From fa3c8d9a1fcc9ceee108bf09d4c56ef74d90843a Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 2 Sep 2019 16:55:09 +1000 Subject: [PATCH] 2.7.2 Reduced exception swallowing as much as possible, fixed walls not having all the stuff, added a few helper methods, updated the odds and ends piece pack to remove redstone ore pieces and add nether quartz ore pieces. --- gradle.properties | 2 +- piecepacks/odds.json | 6 +- .../extrapieces/blocks/ColumnPieceBlock.java | 69 +++++--------- .../extrapieces/blocks/CornerPieceBlock.java | 93 +++++++----------- .../blocks/FenceGatePieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/FencePieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/LayerPieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/PieceBlock.java | 9 ++ .../extrapieces/blocks/PostPieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/SidingPieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/SlabPieceBlock.java | 93 +++++++----------- .../extrapieces/blocks/StairsPieceBlock.java | 94 +------------------ .../extrapieces/blocks/WallPieceBlock.java | 68 ++++++++++++-- src/main/resources/fabric.mod.json | 2 +- 14 files changed, 331 insertions(+), 570 deletions(-) diff --git a/gradle.properties b/gradle.properties index 52c089f5..407bc93c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.6.1+build.165 # Mod Properties - mod_version = 2.7.1 + mod_version = 2.7.2 maven_group = com.shnupbups archives_base_name = extrapieces diff --git a/piecepacks/odds.json b/piecepacks/odds.json index 0210c3bc..06f44000 100644 --- a/piecepacks/odds.json +++ b/piecepacks/odds.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.1.0", "sets": { "dirt": { "base": "minecraft:dirt" @@ -50,8 +50,8 @@ "emerald_ore": { "base": "minecraft:emerald_ore" }, - "redstone_ore": { - "base": "minecraft:redstone_ore" + "quartz_ore": { + "base": "minecraft:quartz_ore" }, "clay": { "base": "minecraft:clay" diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/ColumnPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/ColumnPieceBlock.java index 8a20a624..67eaa60f 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/ColumnPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/ColumnPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -132,73 +133,51 @@ public boolean canPlaceAtSide(BlockState blockState_1, BlockView blockView_1, Bl @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } @Override @@ -206,33 +185,27 @@ public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/CornerPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/CornerPieceBlock.java index 03c05fcb..28072c22 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/CornerPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/CornerPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -100,112 +101,84 @@ public VoxelShape getOutlineShape(BlockState blockState_1, BlockView blockView_1 return NORTH_SHAPE; } } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } public BlockState getPlacementState(ItemPlacementContext itemPlacementContext_1) { diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/FenceGatePieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/FenceGatePieceBlock.java index 57025983..66e7cc0a 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/FenceGatePieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/FenceGatePieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -41,112 +42,84 @@ public PieceSet getSet() { public PieceType getType() { return PieceTypes.FENCE_GATE; } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/FencePieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/FencePieceBlock.java index a1ab5d07..b4b67d1f 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/FencePieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/FencePieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -43,112 +44,84 @@ public PieceSet getSet() { public PieceType getType() { return PieceTypes.FENCE; } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/LayerPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/LayerPieceBlock.java index 9a562c0a..c9c0e066 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/LayerPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/LayerPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -135,111 +136,83 @@ public boolean tryFillWithFluid(IWorld iWorld_1, BlockPos blockPos_1, BlockState public boolean canFillWithFluid(BlockView blockView_1, BlockPos blockPos_1, BlockState blockState_1, Fluid fluid_1) { return blockState_1.get(LAYERS) < 8 && Waterloggable.super.canFillWithFluid(blockView_1, blockPos_1, blockState_1, fluid_1); } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } } diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/PieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/PieceBlock.java index 383b14d1..91e3df65 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/PieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/PieceBlock.java @@ -3,6 +3,7 @@ import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemConvertible; public interface PieceBlock extends ItemConvertible { @@ -15,4 +16,12 @@ public interface PieceBlock extends ItemConvertible { default Block getBase() { return getSet().getBase(); } + + default BlockState getBaseState() { + return getBase().getDefaultState(); + } + + default String getPieceString() { + return getSet().getName()+" "+getType().getId(); + } } diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/PostPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/PostPieceBlock.java index 74e3babe..a1a5f02c 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/PostPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/PostPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -127,112 +128,84 @@ public FluidState getFluidState(BlockState blockState_1) { public boolean canPlaceAtSide(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1, BlockPlacementEnvironment blockPlacementEnvironment_1) { return false; } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/SidingPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/SidingPieceBlock.java index 3cecf0a5..a4c7b0db 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/SidingPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/SidingPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -193,111 +194,83 @@ public boolean canPlaceAtSide(BlockState blockState_1, BlockView blockView_1, Bl public boolean isSideInvisible(BlockState blockState_1, BlockState blockState_2, Direction direction_1) { return getSet().isTransparent() ? (blockState_2.getBlock() == this || super.isSideInvisible(blockState_1, blockState_2, direction_1)) : super.isSideInvisible(blockState_1, blockState_2, direction_1); } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } } diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/SlabPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/SlabPieceBlock.java index a525647f..00e78142 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/SlabPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/SlabPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -45,111 +46,83 @@ public PieceType getType() { public boolean isSideInvisible(BlockState blockState_1, BlockState blockState_2, Direction direction_1) { return getSet().isTransparent() ? (blockState_2.getBlock() == this || super.isSideInvisible(blockState_1, blockState_2, direction_1)) : super.isSideInvisible(blockState_1, blockState_2, direction_1); } - + @Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } - + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { super.onBroken(iWorld_1, blockPos_1, blockState_1); - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } - + @Override public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return super.getBlastResistance(); - } + return this.getBase().getBlastResistance(); } - + @Override public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return super.getRenderLayer(); - } + return this.getBase().getRenderLayer(); } - + @Override public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return super.getTickRate(viewableWorld_1); - } + return this.getBase().getTickRate(viewableWorld_1); } - + @Override public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } } - + @Override public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { super.onSteppedOn(world_1, blockPos_1, entity_1); try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } } - + @Override public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); } - + @Override public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - return a || this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); - } catch (IllegalArgumentException ignored) { - return super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); - } + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } - + @Override public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); } } diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/StairsPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/StairsPieceBlock.java index db01bf3f..f1f14c75 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/StairsPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/StairsPieceBlock.java @@ -1,5 +1,6 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; @@ -45,102 +46,13 @@ public PieceType getType() { public boolean isSideInvisible(BlockState blockState_1, BlockState blockState_2, Direction direction_1) { return getSet().isTransparent() ? (blockState_2.getBlock() == this || super.isSideInvisible(blockState_1, blockState_2, direction_1)) : super.isSideInvisible(blockState_1, blockState_2, direction_1); } - - @Environment(EnvType.CLIENT) - @Override - public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { - try { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} - } - - @Override - public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { - try { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); - } catch (IllegalArgumentException ignored) {} - } - - @Override - public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { - try { - this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); - } catch (IllegalArgumentException ignored) {} - } - - @Override - public float getBlastResistance() { - try { - return this.getBase().getBlastResistance(); - } catch (IllegalArgumentException ignored) { - return this.resistance; - } - } - - @Override - public BlockRenderLayer getRenderLayer() { - try { - return this.getBase().getRenderLayer(); - } catch (IllegalArgumentException ignored) { - return BlockRenderLayer.SOLID; - } - } - - @Override - public int getTickRate(ViewableWorld viewableWorld_1) { - try { - return this.getBase().getTickRate(viewableWorld_1); - } catch (IllegalArgumentException ignored) { - return 10; - } - } - - @Override - public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { - try { - if (blockState_1.getBlock() != blockState_1.getBlock()) { - this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); - this.getBase().onBlockAdded(this.set.getBase().getDefaultState(), world_1, blockPos_1, blockState_2, false); - } - } catch (IllegalArgumentException ignored) {} - } - - @Override - public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { - try { - if (blockState_1.getBlock() != blockState_2.getBlock()) { - this.getBase().getDefaultState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); - } - } catch (IllegalArgumentException ignored) {} - } - + @Override public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { try { this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); - } catch (IllegalArgumentException ignored) {} - } - - @Override - public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { - try { - this.getBase().onScheduledTick(blockState_1, world_1, blockPos_1, random_1); - } catch (IllegalArgumentException ignored) {} - } - - @Override - public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { - try { - return this.getBase().getDefaultState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); } catch (IllegalArgumentException ignored) { - return false; + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); } } - - @Override - public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { - try { - this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); - } catch (IllegalArgumentException ignored) {} - } } diff --git a/src/main/java/com/shnupbups/extrapieces/blocks/WallPieceBlock.java b/src/main/java/com/shnupbups/extrapieces/blocks/WallPieceBlock.java index b0f66aed..3f4d27d8 100644 --- a/src/main/java/com/shnupbups/extrapieces/blocks/WallPieceBlock.java +++ b/src/main/java/com/shnupbups/extrapieces/blocks/WallPieceBlock.java @@ -1,20 +1,22 @@ package com.shnupbups.extrapieces.blocks; +import com.shnupbups.extrapieces.ExtraPieces; import com.shnupbups.extrapieces.core.PieceSet; import com.shnupbups.extrapieces.core.PieceType; import com.shnupbups.extrapieces.core.PieceTypes; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; -import net.minecraft.block.BlockState; -import net.minecraft.block.WallBlock; +import net.minecraft.block.*; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.IWorld; import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; +import net.minecraft.world.explosion.Explosion; import java.util.Random; @@ -40,30 +42,84 @@ public PieceType getType() { } @Environment(EnvType.CLIENT) + @Override public void randomDisplayTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { - this.getBase().randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); + super.randomDisplayTick(blockState_1, world_1, blockPos_1, random_1); + this.getBase().randomDisplayTick(this.getBaseState(), world_1, blockPos_1, random_1); } + @Override public void onBlockBreakStart(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1) { - this.getBase().getDefaultState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); + super.onBlockBreakStart(blockState_1, world_1, blockPos_1, playerEntity_1); + this.getBaseState().onBlockBreakStart(world_1, blockPos_1, playerEntity_1); } + @Override public void onBroken(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) { + super.onBroken(iWorld_1, blockPos_1, blockState_1); this.getBase().onBroken(iWorld_1, blockPos_1, blockState_1); } + @Override public float getBlastResistance() { return this.getBase().getBlastResistance(); } + @Override public BlockRenderLayer getRenderLayer() { return this.getBase().getRenderLayer(); } + @Override public int getTickRate(ViewableWorld viewableWorld_1) { return this.getBase().getTickRate(viewableWorld_1); } + @Override + public void onBlockAdded(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { + super.onBlockAdded(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBase().getDefaultState().neighborUpdate(world_1, blockPos_1, Blocks.AIR, blockPos_1, false); + this.getBase().getDefaultState().onBlockAdded(world_1, blockPos_1, blockState_2, false); + } + } + + @Override + public void onBlockRemoved(BlockState blockState_1, World world_1, BlockPos blockPos_1, BlockState blockState_2, boolean boolean_1) { + super.onBlockRemoved(blockState_1, world_1, blockPos_1, blockState_2, boolean_1); + if (blockState_1.getBlock() != blockState_2.getBlock()) { + this.getBaseState().onBlockRemoved(world_1, blockPos_1, blockState_2, boolean_1); + } + } + + @Override + public void onSteppedOn(World world_1, BlockPos blockPos_1, Entity entity_1) { + super.onSteppedOn(world_1, blockPos_1, entity_1); + try { + this.getBase().onSteppedOn(world_1, blockPos_1, entity_1); + } catch (IllegalArgumentException ignored) { + ExtraPieces.debugLog("Caught an exception in onSteppedOn for "+this.getPieceString()); + } + } + + @Override + public void onScheduledTick(BlockState blockState_1, World world_1, BlockPos blockPos_1, Random random_1) { + super.onScheduledTick(blockState_1, world_1, blockPos_1, random_1); + this.getBase().onScheduledTick(this.getBaseState(), world_1, blockPos_1, random_1); + } + + @Override + public boolean activate(BlockState blockState_1, World world_1, BlockPos blockPos_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1) { + boolean a = super.activate(blockState_1, world_1, blockPos_1, playerEntity_1, hand_1, blockHitResult_1); + return a || this.getBaseState().activate(world_1, playerEntity_1, hand_1, blockHitResult_1); + } + + @Override + public void onDestroyedByExplosion(World world_1, BlockPos blockPos_1, Explosion explosion_1) { + super.onDestroyedByExplosion(world_1, blockPos_1, explosion_1); + this.getBase().onDestroyedByExplosion(world_1, blockPos_1, explosion_1); + } + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState blockState_1, BlockState blockState_2, Direction direction_1) { return getSet().isTransparent() ? (blockState_2.getBlock() == this || super.isSideInvisible(blockState_1, blockState_2, direction_1)) : super.isSideInvisible(blockState_1, blockState_2, direction_1); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a76cea96..bc774022 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "extrapieces", - "version": "2.7.1", + "version": "2.7.2", "name": "Extra Pieces", "description": "Adds more block shapes to Minecraft!",