From 2130c637fb2e41db7b04ca2b9ec425f936b840cd Mon Sep 17 00:00:00 2001 From: Ella Paws <> Date: Mon, 7 Feb 2022 04:50:22 +0100 Subject: [PATCH] minor adjustments and fixes and cleaned imports --- main/java/ella/techia/TechiaClient.java | 9 +++++-- main/java/ella/techia/block/Connector.java | 16 ------------ main/java/ella/techia/block/Inverter.java | 4 +-- .../ella/techia/block/LetiConnectable.java | 8 ------ main/java/ella/techia/block/LetiToggle.java | 17 +------------ main/java/ella/techia/block/Smelter.java | 25 ++++++++++++++++--- main/java/ella/techia/block/ToolBlock.java | 1 - main/java/ella/techia/leti/LetiNetwork.java | 2 ++ 8 files changed, 33 insertions(+), 49 deletions(-) diff --git a/main/java/ella/techia/TechiaClient.java b/main/java/ella/techia/TechiaClient.java index ce91676..b3072b9 100644 --- a/main/java/ella/techia/TechiaClient.java +++ b/main/java/ella/techia/TechiaClient.java @@ -1,11 +1,16 @@ package ella.techia; +import ella.techia.registry.TechiaRegistry; import ella.techia.screen.*; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public class TechiaClient implements ClientModInitializer { @Override - public void onInitializeClient() { - ScreenRegistry.register(Techia.BOX_SCREEN_HANDLER, BoxScreen::new); + public void onInitializeClient(){ + ScreenRegistry.register(TechiaRegistry.BOX_SCREEN_HANDLER, BoxScreen::new); + ScreenRegistry.register(TechiaRegistry.WORKBENCH_SCREEN_HANDLER, WorkbenchScreen::new); + ScreenRegistry.register(TechiaRegistry.SMELTER_SCREEN_HANDLER, SmelterScreen::new); } } diff --git a/main/java/ella/techia/block/Connector.java b/main/java/ella/techia/block/Connector.java index b11b299..0d05868 100644 --- a/main/java/ella/techia/block/Connector.java +++ b/main/java/ella/techia/block/Connector.java @@ -2,26 +2,10 @@ package ella.techia.block; import ella.techia.leti.LetiNetwork; import net.minecraft.block.*; -import net.minecraft.entity.ai.pathing.NavigationType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.WorldView; public class Connector extends LetiConnectable { diff --git a/main/java/ella/techia/block/Inverter.java b/main/java/ella/techia/block/Inverter.java index 63d6afb..9004c9e 100644 --- a/main/java/ella/techia/block/Inverter.java +++ b/main/java/ella/techia/block/Inverter.java @@ -1,11 +1,9 @@ package ella.techia.block; import net.minecraft.block.*; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; public class Inverter extends FacingLeti /*implements LetiBlock, Waterloggable*/ { diff --git a/main/java/ella/techia/block/LetiConnectable.java b/main/java/ella/techia/block/LetiConnectable.java index 5235fea..ac6a5ec 100644 --- a/main/java/ella/techia/block/LetiConnectable.java +++ b/main/java/ella/techia/block/LetiConnectable.java @@ -2,26 +2,18 @@ package ella.techia.block; import ella.techia.leti.LetiNetwork; import net.minecraft.block.*; -import net.minecraft.entity.ai.pathing.NavigationType; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; -import net.minecraft.world.World; import net.minecraft.world.WorldAccess; -import net.minecraft.world.WorldView; public abstract class LetiConnectable extends Block implements LetiBlock, Waterloggable { diff --git a/main/java/ella/techia/block/LetiToggle.java b/main/java/ella/techia/block/LetiToggle.java index dca8c21..17d8589 100644 --- a/main/java/ella/techia/block/LetiToggle.java +++ b/main/java/ella/techia/block/LetiToggle.java @@ -2,26 +2,13 @@ package ella.techia.block; import ella.techia.leti.LetiNetwork; import net.minecraft.block.*; -import net.minecraft.entity.ai.pathing.NavigationType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.WorldView; public class LetiToggle extends LetiConnectable { @@ -42,11 +29,9 @@ public class LetiToggle extends LetiConnectable { super.onUse(state, world, pos, player, hand, hit); boolean pow = state.get(Properties.POWERED); world.setBlockState(pos, state.with(Properties.POWERED, !pow)); - // Will this play the sound for only the player? probably not what we want world.playSound(player, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3f, pow? 0.5f: 0.6f); - //world.playSound(pos.x, pos.y, pos.z, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3f, pow? 0.5f: 0.6f, true); for(LetiNetwork network : LetiNetwork.findAdjacentNetworks()){ - network.updateInputs(pow); + network.updateInputs(); } return ActionResult.SUCCESS; } diff --git a/main/java/ella/techia/block/Smelter.java b/main/java/ella/techia/block/Smelter.java index 108d7f2..e36458c 100644 --- a/main/java/ella/techia/block/Smelter.java +++ b/main/java/ella/techia/block/Smelter.java @@ -3,9 +3,13 @@ package ella.techia.block; import ella.techia.block.entity.SmelterEntity; import ella.techia.registry.TechiaRegistry; import java.util.Random; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.block.*; +//import net.minecraft.client.particle.ParticleManager import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.particle.*; import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -17,6 +21,14 @@ public class Smelter extends BlockWithEntity { public Smelter(net.minecraft.block.AbstractBlock.Settings settings){ super(settings); + this.setDefaultState(this.stateManager.getDefaultState().with(Properties.LIT, true)); + // FIXME when lava can properly be inserted and taken out (whyever you'd do that), set default lit state to false! + } + + @Override + protected void appendProperties(StateManager.Builder builder){ + super.appendProperties(builder); + builder.add(Properties.LIT); } @Override @@ -26,6 +38,7 @@ public class Smelter extends BlockWithEntity { @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit){ + // TODO lava bucket if(!world.isClient){ NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos); @@ -54,8 +67,14 @@ public class Smelter extends BlockWithEntity { } } - /*@Override + @Override + @Environment(CLIENT) public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random){ - TODO particles and/or sound - }*/ + if(state.get(Properties.LIT)){ + if(random.nextFloat() < 0.005f) + world.playSound(null, pos, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.AMBIENT, 0.5f, 1f); + if(random.nextFloat() < 0.05f) + ((ClientWorld)world).addParticle(ParticleTypes.SMOKE, (double)pos.getX() + 0.125 + random.nextDouble() * 0.75, (double)pos.getY() + 1.03, (double)pos.getZ() + 0.125 + random.nextDouble() * 0.75, 0, 0.02, 0.13, 0.02, 0.4d); + } + } } diff --git a/main/java/ella/techia/block/ToolBlock.java b/main/java/ella/techia/block/ToolBlock.java index 0942a30..dd43f7a 100644 --- a/main/java/ella/techia/block/ToolBlock.java +++ b/main/java/ella/techia/block/ToolBlock.java @@ -6,7 +6,6 @@ import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; diff --git a/main/java/ella/techia/leti/LetiNetwork.java b/main/java/ella/techia/leti/LetiNetwork.java index d9baca2..bbd7df6 100644 --- a/main/java/ella/techia/leti/LetiNetwork.java +++ b/main/java/ella/techia/leti/LetiNetwork.java @@ -1,6 +1,8 @@ package ella.techia.leti; import java.util.*; +import java.util.AbstractSet; +import java.util.Iterator; import java.util.Map.Entry; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos;