-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb4e6f7
commit 5a87ead
Showing
111 changed files
with
4,206 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/recursive_pineapple/nuclear_horizons/ClientProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |
18 changes: 14 additions & 4 deletions
18
src/main/java/com/recursive_pineapple/nuclear_horizons/CommonProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/main/java/com/recursive_pineapple/nuclear_horizons/networking/PacketDispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/com/recursive_pineapple/nuclear_horizons/reactors/blocks/BlockList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/recursive_pineapple/nuclear_horizons/reactors/blocks/FluidBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.