-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fences #572
Merged
Merged
Added fences #572
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a98da3
fences
GameJarne 0445dd0
Merge branch 'MinicraftPlus:main' into main
GameJarne 783fd84
Update FenceTile.java
GameJarne acab5ec
Update en-us.json
GameJarne 9d36424
Update fence textures
GameJarne b7d02b9
fixed fence textures
GameJarne d9c793d
Merge branch 'main' into main
Litorom b57791e
Merge remote-tracking branch 'upstream/main'
GameJarne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
package minicraft.level.tile; | ||
|
||
import minicraft.core.Game; | ||
import minicraft.core.io.Sound; | ||
import minicraft.entity.Direction; | ||
import minicraft.entity.Entity; | ||
import minicraft.entity.mob.Mob; | ||
import minicraft.entity.mob.Player; | ||
import minicraft.entity.particle.SmashParticle; | ||
import minicraft.entity.particle.TextParticle; | ||
import minicraft.gfx.Color; | ||
import minicraft.gfx.Screen; | ||
import minicraft.gfx.Sprite; | ||
import minicraft.gfx.SpriteAnimation; | ||
import minicraft.gfx.SpriteLinker; | ||
import minicraft.gfx.SpriteLinker.LinkedSprite; | ||
import minicraft.gfx.SpriteLinker.SpriteType; | ||
import minicraft.item.Item; | ||
import minicraft.item.Items; | ||
import minicraft.item.ToolItem; | ||
import minicraft.level.Level; | ||
import minicraft.util.AdvancementElement; | ||
import minicraft.util.Logging; | ||
|
||
public class FenceTile extends Tile { | ||
|
||
private static SpriteAnimation wood = new SpriteAnimation(SpriteType.Tile, "wood_fence"); | ||
private static SpriteAnimation stone = new SpriteAnimation(SpriteType.Tile, "stone_fence"); | ||
private static SpriteAnimation obsidian = new SpriteAnimation(SpriteType.Tile, "obsidian_fence"); | ||
|
||
protected Material type; | ||
|
||
protected SpriteAnimation top, bottom, left, right; | ||
|
||
public boolean connectUp = false, connectDown = false, connectLeft = false, connectRight = false; | ||
|
||
protected FenceTile(Material type) { this(type, null); } | ||
protected FenceTile(Material type, String name) { | ||
super(type.name() + " " + (name == null ? "Fence" : name), null); | ||
this.type = type; | ||
switch (type) | ||
{ | ||
case Wood: | ||
sprite = wood; | ||
connectsToGrass = true; | ||
break; | ||
case Stone: | ||
sprite = stone; | ||
break; | ||
case Obsidian: | ||
sprite = obsidian; | ||
break; | ||
} | ||
top = new SpriteAnimation(SpriteType.Tile, type.name().toLowerCase() + "_fence_top"); | ||
bottom = new SpriteAnimation(SpriteType.Tile, type.name().toLowerCase() + "_fence_bottom"); | ||
left = new SpriteAnimation(SpriteType.Tile, type.name().toLowerCase() + "_fence_left"); | ||
right = new SpriteAnimation(SpriteType.Tile, type.name().toLowerCase() + "_fence_right"); | ||
} | ||
|
||
public void updateConnections(Level level, int x, int y) | ||
{ | ||
connectUp = level.getTile(x, y - 1).name.equals(name); | ||
connectDown = level.getTile(x, y + 1).name.equals(name); | ||
connectLeft = level.getTile(x - 1, y).name.equals(name); | ||
connectRight = level.getTile(x + 1, y).name.equals(name); | ||
} | ||
|
||
public boolean mayPass(Level level, int x, int y, Entity e) { | ||
return false; | ||
} | ||
|
||
public void render(Screen screen, Level level, int x, int y) | ||
{ | ||
switch (type) | ||
{ | ||
case Wood: Tiles.get("Grass").render(screen, level, x, y); break; | ||
case Stone: Tiles.get("Stone Bricks").render(screen, level, x, y); break; | ||
case Obsidian: Tiles.get("Obsidian").render(screen, level, x, y); break; | ||
} | ||
|
||
sprite.render(screen, level, x, y); | ||
|
||
updateConnections(level, x, y); | ||
|
||
// up | ||
if (connectUp) { | ||
top.render(screen, level, x, y); | ||
} | ||
// bottom | ||
if (connectDown) { | ||
bottom.render(screen, level, x, y); | ||
} | ||
// left | ||
if (connectLeft) { | ||
left.render(screen, level, x, y); | ||
} | ||
// right | ||
if (connectRight) { | ||
right.render(screen, level, x, y); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hurt(Level level, int x, int y, Mob source, int dmg, Direction attackDir) { | ||
hurt(level, x, y, dmg); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean interact(Level level, int xt, int yt, Player player, Item item, Direction attackDir) { | ||
if(Game.isMode("minicraft.settings.mode.creative")) | ||
return false; // Go directly to hurt method | ||
if (item instanceof ToolItem) { | ||
ToolItem tool = (ToolItem) item; | ||
if (tool.type == type.getRequiredTool()) { | ||
if (player.payStamina(4 - tool.level) && tool.payDurability()) { | ||
int data = level.getData(xt, yt); | ||
hurt(level, xt, yt, tool.getDamage()); | ||
AdvancementElement.AdvancementTrigger.ItemUsedOnTileTrigger.INSTANCE.trigger( | ||
new AdvancementElement.AdvancementTrigger.ItemUsedOnTileTrigger.ItemUsedOnTileTriggerConditionHandler.ItemUsedOnTileTriggerConditions( | ||
item, this, data, xt, yt, level.depth)); | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public void hurt(Level level, int x, int y, int dmg) { | ||
int damage = level.getData(x, y) + dmg; | ||
int fenceHealth = 5; | ||
if (Game.isMode("minicraft.settings.mode.creative")) dmg = damage = fenceHealth; | ||
|
||
level.add(new SmashParticle(x * 16, y * 16)); | ||
Sound.play("monsterhurt"); | ||
|
||
level.add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, Color.RED)); | ||
|
||
if (damage >= fenceHealth) { | ||
String itemName = "", tilename = ""; | ||
switch (type) { // Get what tile to set and what item to drop | ||
case Wood: { | ||
itemName = "Wood Fence"; | ||
tilename = "Grass"; | ||
break; | ||
} | ||
case Stone: { | ||
itemName = "Stone Fence"; | ||
tilename = "Stone Bricks"; | ||
break; | ||
} | ||
case Obsidian: { | ||
itemName = "Obsidian Fence"; | ||
tilename = "Obsidian"; | ||
break; | ||
} | ||
} | ||
|
||
level.dropItem(x * 16 + 8, y * 16 + 8, 1, 1, Items.get(itemName)); | ||
level.setTile(x, y, Tiles.get(tilename)); | ||
} else { | ||
level.setData(x, y, damage); | ||
} | ||
} | ||
|
||
public boolean tick(Level level, int xt, int yt) { | ||
int damage = level.getData(xt, yt); | ||
if (damage > 0) { | ||
level.setData(xt, yt, damage - 1); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public String getName(int data) { | ||
return Material.values[data].name() + " Fence"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+126 Bytes
src/client/resources/assets/textures/tile/obsidian_fence_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,32 @@ | |
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.wood_fence": { | ||
"criteria": { | ||
"has_plank": { | ||
"trigger": "inventory_changed", | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"plank" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_plank" | ||
] | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure why this is here. I assume this will break the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't break the code as it follows the format |
||
"rewards": { | ||
"recipes": { | ||
"Wood Fence_1": ["plank_3"] | ||
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.lantern": { | ||
"criteria": { | ||
"has_wood": { | ||
|
@@ -298,6 +324,32 @@ | |
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.stone_fence": { | ||
"criteria": { | ||
"has_stone_brick": { | ||
"trigger": "inventory_changed", | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"stone brick" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_stone_brick" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": { | ||
"Stone Fence_1": ["Stone Brick_3"] | ||
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.obsidian_brick": { | ||
"criteria": { | ||
"has_raw_obsidian": { | ||
|
@@ -402,6 +454,32 @@ | |
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.obsidian_fence": { | ||
"criteria": { | ||
"has_obsidian_brick": { | ||
"trigger": "inventory_changed", | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"obsidian brick" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_obsidian_brick" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": { | ||
"Obsidian Fence_1": ["Obsidian Brick_3"] | ||
} | ||
} | ||
}, | ||
"minicraft.advancements.recipes.oven": { | ||
"criteria": { | ||
"has_stone": { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using there ids two times is absolutely catastrophic!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are aware that this is because that it was made using another outdated version of the code therefore it’s technically correct at that time. However now it has to be adjusted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of a merge is to adjust the written code to reflect changes upstream. It wouldn't be hard to fix.