Skip to content

Commit

Permalink
clean up world accelerator NBT
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Sep 9, 2021
1 parent a20d8c9 commit e8fc713
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.metatileentity.TieredMetaTileEntity;
import gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase;
import gregtech.api.pipenet.tile.TileEntityPipeBase;
import gregtech.api.render.Textures;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
Expand Down Expand Up @@ -104,17 +104,15 @@ public void update() {
BlockPos[] neighbours = new BlockPos[]{worldAcceleratorPos.down(), worldAcceleratorPos.up(), worldAcceleratorPos.north(), worldAcceleratorPos.south(), worldAcceleratorPos.east(), worldAcceleratorPos.west()};
for (BlockPos neighbour : neighbours) {
TileEntity targetTE = world.getTileEntity(neighbour);
if (targetTE == null || targetTE instanceof TileEntityMaterialPipeBase || targetTE instanceof MetaTileEntityHolder) {
if (targetTE == null || targetTE instanceof TileEntityPipeBase || targetTE instanceof MetaTileEntityHolder) {
continue;
}
boolean horror = false;
if (clazz != null && targetTE instanceof ITickable) {
horror = clazz.isInstance(targetTE);
}
if (targetTE instanceof ITickable && (!horror || !world.isRemote)) {
IntStream.range(0, (int) Math.pow(2, getTier())).forEach(value -> {
((ITickable) targetTE).update();
});
IntStream.range(0, (int) Math.pow(2, getTier())).forEach(value -> ((ITickable) targetTE).update());
}
}
} else {
Expand All @@ -126,7 +124,7 @@ public void update() {

IBlockState targetBlock = world.getBlockState(cell);
IntStream.range(0, (int) Math.pow(2, getTier())).forEach(value -> {
if (world.rand.nextInt(100) == 0) {
if (GTValues.RNG.nextInt(100) == 0) {
if (targetBlock.getBlock().getTickRandomly()) {
targetBlock.getBlock().randomTick(world, cell, targetBlock, world.rand);
}
Expand Down Expand Up @@ -193,16 +191,16 @@ public boolean isTEMode() {
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setTag("TileMode", new NBTTagString(Boolean.valueOf(tileMode).toString()));
data.setTag("isPaused", new NBTTagString(Boolean.valueOf(isPaused).toString()));
data.setBoolean("TileMode", tileMode);
data.setBoolean("isPaused", isPaused);
return data;
}

@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
tileMode = Boolean.parseBoolean(data.getString("TileMode"));
isPaused = Boolean.parseBoolean(data.getString("isPaused"));
tileMode = data.getBoolean("TileMode");
isPaused = data.getBoolean("isPaused");
}

@Override
Expand Down

0 comments on commit e8fc713

Please sign in to comment.