Skip to content

Commit

Permalink
more more more
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Feb 16, 2024
1 parent cd9424b commit cb4b800
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public static void registerWaxedBlock(ZetaModule module, Block clean, Block waxe
waxingByModule.put(module, Pair.of(clean, waxed));
}

public static void registerWaxedBlockBooleanProperty(ZetaModule module, Block clean, Block waxed, BooleanProperty property) {
public static void registerWaxedBlockBooleanProperty(ZetaModule module, Block block, BooleanProperty property) {
BooleanPropertyWaxableBlock booleanPropertyWaxableBlock =
new BooleanPropertyWaxableBlock(module, clean, waxed, property, ToolActions.AXE_WAX_OFF);
new BooleanPropertyWaxableBlock(module, block, property, ToolActions.AXE_WAX_OFF);

booleanPropertySet.add(booleanPropertyWaxableBlock);

waxingByModule.put(module, Pair.of(clean, waxed));
waxingByModule.put(module, Pair.of(block, block));
}

public static void registerInteraction(ToolAction action, Block in, Block out) {
Expand Down Expand Up @@ -101,9 +101,8 @@ public static void toolActionEvent(ZBlock.BlockToolModification event) {
BlockState state = event.getState();
Block block = state.getBlock();

if(waxableBlock.clean == block) {
Block finalBlock = waxableBlock.waxed;
event.setFinalState(copyState(state, finalBlock)
if(waxableBlock.block == block) {
event.setFinalState(copyState(state, waxableBlock.block)
.setValue(waxableBlock.property, false)
);
}
Expand Down Expand Up @@ -139,14 +138,12 @@ public static void itemUse(ZRightClickBlock event) {
}

for (BooleanPropertyWaxableBlock waxableBlock : booleanPropertySet) {
if(waxableBlock.clean == block) {
Block alternate = waxableBlock.waxed;

if(waxableBlock.block == block) {
if(event.getEntity() instanceof ServerPlayer sp)
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(sp, pos, stack);

if(!world.isClientSide)
world.setBlockAndUpdate(pos, copyState(state, alternate)
world.setBlockAndUpdate(pos, copyState(state, waxableBlock.block)
.setValue(waxableBlock.property, true)
);
world.levelEvent(event.getPlayer(), LevelEvent.PARTICLES_AND_SOUND_WAX_ON, pos, 0);
Expand Down Expand Up @@ -174,15 +171,13 @@ private static BlockState copyState(BlockState original, Block newBlock) {

public static class BooleanPropertyWaxableBlock {
public ZetaModule module;
public Block clean;
public Block waxed;
public Block block;
public BooleanProperty property;
public ToolAction action;

private BooleanPropertyWaxableBlock(ZetaModule module, Block clean, Block waxed, BooleanProperty property, ToolAction action) {
private BooleanPropertyWaxableBlock(ZetaModule module, Block block, BooleanProperty property, ToolAction action) {
this.module = module;
this.clean = clean;
this.waxed = waxed;
this.block = block;
this.property = property;
this.action = action;
}
Expand Down

0 comments on commit cb4b800

Please sign in to comment.