From a7de6b428afc0a050a109f1994c8f58e9d69ed16 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Sat, 27 Jul 2019 01:52:51 +0300 Subject: [PATCH] Cleanups --- .../blockentity/AlarmBlockEntity.java | 41 ++++++++++--------- .../blockentity/cable/CableBlockEntity.java | 14 +++---- .../transformers/TransformerBlockEntity.java | 4 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/java/techreborn/blockentity/AlarmBlockEntity.java b/src/main/java/techreborn/blockentity/AlarmBlockEntity.java index 347e1d0d4..40ede888a 100644 --- a/src/main/java/techreborn/blockentity/AlarmBlockEntity.java +++ b/src/main/java/techreborn/blockentity/AlarmBlockEntity.java @@ -49,17 +49,19 @@ public class AlarmBlockEntity extends BlockEntity super(TRBlockEntities.ALARM); } - public void rightClick() { - if (!world.isClient) { - if (selectedSound < 3) { - selectedSound++; - } else { - selectedSound = 1; - } - ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText( - Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound)); - } - } + public void rightClick() { + if (world.isClient) { + return; + } + + if (selectedSound < 3) { + selectedSound++; + } else { + selectedSound = 1; + } + ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText( + Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound)); + } // BlockEntity @Override @@ -79,16 +81,16 @@ public class AlarmBlockEntity extends BlockEntity super.fromTag(compound); } - //TODO 1.13 seems to be gone? -// @Override -// public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { -// return false; -// } - // ITickable @Override public void tick() { - if (!world.isClient && world.getTime() % 25 == 0 && world.isReceivingRedstonePower(getPos())) { + if (world.isClient()){ + return; + } + if (world.getTime() % 25 != 0) { + return; + } + if (world.isReceivingRedstonePower(getPos())) { BlockAlarm.setActive(true, world, pos); switch (selectedSound) { case 1: @@ -101,8 +103,7 @@ public class AlarmBlockEntity extends BlockEntity world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F); break; } - - } else if (!world.isClient && world.getTime() % 25 == 0) { + } else { BlockAlarm.setActive(false, world, pos); } } diff --git a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java index 784cc9609..bf222a42e 100644 --- a/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/cable/CableBlockEntity.java @@ -149,13 +149,13 @@ public class CableBlockEntity extends BlockEntity return; } Collections.shuffle(acceptors); - for (EnergyBlockEntity blockEntity : acceptors) { - double drain = Math.min(energy, transferRate); - if (drain > 0 && blockEntity.addEnergy(drain, true) > 0) { - double move = blockEntity.addEnergy(drain, false); - useEnergy(move, false); - } - } + acceptors.forEach(blockEntity -> { + double drain = Math.min(energy, transferRate); + if (drain > 0 && blockEntity.addEnergy(drain, true) > 0) { + double move = blockEntity.addEnergy(drain, false); + useEnergy(move, false); + } + }); } // IListInfoProvider diff --git a/src/main/java/techreborn/blockentity/transformers/TransformerBlockEntity.java b/src/main/java/techreborn/blockentity/transformers/TransformerBlockEntity.java index 02f00deaa..aef7c614a 100644 --- a/src/main/java/techreborn/blockentity/transformers/TransformerBlockEntity.java +++ b/src/main/java/techreborn/blockentity/transformers/TransformerBlockEntity.java @@ -89,7 +89,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity @Override public boolean canAcceptEnergy(Direction direction) { - if (IC2TransformersStyle == true){ + if (IC2TransformersStyle){ return getFacingEnum() == direction; } return getFacingEnum() != direction; @@ -97,7 +97,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity @Override public boolean canProvideEnergy(Direction direction) { - if (IC2TransformersStyle == true){ + if (IC2TransformersStyle){ return getFacingEnum() != direction; } return getFacing() == direction;