Skip to content

Commit

Permalink
added cutting capability to swords
Browse files Browse the repository at this point in the history
  • Loading branch information
mickelus committed Jul 16, 2018
1 parent 44fd322 commit af65093
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void onBlur() {
}
};

iconClickable.addChild(new GuiTexture(0, 0, 29, 29, 52, 32, WORKBENCH_TEXTURE));
iconClickable.addChild(new GuiTexture(0, 0, 29, 29, 97, 0, WORKBENCH_TEXTURE));
addChild(iconClickable);

capabilityIndicator = new GuiCapabilityRequirement(6, 7, capability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import se.mickelus.tetra.capabilities.Capability;
import se.mickelus.tetra.gui.GuiElement;
import se.mickelus.tetra.gui.GuiString;
import se.mickelus.tetra.gui.GuiStringOutline;
import se.mickelus.tetra.gui.GuiTexture;

public class GuiCapability extends GuiElement {
Expand All @@ -17,10 +18,10 @@ public GuiCapability(int x, int y, Capability capability) {
super(x, y, 16, 16);
this.capability = capability;

levelIndicator = new GuiString(10, 8, "");
addChild(levelIndicator);

addChild(new GuiTexture(0, 0, 16, 16, capability.ordinal() * 16, 52, texture));

levelIndicator = new GuiStringOutline(10, 8, "");
addChild(levelIndicator);
}

public void update(int level, int color) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/se/mickelus/tetra/capabilities/Capability.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum Capability {
hammer,
axe,
pickaxe
pickaxe,
cut
}
10 changes: 10 additions & 0 deletions src/main/java/se/mickelus/tetra/items/ItemModularHandheld.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class ItemModularHandheld extends ItemModular {
private static final Set<Block> pickaxeBlocks = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE);
private static final Set<Material> pickaxeMaterials = Sets.newHashSet(Material.IRON, Material.ANVIL, Material.ROCK);

private static final Set<Material> cuttingMaterials = Sets.newHashSet(Material.PLANTS, Material.VINE, Material.CORAL, Material.LEAVES, Material.GOURD, Material.WEB);

@Override
public boolean onBlockDestroyed(ItemStack itemStack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
Expand Down Expand Up @@ -240,6 +241,8 @@ public int getHarvestLevel(ItemStack itemStack, String toolClass, @Nullable Enti
public boolean canHarvestBlock(IBlockState blockState, ItemStack itemStack) {
if (pickaxeMaterials.contains(blockState.getMaterial())) {
return getHarvestLevel(itemStack, "pickaxe", null, null) >= 0;
} else if (blockState.getBlock().equals(Blocks.WEB)) {
return getHarvestLevel(itemStack, "cut", null, null) >= 0;
}
return false;
}
Expand All @@ -258,11 +261,18 @@ public float getDestroySpeed(ItemStack itemStack, IBlockState blockState) {
tool = "axe";
} else if (pickaxeBlocks.contains(blockState.getBlock())) {
tool = "pickaxe";
} else if (cuttingMaterials.contains(blockState.getMaterial())) {
tool = "cut";
}
}

float speed = (float) (4 + getSpeedModifier(itemStack)) * getCapabilityEfficiency(itemStack, tool);

// todo: need a better way to handle this
if ("cut".equals(tool) && blockState.getBlock().equals(Blocks.WEB)) {
speed *= 10;
}

if (speed < 1) {
return 1;
}
Expand Down
Binary file modified src/main/resources/assets/tetra/textures/gui/workbench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions src/main/resources/data/tetra/modules/sword/basic_blade.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"glyph": { "tint": "9d804e" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -18,6 +21,9 @@
"glyph": { "tint": "694f2f" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -28,6 +34,9 @@
"glyph": { "tint": "c8b77d" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -38,6 +47,9 @@
"glyph": { "tint": "996e4c" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -49,6 +61,9 @@
"glyph": { "tint": "ac5d33" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -59,6 +74,9 @@
"glyph": { "tint": "3c2712" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -69,6 +87,9 @@
"glyph": { "tint": "9a9a9a" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -79,6 +100,9 @@
"glyph": { "tint": "9a9a9a" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -89,6 +113,9 @@
"glyph": { "tint": "8a6658" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -99,6 +126,9 @@
"glyph": { "tint": "b1b1b3" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -109,6 +139,9 @@
"glyph": { "tint": "79797a" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -119,6 +152,9 @@
"glyph": { "tint": "d8d8d8" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -130,6 +166,9 @@
"glyph": { "tint": "343434" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -140,6 +179,9 @@
"glyph": { "tint": "eaee57" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -150,6 +192,9 @@
"glyph": { "tint": "33ebcb" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -161,6 +206,9 @@
"glyph": { "tint": "3c3056" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -171,6 +219,9 @@
"glyph": { "tint": "df7646" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -181,6 +232,9 @@
"glyph": { "tint": "b3c9c1" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -191,6 +245,9 @@
"glyph": { "tint": "d6f6ff" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -201,6 +258,9 @@
"glyph": { "tint": "c2d3a6" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -212,6 +272,9 @@
"glyph": { "tint": "897a9b" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -222,6 +285,9 @@
"glyph": { "tint": "b2712c" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -232,6 +298,9 @@
"glyph": { "tint": "e4da4c" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -242,6 +311,9 @@
"glyph": { "tint": "999999" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -252,6 +324,9 @@
"glyph": { "tint": "4d3984" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -262,6 +337,9 @@
"glyph": { "tint": "5ea917" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -272,6 +350,9 @@
"glyph": { "tint": "458430" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -282,6 +363,9 @@
"glyph": { "tint": "fa9f00" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
},
{
Expand All @@ -293,6 +377,9 @@
"glyph": { "tint": "b8cf9c" },
"effects": {
"sweeping": 1
},
"capabilities": {
"cut": [1, 0.9375]
}
}
]
Loading

0 comments on commit af65093

Please sign in to comment.