Skip to content

Commit

Permalink
applied spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Jun 27, 2024
1 parent 88b02a2 commit 7663b0d
Show file tree
Hide file tree
Showing 54 changed files with 1,339 additions and 1,248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import com.gtnewhorizons.modularui.common.peripheral.ModularUIPeripheralInputHandler;
import com.gtnewhorizons.modularui.integration.nei.ModularUIContainerObjectHandler;
// import com.recursive_pineapple.nuclear_horizons.reactors.gui.GuiHandler;

import codechicken.nei.guihook.GuiContainerManager;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;

public class ClientProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);

GuiContainerManager.addInputHandler(new ModularUIPeripheralInputHandler());
GuiContainerManager.addObjectHandler(new ModularUIContainerObjectHandler());
// NetworkRegistry.INSTANCE.registerGuiHandler(NuclearHorizons.instance, new GuiHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

import javax.annotation.Nullable;

import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;

import com.recursive_pineapple.nuclear_horizons.NuclearHorizons;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.IUpdateableTileEntity;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileReactorSimulator;
Expand All @@ -20,23 +27,24 @@
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;

public class PacketDispatcher {

private static byte packetId = 0;

public static final SimpleNetworkWrapper DISPATCHER = NetworkRegistry.INSTANCE.newSimpleChannel(NuclearHorizons.MODID);


public static final SimpleNetworkWrapper DISPATCHER = NetworkRegistry.INSTANCE
.newSimpleChannel(NuclearHorizons.MODID);

public static final void registerPackets() {
DISPATCHER.registerMessage(ReactorSimulationFinishedMessage::handle, ReactorSimulationFinishedMessage.class, packetId++, Side.SERVER);
DISPATCHER.registerMessage(
ReactorSimulationFinishedMessage::handle,
ReactorSimulationFinishedMessage.class,
packetId++,
Side.SERVER);
}

public static class ReactorSimulationFinishedMessage implements IMessage {

public int dimensionId, x, y, z;

public SimulationResult result;
Expand All @@ -62,24 +70,24 @@ public void toBytes(ByteBuf buf) {
}

public static IMessage handle(IMessage message, MessageContext ctx) {
if(!(message instanceof ReactorSimulationFinishedMessage msg)) {
if (!(message instanceof ReactorSimulationFinishedMessage msg)) {
return null;
}

WorldServer dim = null;

for(var world : MinecraftServer.getServer().worldServers) {
if(world.provider.dimensionId == msg.dimensionId) {
for (var world : MinecraftServer.getServer().worldServers) {
if (world.provider.dimensionId == msg.dimensionId) {
dim = world;
break;
}
}

if(dim == null) {
if (dim == null) {
return null;
}

if(dim.getTileEntity(msg.x, msg.y, msg.z) instanceof TileReactorSimulator sim) {
if (dim.getTileEntity(msg.x, msg.y, msg.z) instanceof TileReactorSimulator sim) {
sim.setSimulationResult(msg.result);
}

Expand Down Expand Up @@ -107,16 +115,17 @@ public static void init() {
throw new RuntimeException(e);
}

List<Map.Entry<String, Class<? extends TileEntity>>> updateableTileEntities = nameToClass
.entrySet()
List<Map.Entry<String, Class<? extends TileEntity>>> updateableTileEntities = nameToClass.entrySet()
.stream()
.filter(e -> IUpdateableTileEntity.class.isAssignableFrom(e.getValue()))
.sorted((a, b) -> a.getKey().compareTo(b.getKey()))
.sorted(
(a, b) -> a.getKey()
.compareTo(b.getKey()))
.collect(Collectors.toList());

int nextId = 0;

for(var e : updateableTileEntities) {
for (var e : updateableTileEntities) {
idToClass.put(nextId, e.getValue());
classToId.put(e.getValue(), nextId);
nextId++;
Expand All @@ -128,18 +137,19 @@ public static void init() {
public static @Nullable TileEntityUpdatedMessage fromUpdateableTileEntity(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);

if(te == null) {
if (te == null) {
NuclearHorizons.LOG.warn(
"Tried to update null tile entity! dimension=%d, x=%d, y=%d, z=%d, tileEntity=%s",
world.provider.dimensionId,
x, y, z,
Objects.toString(te)
);
x,
y,
z,
Objects.toString(te));

return null;
}

if(te instanceof IUpdateableTileEntity ute) {
if (te instanceof IUpdateableTileEntity ute) {
var msg = new TileEntityUpdatedMessage();

msg.dimensionId = world.provider.dimensionId;
Expand All @@ -154,9 +164,10 @@ public static void init() {
NuclearHorizons.LOG.warn(
"Tried to update non-IUpdateableTileEntity tile entity! dimension=%d, x=%d, y=%d, z=%d, tileEntity=%s",
world.provider.dimensionId,
x, y, z,
Objects.toString(te)
);
x,
y,
z,
Objects.toString(te));

return null;
}
Expand Down Expand Up @@ -185,34 +196,36 @@ public void toBytes(ByteBuf buf) {
}

public static IMessage handle(IMessage message, MessageContext ctx) {
if(ctx.side == Side.CLIENT && message instanceof TileEntityUpdatedMessage msg) {
if (ctx.side == Side.CLIENT && message instanceof TileEntityUpdatedMessage msg) {
var world = Minecraft.getMinecraft().theWorld;

Class<? extends TileEntity> msgTeClass = idToClass.get(msg.tileEntityId);

if(world.provider.dimensionId == msg.dimensionId) {
if (world.provider.dimensionId == msg.dimensionId) {
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);

if(te != null && te.getClass() == msgTeClass && te instanceof IUpdateableTileEntity ute) {
if (te != null && te.getClass() == msgTeClass && te instanceof IUpdateableTileEntity ute) {
ute.onNetworkUpdate(msg.data);
} else {
NuclearHorizons.LOG.warn(
"Received update for invalid tile entity! dimension=%d, x=%d, y=%d, z=%d, tileEntityClass=%s, actualTileEntity=%s, data=%s",
msg.dimensionId,
msg.x, msg.y, msg.z,
msg.x,
msg.y,
msg.z,
msgTeClass.getName(),
te,
msg.data.toString()
);
msg.data.toString());
}
} else {
NuclearHorizons.LOG.warn(
"Received update for tile entity in another dimension! dimension=%d, x=%d, y=%d, z=%d, tileEntityClass=%s, data=%s",
msg.dimensionId,
msg.x, msg.y, msg.z,
msg.x,
msg.y,
msg.z,
msgTeClass.getName(),
msg.data.toString()
);
msg.data.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static cpw.mods.fml.common.registry.GameRegistry.registerBlock;
import static cpw.mods.fml.common.registry.GameRegistry.registerTileEntity;

import net.minecraft.block.material.Material;

import com.recursive_pineapple.nuclear_horizons.NuclearHorizons;
import com.recursive_pineapple.nuclear_horizons.reactors.fluids.FluidList;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileAccessHatch;
Expand All @@ -13,10 +15,8 @@
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileRedstonePort;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileThermalSensor;

import net.minecraft.block.material.Material;

public class BlockList {

public static final String REACTOR_CORE_NAME = "reactor_core";
public static final String REACTOR_CHAMBER_NAME = "reactor_chamber";
public static final String PRESSURE_VESSEL_NAME = "pressure_vessel";
Expand Down Expand Up @@ -54,16 +54,14 @@ public static void registerBlocks() {
FluidList.COOLANT,
Material.water,
NuclearHorizons.MODID + ":coolant_still",
NuclearHorizons.MODID + ":coolant_flow"
);
NuclearHorizons.MODID + ":coolant_flow");
COOLANT_BLOCK.setBlockName(COOLANT_BLOCK_NAME);

HOT_COOLANT_BLOCK = new FluidBlock(
FluidList.HOT_COOLANT,
Material.water,
NuclearHorizons.MODID + ":hot_coolant_still",
NuclearHorizons.MODID + ":hot_coolant_flow"
);
NuclearHorizons.MODID + ":hot_coolant_flow");
HOT_COOLANT_BLOCK.setBurnsEntities(true);
HOT_COOLANT_BLOCK.setBlockName(HOT_COOLANT_BLOCK_NAME);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.recursive_pineapple.nuclear_horizons.reactors.blocks;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
Expand All @@ -11,12 +9,15 @@
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class FluidBlock extends BlockFluidClassic {

public static final DamageSource HOT_FLUID_DAMAGE = new DamageSource("hot_fluid");

private String stillTextureName, flowingTextureName;

public IIcon stillIcon, flowingIcon;
private boolean burnsEntities = false;

Expand Down Expand Up @@ -46,7 +47,7 @@ public FluidBlock setBurnsEntities(boolean burnsEntities) {
@Override
public void onEntityCollidedWithBlock(World worldIn, int x, int y, int z, Entity entityIn) {
super.onEntityCollidedWithBlock(worldIn, x, y, z, entityIn);
if(burnsEntities && worldIn.getWorldTime() % 20 == 0) {
if (burnsEntities && worldIn.getWorldTime() % 20 == 0) {
entityIn.attackEntityFrom(HOT_FLUID_DAMAGE, 1.0f);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.block.material.Material;

public class PressureVessel extends Block {

public PressureVessel() {
super(Material.rock);
setBlockName(BlockList.PRESSURE_VESSEL_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.recursive_pineapple.nuclear_horizons.reactors.blocks;

import com.gtnewhorizons.modularui.api.UIInfos;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileAccessHatch;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import com.gtnewhorizons.modularui.api.UIInfos;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileAccessHatch;

public class ReactorAccessHatch extends BlockContainer {

public ReactorAccessHatch() {
super(Material.rock);
setBlockName(BlockList.REACTOR_ACCESS_HATCH_NAME);
Expand All @@ -21,18 +21,19 @@ public ReactorAccessHatch() {
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileAccessHatch();
}

@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
var reactor = ((TileAccessHatch)worldIn.getTileEntity(x, y, z)).getReactor();
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX,
float subY, float subZ) {
var reactor = ((TileAccessHatch) worldIn.getTileEntity(x, y, z)).getReactor();

if(!worldIn.isRemote) {
if(reactor != null) {
if (!worldIn.isRemote) {
if (reactor != null) {
UIInfos.TILE_MODULAR_UI.open(player, worldIn, reactor.xCoord, reactor.yCoord, reactor.zCoord);
}
}

if(reactor != null) {
if (reactor != null) {
return true;
} else {
return false;
Expand Down
Loading

0 comments on commit 7663b0d

Please sign in to comment.