This commit is contained in:
drcrazy 2019-07-27 01:52:51 +03:00
parent 4e1dfa0018
commit a7de6b428a
3 changed files with 30 additions and 29 deletions

View file

@ -49,17 +49,19 @@ public class AlarmBlockEntity extends BlockEntity
super(TRBlockEntities.ALARM); super(TRBlockEntities.ALARM);
} }
public void rightClick() { public void rightClick() {
if (!world.isClient) { if (world.isClient) {
if (selectedSound < 3) { return;
selectedSound++; }
} else {
selectedSound = 1; if (selectedSound < 3) {
} selectedSound++;
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText( } else {
Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound)); selectedSound = 1;
} }
} ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText(
Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
}
// BlockEntity // BlockEntity
@Override @Override
@ -79,16 +81,16 @@ public class AlarmBlockEntity extends BlockEntity
super.fromTag(compound); 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 // ITickable
@Override @Override
public void tick() { 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); BlockAlarm.setActive(true, world, pos);
switch (selectedSound) { switch (selectedSound) {
case 1: 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); world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
break; break;
} }
} else {
} else if (!world.isClient && world.getTime() % 25 == 0) {
BlockAlarm.setActive(false, world, pos); BlockAlarm.setActive(false, world, pos);
} }
} }

View file

@ -149,13 +149,13 @@ public class CableBlockEntity extends BlockEntity
return; return;
} }
Collections.shuffle(acceptors); Collections.shuffle(acceptors);
for (EnergyBlockEntity blockEntity : acceptors) { acceptors.forEach(blockEntity -> {
double drain = Math.min(energy, transferRate); double drain = Math.min(energy, transferRate);
if (drain > 0 && blockEntity.addEnergy(drain, true) > 0) { if (drain > 0 && blockEntity.addEnergy(drain, true) > 0) {
double move = blockEntity.addEnergy(drain, false); double move = blockEntity.addEnergy(drain, false);
useEnergy(move, false); useEnergy(move, false);
} }
} });
} }
// IListInfoProvider // IListInfoProvider

View file

@ -89,7 +89,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
@Override @Override
public boolean canAcceptEnergy(Direction direction) { public boolean canAcceptEnergy(Direction direction) {
if (IC2TransformersStyle == true){ if (IC2TransformersStyle){
return getFacingEnum() == direction; return getFacingEnum() == direction;
} }
return getFacingEnum() != direction; return getFacingEnum() != direction;
@ -97,7 +97,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
@Override @Override
public boolean canProvideEnergy(Direction direction) { public boolean canProvideEnergy(Direction direction) {
if (IC2TransformersStyle == true){ if (IC2TransformersStyle){
return getFacingEnum() != direction; return getFacingEnum() != direction;
} }
return getFacing() == direction; return getFacing() == direction;