Skip to content

Commit

Permalink
mostly working
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Jun 27, 2024
1 parent 6a6b089 commit 88b02a2
Show file tree
Hide file tree
Showing 46 changed files with 8,524 additions and 91 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ If you would like to help, send a me message on discord (my username is recursiv

# Issues
If you find an issue and would like to report it, you can either open an issue here or send me a message on discord.

# TODO
- Breeder rods
- Explosions & other overheat effects
- UI Polishing
- New textures
- Make vents state their total cooling capacity in sim results
- Test on MP
- Component automation configuration in the simulator
- A decent looking TESR thermal sensor for EU reactors (or hook into nuclear control somehow)
Binary file added assets/reactor_chamber_side.xcf
Binary file not shown.
Binary file added assets/reactor_chamber_top.xcf
Binary file not shown.
Binary file added assets/reactor_core_side.xcf
Binary file not shown.
Binary file added assets/reactor_core_side_active.xcf
Binary file not shown.
Binary file modified assets/thermal_sensor.xcf
Binary file not shown.
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dependencies {
runtimeOnlyNonPublishable("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:waila:1.8.0:dev")

implementation("com.google.protobuf:protobuf-java:3.25.3")

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")
Expand Down
6 changes: 6 additions & 0 deletions scripts/update_protos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd $(dirname $(realpath $0))/..

protoc --plugin=java --java_out=src/main/java/ $(find src -name "*.proto")

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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 com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationItems;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
Expand All @@ -24,8 +25,10 @@ public void preInit(FMLPreInitializationEvent event) {

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

SimulationItems.init();
}

// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

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;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationResult;

import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.NetworkRegistry;
Expand All @@ -20,16 +22,69 @@
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 void registerPackets() {
DISPATCHER.registerMessage(TileEntityUpdatedMessage::handle, TileEntityUpdatedMessage.class, packetId++, Side.CLIENT);
DISPATCHER.registerMessage(ReactorSimulationFinishedMessage::handle, ReactorSimulationFinishedMessage.class, packetId++, Side.SERVER);
}

public static class ReactorSimulationFinishedMessage implements IMessage {
public int dimensionId, x, y, z;

public SimulationResult result;

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

this.result = SimulationResult.read(buf);
}

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

SimulationResult.write(buf, result);
}

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

WorldServer dim = null;

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

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

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

return null;
}
}

public static class TileEntityUpdatedMessage implements IMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
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.TileReactorChamber;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileReactorCore;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileReactorSimulator;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileRedstonePort;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.TileThermalSensor;

Expand All @@ -22,6 +24,7 @@ public class BlockList {
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 REACTOR_SIMULATOR_NAME = "reactor_simulator";
public static final String COOLANT_BLOCK_NAME = "nh_coolant";
public static final String HOT_COOLANT_BLOCK_NAME = "nh_hot_coolant";

Expand All @@ -32,6 +35,7 @@ public class BlockList {
public static ReactorAccessHatch REACTOR_ACCESS_HATCH;
public static ReactorRedstonePort REACTOR_REDSTONE_PORT;
public static ReactorThermalSensor REACTOR_THERMAL_SENSOR;
public static ReactorSimulator REACTOR_SIMULATOR;

public static FluidBlock COOLANT_BLOCK;
public static FluidBlock HOT_COOLANT_BLOCK;
Expand All @@ -44,6 +48,7 @@ public static void registerBlocks() {
REACTOR_ACCESS_HATCH = new ReactorAccessHatch();
REACTOR_REDSTONE_PORT = new ReactorRedstonePort();
REACTOR_THERMAL_SENSOR = new ReactorThermalSensor();
REACTOR_SIMULATOR = new ReactorSimulator();

COOLANT_BLOCK = new FluidBlock(
FluidList.COOLANT,
Expand All @@ -59,12 +64,14 @@ public static void registerBlocks() {
NuclearHorizons.MODID + ":hot_coolant_still",
NuclearHorizons.MODID + ":hot_coolant_flow"
);
HOT_COOLANT_BLOCK.setBurnsEntities(true);
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);
registerTileEntity(TileReactorChamber.class, REACTOR_CHAMBER_NAME);

registerBlock(PRESSURE_VESSEL, PRESSURE_VESSEL_NAME);

Expand All @@ -80,6 +87,9 @@ public static void registerBlocks() {
registerBlock(REACTOR_THERMAL_SENSOR, REACTOR_THERMAL_SENSOR_NAME);
registerTileEntity(TileThermalSensor.class, REACTOR_THERMAL_SENSOR_NAME);

registerBlock(REACTOR_SIMULATOR, REACTOR_SIMULATOR_NAME);
registerTileEntity(TileReactorSimulator.class, REACTOR_SIMULATOR_NAME);

registerBlock(COOLANT_BLOCK, COOLANT_BLOCK_NAME);
registerBlock(HOT_COOLANT_BLOCK, HOT_COOLANT_BLOCK_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class FluidBlock extends BlockFluidFinite {
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;

public FluidBlock(Fluid fluid, Material material, String stillTextureName, String flowingTextureName) {
super(fluid, material);
Expand All @@ -31,4 +37,17 @@ public void registerBlockIcons(IIconRegister reg) {
stillIcon = reg.registerIcon(stillTextureName);
flowingIcon = reg.registerIcon(flowingTextureName);
}

public FluidBlock setBurnsEntities(boolean burnsEntities) {
this.burnsEntities = burnsEntities;
return this;
}

@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) {
entityIn.attackEntityFrom(HOT_FLUID_DAMAGE, 1.0f);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

public class ReactorChamber extends BlockContainer {

private IIcon iconTop, iconSide;

public ReactorChamber() {
super(Material.iron);

Expand All @@ -27,6 +31,21 @@ public ReactorChamber() {
setBlockTextureName("nuclear_horizons:reactor_chamber");
}

@Override
public void registerBlockIcons(IIconRegister reg) {
this.iconTop = reg.registerIcon("nuclear_horizons:reactor_chamber_top");
this.iconSide = reg.registerIcon("nuclear_horizons:reactor_chamber_side");
}

@Override
public IIcon getIcon(int side, int meta) {
if(side == 0 || side == 1) {
return iconTop;
} else {
return iconSide;
}
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileReactorChamber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class ReactorCore extends BlockContainer {

private IIcon iconTop, iconSide;
private IIcon iconTop, iconSideInactive, iconSideActive, iconBottom;

public ReactorCore() {
super(Material.iron);
Expand All @@ -25,13 +25,27 @@ public ReactorCore() {

@Override
public void registerBlockIcons(IIconRegister reg) {
this.iconTop = reg.registerIcon("nuclear_horizons:reactor_chamber");
this.iconSide = reg.registerIcon("nuclear_horizons:reactor_core");
this.iconTop = reg.registerIcon("nuclear_horizons:reactor_chamber_side");
this.iconBottom = reg.registerIcon("nuclear_horizons:reactor_chamber_top");
this.iconSideInactive = reg.registerIcon("nuclear_horizons:reactor_core_side");
this.iconSideActive = reg.registerIcon("nuclear_horizons:reactor_core_side_active");
}

@Override
public IIcon getIcon(int side, int meta) {
return iconTop;
if(side == 1) {
return iconTop;
}

if(side == 0) {
return iconBottom;
}

if(meta == 1) {
return iconSideActive;
} else {
return iconSideInactive;
}
}

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

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

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;

public class ReactorSimulator extends BlockContainer {
protected ReactorSimulator() {
super(Material.iron);

setBlockName(BlockList.REACTOR_SIMULATOR_NAME);
setStepSound(soundTypeMetal);
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileReactorSimulator();
}

@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
if(!worldIn.isRemote) {
UIInfos.TILE_MODULAR_UI.open(player, worldIn, x, y, z);
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.recursive_pineapple.nuclear_horizons.reactors.components;

import com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationResult;

import net.minecraft.item.ItemStack;

public interface IComponentAdapter {
Expand Down Expand Up @@ -46,4 +48,8 @@ public default int getReactorMaxHeatIncrease() {
public default double getExplosionRadiusMult() {
return 1.0;
}

public default void modifySimulationResults(SimulationResult result, int componentIndex) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void onHeatTick() {
}

if(fuelRod.getRemainingHealth(itemStack) <= 0) {
var product = fuelRod.getProduct(itemStack);
reactor.setItem(x, y, product != null ? product.copy() : null);
return;
}

Expand Down Expand Up @@ -83,7 +85,7 @@ public void onEnergyTick() {
return;
}

if(fuelRod.getRemainingHealth(itemStack) == 0) {
if(fuelRod.getRemainingHealth(itemStack) <= 0) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ public int getStoredHeat() {

@Override
public int addHeat(int delta) {
return this.heatContainer.addHeat(itemStack, delta);
}
int rejected = this.heatContainer.addHeat(itemStack, delta);

@Override
public void onHeatTick() {
if(this.heatContainer.getRemainingHealth(itemStack) <= 0 && this.heatContainer.isConsumable(itemStack)) {
this.reactor.setItem(x, y, null);
}

return rejected;
}
}
Loading

0 comments on commit 88b02a2

Please sign in to comment.