Skip to content

Commit

Permalink
pre-energy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Jun 9, 2024
1 parent eb4e6f7 commit 5a87ead
Show file tree
Hide file tree
Showing 111 changed files with 4,206 additions and 4 deletions.
Binary file added assets/access_hatch.xcf
Binary file not shown.
Binary file added assets/access_hatch2.xcf
Binary file not shown.
Binary file added assets/coolant_flow.xcf
Binary file not shown.
Binary file added assets/coolant_still.xcf
Binary file not shown.
Binary file added assets/fluid_port.xcf
Binary file not shown.
Binary file added assets/hot_coolant_flow.xcf
Binary file not shown.
Binary file added assets/hot_coolant_still.xcf
Binary file not shown.
Binary file added assets/pressure_vessel.xcf
Binary file not shown.
Binary file added assets/reactor_chamber.xcf
Binary file not shown.
Binary file added assets/reactor_gui.xcf
Binary file not shown.
Binary file added assets/reactor_gui_decorations.xcf
Binary file not shown.
Binary file added assets/reactor_missing_chamber.xcf
Binary file not shown.
Binary file added assets/redstone_port.xcf
Binary file not shown.
Binary file added assets/thermal_sensor.xcf
Binary file not shown.
Binary file added assets/thorium_1x_rod.xcf
Binary file not shown.
7 changes: 7 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderIO:2.8.4:dev")
runtimeOnlyNonPublishable("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:waila:1.8.0:dev")

api("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.23:dev')
api("com.github.GTNewHorizons:ModularUI:1.2.0:dev")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package com.recursive_pineapple.nuclear_horizons;

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());
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
package com.recursive_pineapple.nuclear_horizons;

import com.recursive_pineapple.nuclear_horizons.networking.PacketDispatcher;
import com.recursive_pineapple.nuclear_horizons.reactors.blocks.BlockList;
import com.recursive_pineapple.nuclear_horizons.reactors.fluids.FluidList;
import com.recursive_pineapple.nuclear_horizons.reactors.items.ItemList;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;

public class CommonProxy {

// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
// GameRegistry." (Remove if not needed)
public void preInit(FMLPreInitializationEvent event) {
NuclearHorizons.LOG.info("Loading Nuclear Horizons version " + Tags.VERSION);

Config.synchronizeConfiguration(event.getSuggestedConfigurationFile());

NuclearHorizons.LOG.info("Loading Nuclear Horizons version " + Tags.VERSION);
FluidList.registerFluids();
BlockList.registerBlocks();
ItemList.registerItems();
}

// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
public void init(FMLInitializationEvent event) {}
public void init(FMLInitializationEvent event) {
// PacketDispatcher.registerPackets();
// PacketDispatcher.TileEntityUpdatedMessage.init();
}

// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
public void postInit(FMLPostInitializationEvent event) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

public class Config {

public static int ROD_EU_MULTIPLIER = 1;
public static double MOX_EU_COEFFICIENT = 4;

public static void synchronizeConfiguration(File configFile) {
Configuration configuration = new Configuration(configFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
Expand All @@ -25,6 +26,9 @@ public class NuclearHorizons {
serverSide = "com.recursive_pineapple.nuclear_horizons.CommonProxy")
public static CommonProxy proxy;

@Instance
public static NuclearHorizons instance = new NuclearHorizons();

@Mod.EventHandler
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
// GameRegistry." (Remove if not needed)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package com.recursive_pineapple.nuclear_horizons.networking;

import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

import com.recursive_pineapple.nuclear_horizons.NuclearHorizons;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.IUpdateableTileEntity;

import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
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.tileentity.TileEntity;
import net.minecraft.world.World;

public class PacketDispatcher {
private static byte packetId = 0;

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

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

public static class TileEntityUpdatedMessage implements IMessage {

public int dimensionId, x, y, z, tileEntityId;
public NBTTagCompound data;

private static Map<Integer, Class<? extends TileEntity>> idToClass;
private static Map<Class<? extends TileEntity>, Integer> classToId;

@SuppressWarnings("unchecked")
public static void init() {
Map<String, Class<? extends TileEntity>> nameToClass;

try {
Field field = TileEntity.class.getField("nameToClassMap");
field.setAccessible(true);
nameToClass = (Map<String, Class<? extends TileEntity>>) field.get(null);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
throw new RuntimeException(e);
}

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()))
.collect(Collectors.toList());

int nextId = 0;

for(var e : updateableTileEntities) {
idToClass.put(nextId, e.getValue());
classToId.put(e.getValue(), nextId);
nextId++;
}

NuclearHorizons.LOG.info("Found %d updateable tile entities", nextId);
}

public static @Nullable TileEntityUpdatedMessage fromUpdateableTileEntity(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);

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)
);

return null;
}

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

msg.dimensionId = world.provider.dimensionId;
msg.x = x;
msg.y = y;
msg.z = z;
msg.tileEntityId = classToId.get(te.getClass());
msg.data = ute.getNetworkUpdateData();

return msg;
} else {
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)
);

return null;
}
}

@Override
public void fromBytes(ByteBuf buf) {
this.dimensionId = buf.readInt();
this.x = buf.readInt();
this.y = buf.readInt();
this.z = buf.readInt();
this.tileEntityId = buf.readInt();

this.data = ByteBufUtils.readTag(buf);
}

@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(dimensionId);
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(tileEntityId);

ByteBufUtils.writeTag(buf, data);
}

public static IMessage handle(IMessage message, MessageContext ctx) {
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) {
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);

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,
msgTeClass.getName(),
te,
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,
msgTeClass.getName(),
msg.data.toString()
);
}
}

return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.recursive_pineapple.nuclear_horizons.reactors.blocks;

import static cpw.mods.fml.common.registry.GameRegistry.registerBlock;
import static cpw.mods.fml.common.registry.GameRegistry.registerTileEntity;

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;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileFluidPort;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileReactorCore;
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";
public static final String REACTOR_FLUID_PORT_NAME = "reactor_fluid_port";
public static final String REACTOR_ACCESS_HATCH_NAME = "reactor_access_hatch";
public static final String REACTOR_REDSTONE_PORT_NAME = "reactor_redstone_port";
public static final String REACTOR_THERMAL_SENSOR_NAME = "reactor_thermal_sensor";
public static final String COOLANT_BLOCK_NAME = "nh_coolant";
public static final String HOT_COOLANT_BLOCK_NAME = "nh_hot_coolant";

public static ReactorCore REACTOR_CORE;
public static ReactorChamber REACTOR_CHAMBER;
public static PressureVessel PRESSURE_VESSEL;
public static ReactorFluidPort REACTOR_FLUID_PORT;
public static ReactorAccessHatch REACTOR_ACCESS_HATCH;
public static ReactorRedstonePort REACTOR_REDSTONE_PORT;
public static ReactorThermalSensor REACTOR_THERMAL_SENSOR;

public static FluidBlock COOLANT_BLOCK;
public static FluidBlock HOT_COOLANT_BLOCK;

public static void registerBlocks() {
REACTOR_CORE = new ReactorCore();
REACTOR_CHAMBER = new ReactorChamber();
PRESSURE_VESSEL = new PressureVessel();
REACTOR_FLUID_PORT = new ReactorFluidPort();
REACTOR_ACCESS_HATCH = new ReactorAccessHatch();
REACTOR_REDSTONE_PORT = new ReactorRedstonePort();
REACTOR_THERMAL_SENSOR = new ReactorThermalSensor();

COOLANT_BLOCK = new FluidBlock(
FluidList.COOLANT,
Material.water,
NuclearHorizons.MODID + ":coolant_still",
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"
);
HOT_COOLANT_BLOCK.setBlockName(HOT_COOLANT_BLOCK_NAME);

registerBlock(REACTOR_CORE, REACTOR_CORE_NAME);
registerTileEntity(TileReactorCore.class, REACTOR_CORE_NAME);

registerBlock(REACTOR_CHAMBER, REACTOR_CHAMBER_NAME);

registerBlock(PRESSURE_VESSEL, PRESSURE_VESSEL_NAME);

registerBlock(REACTOR_FLUID_PORT, REACTOR_FLUID_PORT_NAME);
registerTileEntity(TileFluidPort.class, REACTOR_FLUID_PORT_NAME);

registerBlock(REACTOR_ACCESS_HATCH, REACTOR_ACCESS_HATCH_NAME);
registerTileEntity(TileAccessHatch.class, REACTOR_ACCESS_HATCH_NAME);

registerBlock(REACTOR_REDSTONE_PORT, REACTOR_REDSTONE_PORT_NAME);
registerTileEntity(TileRedstonePort.class, REACTOR_REDSTONE_PORT_NAME);

registerBlock(REACTOR_THERMAL_SENSOR, REACTOR_THERMAL_SENSOR_NAME);
registerTileEntity(TileThermalSensor.class, REACTOR_THERMAL_SENSOR_NAME);

registerBlock(COOLANT_BLOCK, COOLANT_BLOCK_NAME);
registerBlock(HOT_COOLANT_BLOCK, HOT_COOLANT_BLOCK_NAME);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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.util.IIcon;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;

public class FluidBlock extends BlockFluidFinite {

private String stillTextureName, flowingTextureName;

public IIcon stillIcon, flowingIcon;

public FluidBlock(Fluid fluid, Material material, String stillTextureName, String flowingTextureName) {
super(fluid, material);

this.stillTextureName = stillTextureName;
this.flowingTextureName = flowingTextureName;
}

@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side != 0 && side != 1 ? flowingIcon : stillIcon;
}

@Override
public void registerBlockIcons(IIconRegister reg) {
stillIcon = reg.registerIcon(stillTextureName);
flowingIcon = reg.registerIcon(flowingTextureName);
}
}
Loading

0 comments on commit 5a87ead

Please sign in to comment.