Started work on the farm, some changes to the idsu, its still broken
This commit is contained in:
parent
be33bdc148
commit
c160abf176
26 changed files with 626 additions and 194 deletions
|
@ -29,6 +29,7 @@ import techreborn.init.ModParts;
|
||||||
import techreborn.init.ModRecipes;
|
import techreborn.init.ModRecipes;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.packets.PacketHandler;
|
import techreborn.packets.PacketHandler;
|
||||||
|
import techreborn.packets.PacketPipeline;
|
||||||
import techreborn.proxies.CommonProxy;
|
import techreborn.proxies.CommonProxy;
|
||||||
import techreborn.tiles.idsu.IDSUManager;
|
import techreborn.tiles.idsu.IDSUManager;
|
||||||
import techreborn.util.LogHelper;
|
import techreborn.util.LogHelper;
|
||||||
|
@ -46,6 +47,8 @@ public class Core {
|
||||||
@Mod.Instance
|
@Mod.Instance
|
||||||
public static Core INSTANCE;
|
public static Core INSTANCE;
|
||||||
|
|
||||||
|
public static final PacketPipeline packetPipeline = new PacketPipeline();
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preinit(FMLPreInitializationEvent event){
|
public void preinit(FMLPreInitializationEvent event){
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
@ -97,7 +100,7 @@ public class Core {
|
||||||
IDSUManager.INSTANCE = new IDSUManager();
|
IDSUManager.INSTANCE = new IDSUManager();
|
||||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||||
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
|
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
|
||||||
|
packetPipeline.initalise();
|
||||||
LogHelper.info("Initialization Complete");
|
LogHelper.info("Initialization Complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +114,7 @@ public class Core {
|
||||||
for(ICompatModule compatModule : CompatManager.INSTANCE.compatModules){
|
for(ICompatModule compatModule : CompatManager.INSTANCE.compatModules){
|
||||||
compatModule.postInit(event);
|
compatModule.postInit(event);
|
||||||
}
|
}
|
||||||
|
packetPipeline.postInitialise();
|
||||||
LogHelper.info(RecipeHandler.recipeList.size() + " recipes loaded");
|
LogHelper.info(RecipeHandler.recipeList.size() + " recipes loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package techreborn.api.farm;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface IFarmLogicContainer {
|
||||||
|
|
||||||
|
public IFarmLogicDevice getLogicFromStack(ItemStack stack);
|
||||||
|
|
||||||
|
}
|
9
src/main/java/techreborn/api/farm/IFarmLogicDevice.java
Normal file
9
src/main/java/techreborn/api/farm/IFarmLogicDevice.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package techreborn.api.farm;
|
||||||
|
|
||||||
|
import techreborn.tiles.TileFarm;
|
||||||
|
|
||||||
|
public interface IFarmLogicDevice {
|
||||||
|
|
||||||
|
public void tick(TileFarm tileFarm);
|
||||||
|
|
||||||
|
}
|
5
src/main/java/techreborn/api/farm/package-info.java
Normal file
5
src/main/java/techreborn/api/farm/package-info.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||||
|
package techreborn.api.farm;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.API;
|
||||||
|
|
36
src/main/java/techreborn/blocks/BlockFarm.java
Normal file
36
src/main/java/techreborn/blocks/BlockFarm.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package techreborn.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import techreborn.Core;
|
||||||
|
import techreborn.client.GuiHandler;
|
||||||
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.tiles.TileFarm;
|
||||||
|
|
||||||
|
public class BlockFarm extends BlockMachineBase {
|
||||||
|
public BlockFarm() {
|
||||||
|
super(Material.iron);
|
||||||
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
setBlockName("techreborn.farm");
|
||||||
|
setHardness(2F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
|
return new TileFarm();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if(!player.isSneaking()){
|
||||||
|
player.openGui(Core.INSTANCE, GuiHandler.farmID, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
|
@ -66,7 +67,7 @@ public class BlockIDSU extends BlockMachineBase {
|
||||||
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||||
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(world, player), player);
|
Core.packetPipeline.sendTo(IDSUManager.INSTANCE.getPacket(world), (EntityPlayerMP) player);
|
||||||
}
|
}
|
||||||
if (!player.isSneaking())
|
if (!player.isSneaking())
|
||||||
player.openGui(Core.INSTANCE, GuiHandler.idsuID, world, x, y,
|
player.openGui(Core.INSTANCE, GuiHandler.idsuID, world, x, y,
|
||||||
|
|
|
@ -3,86 +3,10 @@ package techreborn.client;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.client.container.ContainerAesu;
|
import techreborn.client.container.*;
|
||||||
import techreborn.client.container.ContainerAlloyFurnace;
|
import techreborn.client.gui.*;
|
||||||
import techreborn.client.container.ContainerAlloySmelter;
|
|
||||||
import techreborn.client.container.ContainerAssemblingMachine;
|
|
||||||
import techreborn.client.container.ContainerBlastFurnace;
|
|
||||||
import techreborn.client.container.ContainerCentrifuge;
|
|
||||||
import techreborn.client.container.ContainerChargeBench;
|
|
||||||
import techreborn.client.container.ContainerChemicalReactor;
|
|
||||||
import techreborn.client.container.ContainerChunkloader;
|
|
||||||
import techreborn.client.container.ContainerDestructoPack;
|
|
||||||
import techreborn.client.container.ContainerDieselGenerator;
|
|
||||||
import techreborn.client.container.ContainerDigitalChest;
|
|
||||||
import techreborn.client.container.ContainerGasTurbine;
|
|
||||||
import techreborn.client.container.ContainerGrinder;
|
|
||||||
import techreborn.client.container.ContainerIDSU;
|
|
||||||
import techreborn.client.container.ContainerImplosionCompressor;
|
|
||||||
import techreborn.client.container.ContainerIndustrialElectrolyzer;
|
|
||||||
import techreborn.client.container.ContainerIndustrialSawmill;
|
|
||||||
import techreborn.client.container.ContainerLathe;
|
|
||||||
import techreborn.client.container.ContainerLesu;
|
|
||||||
import techreborn.client.container.ContainerMatterFabricator;
|
|
||||||
import techreborn.client.container.ContainerPda;
|
|
||||||
import techreborn.client.container.ContainerPlateCuttingMachine;
|
|
||||||
import techreborn.client.container.ContainerQuantumChest;
|
|
||||||
import techreborn.client.container.ContainerQuantumTank;
|
|
||||||
import techreborn.client.container.ContainerRollingMachine;
|
|
||||||
import techreborn.client.container.ContainerSemifluidGenerator;
|
|
||||||
import techreborn.client.container.ContainerThermalGenerator;
|
|
||||||
import techreborn.client.gui.GuiAesu;
|
|
||||||
import techreborn.client.gui.GuiAlloyFurnace;
|
|
||||||
import techreborn.client.gui.GuiAlloySmelter;
|
|
||||||
import techreborn.client.gui.GuiAssemblingMachine;
|
|
||||||
import techreborn.client.gui.GuiBlastFurnace;
|
|
||||||
import techreborn.client.gui.GuiCentrifuge;
|
|
||||||
import techreborn.client.gui.GuiChargeBench;
|
|
||||||
import techreborn.client.gui.GuiChemicalReactor;
|
|
||||||
import techreborn.client.gui.GuiChunkLoader;
|
|
||||||
import techreborn.client.gui.GuiDestructoPack;
|
|
||||||
import techreborn.client.gui.GuiDieselGenerator;
|
|
||||||
import techreborn.client.gui.GuiDigitalChest;
|
|
||||||
import techreborn.client.gui.GuiGasTurbine;
|
|
||||||
import techreborn.client.gui.GuiGrinder;
|
|
||||||
import techreborn.client.gui.GuiIDSU;
|
|
||||||
import techreborn.client.gui.GuiImplosionCompressor;
|
|
||||||
import techreborn.client.gui.GuiIndustrialElectrolyzer;
|
|
||||||
import techreborn.client.gui.GuiIndustrialSawmill;
|
|
||||||
import techreborn.client.gui.GuiLathe;
|
|
||||||
import techreborn.client.gui.GuiLesu;
|
|
||||||
import techreborn.client.gui.GuiMatterFabricator;
|
|
||||||
import techreborn.client.gui.GuiPlateCuttingMachine;
|
|
||||||
import techreborn.client.gui.GuiQuantumChest;
|
|
||||||
import techreborn.client.gui.GuiQuantumTank;
|
|
||||||
import techreborn.client.gui.GuiRollingMachine;
|
|
||||||
import techreborn.client.gui.GuiSemifluidGenerator;
|
|
||||||
import techreborn.client.gui.GuiThermalGenerator;
|
|
||||||
import techreborn.pda.GuiPda;
|
import techreborn.pda.GuiPda;
|
||||||
import techreborn.tiles.TileAesu;
|
import techreborn.tiles.*;
|
||||||
import techreborn.tiles.TileAlloyFurnace;
|
|
||||||
import techreborn.tiles.TileAlloySmelter;
|
|
||||||
import techreborn.tiles.TileAssemblingMachine;
|
|
||||||
import techreborn.tiles.TileBlastFurnace;
|
|
||||||
import techreborn.tiles.TileCentrifuge;
|
|
||||||
import techreborn.tiles.TileChargeBench;
|
|
||||||
import techreborn.tiles.TileChemicalReactor;
|
|
||||||
import techreborn.tiles.TileChunkLoader;
|
|
||||||
import techreborn.tiles.TileDieselGenerator;
|
|
||||||
import techreborn.tiles.TileDigitalChest;
|
|
||||||
import techreborn.tiles.TileGasTurbine;
|
|
||||||
import techreborn.tiles.TileGrinder;
|
|
||||||
import techreborn.tiles.TileImplosionCompressor;
|
|
||||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
|
||||||
import techreborn.tiles.TileIndustrialSawmill;
|
|
||||||
import techreborn.tiles.TileLathe;
|
|
||||||
import techreborn.tiles.TileMatterFabricator;
|
|
||||||
import techreborn.tiles.TilePlateCuttingMachine;
|
|
||||||
import techreborn.tiles.TileQuantumChest;
|
|
||||||
import techreborn.tiles.TileQuantumTank;
|
|
||||||
import techreborn.tiles.TileRollingMachine;
|
|
||||||
import techreborn.tiles.TileSemifluidGenerator;
|
|
||||||
import techreborn.tiles.TileThermalGenerator;
|
|
||||||
import techreborn.tiles.idsu.TileIDSU;
|
import techreborn.tiles.idsu.TileIDSU;
|
||||||
import techreborn.tiles.lesu.TileLesu;
|
import techreborn.tiles.lesu.TileLesu;
|
||||||
|
|
||||||
|
@ -116,6 +40,7 @@ public class GuiHandler implements IGuiHandler {
|
||||||
public static final int lesuID = 26;
|
public static final int lesuID = 26;
|
||||||
public static final int idsuID = 27;
|
public static final int idsuID = 27;
|
||||||
public static final int chargeBench = 28;
|
public static final int chargeBench = 28;
|
||||||
|
public static final int farmID = 29;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||||
|
@ -224,7 +149,9 @@ public class GuiHandler implements IGuiHandler {
|
||||||
return new ContainerIDSU((TileIDSU) world.getTileEntity(x, y, z), player);
|
return new ContainerIDSU((TileIDSU) world.getTileEntity(x, y, z), player);
|
||||||
} else if (ID == chargeBench) {
|
} else if (ID == chargeBench) {
|
||||||
return new ContainerChargeBench((TileChargeBench) world.getTileEntity(x, y, z), player);
|
return new ContainerChargeBench((TileChargeBench) world.getTileEntity(x, y, z), player);
|
||||||
}
|
} else if (ID == farmID){
|
||||||
|
return new ContainerFarm((TileFarm) world.getTileEntity(x,y,z), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -337,7 +264,9 @@ public class GuiHandler implements IGuiHandler {
|
||||||
return new GuiIDSU(player, (TileIDSU)world.getTileEntity(x, y, z));
|
return new GuiIDSU(player, (TileIDSU)world.getTileEntity(x, y, z));
|
||||||
} else if (ID == chargeBench) {
|
} else if (ID == chargeBench) {
|
||||||
return new GuiChargeBench(player, (TileChargeBench)world.getTileEntity(x, y, z));
|
return new GuiChargeBench(player, (TileChargeBench)world.getTileEntity(x, y, z));
|
||||||
}
|
} else if(ID == farmID){
|
||||||
|
return new GuiFarm(new ContainerFarm((TileFarm)world.getTileEntity(x, y, z), player));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
55
src/main/java/techreborn/client/container/ContainerFarm.java
Normal file
55
src/main/java/techreborn/client/container/ContainerFarm.java
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package techreborn.client.container;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import techreborn.tiles.TileFarm;
|
||||||
|
|
||||||
|
public class ContainerFarm extends TechRebornContainer {
|
||||||
|
|
||||||
|
TileFarm farm;
|
||||||
|
EntityPlayer player;
|
||||||
|
|
||||||
|
public ContainerFarm(TileFarm farm, EntityPlayer player) {
|
||||||
|
this.farm = farm;
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
|
|
||||||
|
this.addSlotToContainer(new Slot(farm.inventory, 0, 35, 7));
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
this.addSlotToContainer(new Slot(farm.inventory, 1 + i, 71 + (i * 18), 52));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int p = 5;
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
this.addSlotToContainer(new Slot(farm.inventory, p, 143 + (i * 18), 16 + (j * 18)));
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 9; ++j)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||||
|
+ 9, 8 + j * 18 + 27, 84 + i * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 9; ++i)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18 + 27,
|
||||||
|
142));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
38
src/main/java/techreborn/client/gui/GuiFarm.java
Normal file
38
src/main/java/techreborn/client/gui/GuiFarm.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package techreborn.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import techreborn.client.container.ContainerFarm;
|
||||||
|
|
||||||
|
public class GuiFarm extends GuiContainer {
|
||||||
|
|
||||||
|
private static final ResourceLocation texture = new ResourceLocation(
|
||||||
|
"techreborn", "textures/gui/farm.png");
|
||||||
|
|
||||||
|
ContainerFarm containerFarm;
|
||||||
|
|
||||||
|
public GuiFarm(ContainerFarm container) {
|
||||||
|
super(container);
|
||||||
|
this.xSize = 203;
|
||||||
|
this.ySize = 166;
|
||||||
|
container = (ContainerFarm) this.inventorySlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) {
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||||
|
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(int arg0, int arg1) {
|
||||||
|
String name = StatCollector.translateToLocal("tile.techreborn.farm.name");
|
||||||
|
fontRendererObj.drawString(name, xSize / 2 - fontRendererObj.getStringWidth(name) / 2 + 68, 5, 4210752);
|
||||||
|
this.fontRendererObj.drawString(I18n.format("container.inventory"), 60,
|
||||||
|
this.ySize - 96 + 2, 4210752);
|
||||||
|
super.drawGuiContainerForegroundLayer(arg0, arg1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
import techreborn.Core;
|
||||||
import techreborn.client.container.ContainerIDSU;
|
import techreborn.client.container.ContainerIDSU;
|
||||||
import techreborn.cofhLib.gui.GuiBase;
|
import techreborn.cofhLib.gui.GuiBase;
|
||||||
import techreborn.cofhLib.gui.element.ElementListBox;
|
import techreborn.cofhLib.gui.element.ElementListBox;
|
||||||
|
@ -78,8 +79,8 @@ public class GuiIDSU extends GuiBase {
|
||||||
protected void actionPerformed(GuiButton button) {
|
protected void actionPerformed(GuiButton button) {
|
||||||
super.actionPerformed(button);
|
super.actionPerformed(button);
|
||||||
if (isInteger(idFeild.getText())) {
|
if (isInteger(idFeild.getText())) {
|
||||||
PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText()));
|
Core.packetPipeline.sendToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText()));
|
||||||
} else {
|
} else {
|
||||||
LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs");
|
LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ package techreborn.command;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import techreborn.Core;
|
||||||
import techreborn.api.recipe.RecipeHandler;
|
import techreborn.api.recipe.RecipeHandler;
|
||||||
import techreborn.packets.PacketHandler;
|
import techreborn.packets.PacketHandler;
|
||||||
import techreborn.tiles.idsu.IDSUManager;
|
import techreborn.tiles.idsu.IDSUManager;
|
||||||
|
@ -36,7 +38,7 @@ public class TechRebornDevCommand extends CommandBase {
|
||||||
} else if ("recipes".equals(args[0])) {
|
} else if ("recipes".equals(args[0])) {
|
||||||
sender.addChatMessage(new ChatComponentText(RecipeHandler.recipeList.size() + " recipes loaded"));
|
sender.addChatMessage(new ChatComponentText(RecipeHandler.recipeList.size() + " recipes loaded"));
|
||||||
} else if ("idsu".equals(args[0])){
|
} else if ("idsu".equals(args[0])){
|
||||||
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(sender.getEntityWorld(), (EntityPlayer) sender), (EntityPlayer) sender);
|
Core.packetPipeline.sendTo(IDSUManager.INSTANCE.getPacket(sender.getEntityWorld()), (EntityPlayerMP) sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/main/java/techreborn/farm/FarmTree.java
Normal file
14
src/main/java/techreborn/farm/FarmTree.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package techreborn.farm;
|
||||||
|
|
||||||
|
import techreborn.api.farm.IFarmLogicDevice;
|
||||||
|
import techreborn.tiles.TileFarm;
|
||||||
|
|
||||||
|
public class FarmTree implements IFarmLogicDevice {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick(TileFarm tileFarm) {
|
||||||
|
System.out.println("tick");
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,23 +6,7 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import techreborn.blocks.BlockChunkLoader;
|
import techreborn.blocks.*;
|
||||||
import techreborn.blocks.BlockComputerCube;
|
|
||||||
import techreborn.blocks.BlockDigitalChest;
|
|
||||||
import techreborn.blocks.BlockElectricCraftingTable;
|
|
||||||
import techreborn.blocks.BlockFusionCoil;
|
|
||||||
import techreborn.blocks.BlockFusionControlComputer;
|
|
||||||
import techreborn.blocks.BlockHighlyAdvancedMachine;
|
|
||||||
import techreborn.blocks.BlockMachineCasing;
|
|
||||||
import techreborn.blocks.BlockMachineFrame;
|
|
||||||
import techreborn.blocks.BlockMetalShelf;
|
|
||||||
import techreborn.blocks.BlockOre;
|
|
||||||
import techreborn.blocks.BlockQuantumChest;
|
|
||||||
import techreborn.blocks.BlockQuantumTank;
|
|
||||||
import techreborn.blocks.BlockStorage;
|
|
||||||
import techreborn.blocks.BlockStorage2;
|
|
||||||
import techreborn.blocks.BlockSupercondensator;
|
|
||||||
import techreborn.blocks.BlockWoodenshelf;
|
|
||||||
import techreborn.blocks.generator.BlockDieselGenerator;
|
import techreborn.blocks.generator.BlockDieselGenerator;
|
||||||
import techreborn.blocks.generator.BlockDragonEggSiphoner;
|
import techreborn.blocks.generator.BlockDragonEggSiphoner;
|
||||||
import techreborn.blocks.generator.BlockGasTurbine;
|
import techreborn.blocks.generator.BlockGasTurbine;
|
||||||
|
@ -63,34 +47,7 @@ import techreborn.itemblocks.ItemBlockQuantumChest;
|
||||||
import techreborn.itemblocks.ItemBlockQuantumTank;
|
import techreborn.itemblocks.ItemBlockQuantumTank;
|
||||||
import techreborn.itemblocks.ItemBlockStorage;
|
import techreborn.itemblocks.ItemBlockStorage;
|
||||||
import techreborn.itemblocks.ItemBlockStorage2;
|
import techreborn.itemblocks.ItemBlockStorage2;
|
||||||
import techreborn.tiles.TileAesu;
|
import techreborn.tiles.*;
|
||||||
import techreborn.tiles.TileAlloyFurnace;
|
|
||||||
import techreborn.tiles.TileAlloySmelter;
|
|
||||||
import techreborn.tiles.TileAssemblingMachine;
|
|
||||||
import techreborn.tiles.TileBlastFurnace;
|
|
||||||
import techreborn.tiles.TileCentrifuge;
|
|
||||||
import techreborn.tiles.TileChargeBench;
|
|
||||||
import techreborn.tiles.TileChemicalReactor;
|
|
||||||
import techreborn.tiles.TileChunkLoader;
|
|
||||||
import techreborn.tiles.TileDieselGenerator;
|
|
||||||
import techreborn.tiles.TileDigitalChest;
|
|
||||||
import techreborn.tiles.TileDragonEggSiphoner;
|
|
||||||
import techreborn.tiles.TileGasTurbine;
|
|
||||||
import techreborn.tiles.TileGrinder;
|
|
||||||
import techreborn.tiles.TileHeatGenerator;
|
|
||||||
import techreborn.tiles.TileImplosionCompressor;
|
|
||||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
|
||||||
import techreborn.tiles.TileIndustrialSawmill;
|
|
||||||
import techreborn.tiles.TileLathe;
|
|
||||||
import techreborn.tiles.TileMachineCasing;
|
|
||||||
import techreborn.tiles.TileMatterFabricator;
|
|
||||||
import techreborn.tiles.TileMetalShelf;
|
|
||||||
import techreborn.tiles.TilePlateCuttingMachine;
|
|
||||||
import techreborn.tiles.TileQuantumChest;
|
|
||||||
import techreborn.tiles.TileQuantumTank;
|
|
||||||
import techreborn.tiles.TileRollingMachine;
|
|
||||||
import techreborn.tiles.TileSemifluidGenerator;
|
|
||||||
import techreborn.tiles.TileThermalGenerator;
|
|
||||||
import techreborn.tiles.idsu.TileIDSU;
|
import techreborn.tiles.idsu.TileIDSU;
|
||||||
import techreborn.tiles.lesu.TileLesu;
|
import techreborn.tiles.lesu.TileLesu;
|
||||||
import techreborn.tiles.lesu.TileLesuStorage;
|
import techreborn.tiles.lesu.TileLesuStorage;
|
||||||
|
@ -142,6 +99,7 @@ public class ModBlocks {
|
||||||
public static Block heatGenerator;
|
public static Block heatGenerator;
|
||||||
public static Block industrialSawmill;
|
public static Block industrialSawmill;
|
||||||
public static Block chargeBench;
|
public static Block chargeBench;
|
||||||
|
public static Block farm;
|
||||||
|
|
||||||
public static Block ore;
|
public static Block ore;
|
||||||
public static Block storage;
|
public static Block storage;
|
||||||
|
@ -323,10 +281,14 @@ public class ModBlocks {
|
||||||
|
|
||||||
machineframe = new BlockMachineFrame(Material.iron);
|
machineframe = new BlockMachineFrame(Material.iron);
|
||||||
GameRegistry.registerBlock(machineframe, ItemBlockMachineFrame.class, "techreborn.machineFrame");
|
GameRegistry.registerBlock(machineframe, ItemBlockMachineFrame.class, "techreborn.machineFrame");
|
||||||
LogHelper.info("TechReborns Blocks Loaded");
|
|
||||||
|
farm = new BlockFarm();
|
||||||
|
GameRegistry.registerBlock(farm, "techreborn.farm");
|
||||||
|
GameRegistry.registerTileEntity(TileFarm.class, "TileFarmTR");
|
||||||
|
|
||||||
|
|
||||||
registerOreDict();
|
registerOreDict();
|
||||||
|
LogHelper.info("TechReborns Blocks Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerOreDict(){
|
public static void registerOreDict(){
|
||||||
|
|
|
@ -10,21 +10,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import techreborn.items.ItemCells;
|
import techreborn.items.*;
|
||||||
import techreborn.items.ItemCrushedOre;
|
|
||||||
import techreborn.items.ItemDusts;
|
|
||||||
import techreborn.items.ItemDustsSmall;
|
|
||||||
import techreborn.items.ItemDustsTiny;
|
|
||||||
import techreborn.items.ItemGems;
|
|
||||||
import techreborn.items.ItemIngots;
|
|
||||||
import techreborn.items.ItemLapotronicOrb;
|
|
||||||
import techreborn.items.ItemNuggets;
|
|
||||||
import techreborn.items.ItemParts;
|
|
||||||
import techreborn.items.ItemPlates;
|
|
||||||
import techreborn.items.ItemPurifiedCrushedOre;
|
|
||||||
import techreborn.items.ItemRods;
|
|
||||||
import techreborn.items.ItemUUmatter;
|
|
||||||
import techreborn.items.ItemUpgrade;
|
|
||||||
import techreborn.items.armor.ItemLapotronPack;
|
import techreborn.items.armor.ItemLapotronPack;
|
||||||
import techreborn.items.armor.ItemLithiumBatpack;
|
import techreborn.items.armor.ItemLithiumBatpack;
|
||||||
import techreborn.items.tools.ItemAdvancedDrill;
|
import techreborn.items.tools.ItemAdvancedDrill;
|
||||||
|
@ -86,7 +72,7 @@ public class ModItems {
|
||||||
public static Item hammerIron;
|
public static Item hammerIron;
|
||||||
public static Item hammerDiamond;
|
public static Item hammerDiamond;
|
||||||
public static Item upgrades;
|
public static Item upgrades;
|
||||||
|
public static Item farmPatten;
|
||||||
|
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
|
@ -142,6 +128,9 @@ public class ModItems {
|
||||||
hammerDiamond = new ItemHammer(200);
|
hammerDiamond = new ItemHammer(200);
|
||||||
hammerDiamond.setUnlocalizedName("hammerDiamond").setContainerItem(hammerDiamond);
|
hammerDiamond.setUnlocalizedName("hammerDiamond").setContainerItem(hammerDiamond);
|
||||||
GameRegistry.registerItem(hammerDiamond, "hammerDiamond");
|
GameRegistry.registerItem(hammerDiamond, "hammerDiamond");
|
||||||
|
|
||||||
|
farmPatten = new ItemFarmPatten();
|
||||||
|
GameRegistry.registerItem(farmPatten, "farmPatten");
|
||||||
|
|
||||||
// buckets
|
// buckets
|
||||||
bucketBerylium = new ItemFluidbucket(ModFluids.BlockFluidBerylium);
|
bucketBerylium = new ItemFluidbucket(ModFluids.BlockFluidBerylium);
|
||||||
|
|
22
src/main/java/techreborn/items/ItemFarmPatten.java
Normal file
22
src/main/java/techreborn/items/ItemFarmPatten.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package techreborn.items;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import techreborn.api.farm.IFarmLogicContainer;
|
||||||
|
import techreborn.api.farm.IFarmLogicDevice;
|
||||||
|
import techreborn.client.TechRebornCreativeTabMisc;
|
||||||
|
import techreborn.farm.FarmTree;
|
||||||
|
|
||||||
|
public class ItemFarmPatten extends Item implements IFarmLogicContainer {
|
||||||
|
|
||||||
|
|
||||||
|
public ItemFarmPatten() {
|
||||||
|
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||||
|
setUnlocalizedName("techreborn.farmPatten");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFarmLogicDevice getLogicFromStack(ItemStack stack) {
|
||||||
|
return new FarmTree();
|
||||||
|
}
|
||||||
|
}
|
50
src/main/java/techreborn/packets/AbstractPacket.java
Normal file
50
src/main/java/techreborn/packets/AbstractPacket.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package techreborn.packets;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbstractPacket class. Should be the parent of all packets wishing to use the
|
||||||
|
* PacketPipeline.
|
||||||
|
*
|
||||||
|
* @author sirgingalot
|
||||||
|
*/
|
||||||
|
public abstract class AbstractPacket {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode the packet data into the ByteBuf stream. Complex data sets may
|
||||||
|
* need specific data handlers (See
|
||||||
|
*
|
||||||
|
* @param ctx channel context
|
||||||
|
* @param buffer the buffer to encode into
|
||||||
|
* @link{cpw.mods.fml.common.network.ByteBuffUtils )
|
||||||
|
*/
|
||||||
|
public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the packet data from the ByteBuf stream. Complex data sets may
|
||||||
|
* need specific data handlers (See
|
||||||
|
*
|
||||||
|
* @param ctx channel context
|
||||||
|
* @param buffer the buffer to decode from
|
||||||
|
* @link{cpw.mods.fml.common.network.ByteBuffUtils )
|
||||||
|
*/
|
||||||
|
public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a packet on the client side. Note this occurs after decoding has
|
||||||
|
* completed.
|
||||||
|
*
|
||||||
|
* @param player the player reference
|
||||||
|
*/
|
||||||
|
public abstract void handleClientSide(EntityPlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a packet on the powerSink side. Note this occurs after decoding has
|
||||||
|
* completed.
|
||||||
|
*
|
||||||
|
* @param player the player reference
|
||||||
|
*/
|
||||||
|
public abstract void handleServerSide(EntityPlayer player);
|
||||||
|
}
|
|
@ -21,8 +21,6 @@ public class PacketHandler extends
|
||||||
|
|
||||||
public PacketHandler() {
|
public PacketHandler() {
|
||||||
addDiscriminator(0, PacketAesu.class);
|
addDiscriminator(0, PacketAesu.class);
|
||||||
addDiscriminator(1, PacketIdsu.class);
|
|
||||||
addDiscriminator(2, PacketSendIDSUManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumMap<Side, FMLEmbeddedChannel> getChannels()
|
public static EnumMap<Side, FMLEmbeddedChannel> getChannels()
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
package techreborn.packets;
|
package techreborn.packets;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import techreborn.tiles.idsu.TileIDSU;
|
import techreborn.tiles.idsu.TileIDSU;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
public class PacketIdsu extends AbstractPacket {
|
||||||
* Created by mark on 17/06/15.
|
|
||||||
*/
|
|
||||||
public class PacketIdsu extends SimplePacket {
|
|
||||||
|
|
||||||
|
|
||||||
public PacketIdsu() {
|
public PacketIdsu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +18,8 @@ public class PacketIdsu extends SimplePacket {
|
||||||
|
|
||||||
TileIDSU idsu;
|
TileIDSU idsu;
|
||||||
|
|
||||||
|
int x, y, z;
|
||||||
|
|
||||||
public PacketIdsu(int buttonID, TileIDSU idsu, int channel, String newName) {
|
public PacketIdsu(int buttonID, TileIDSU idsu, int channel, String newName) {
|
||||||
this.idsu = idsu;
|
this.idsu = idsu;
|
||||||
this.buttonID = buttonID;
|
this.buttonID = buttonID;
|
||||||
|
@ -28,28 +27,45 @@ public class PacketIdsu extends SimplePacket {
|
||||||
this.newName = newName;
|
this.newName = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeData(ByteBuf out) throws IOException {
|
|
||||||
SimplePacket.writeTileEntity(idsu, out);
|
|
||||||
out.writeInt(buttonID);
|
|
||||||
out.writeInt(channel);
|
|
||||||
PacketBuffer buffer = new PacketBuffer(out);
|
|
||||||
buffer.writeStringToBuffer(newName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readData(ByteBuf in) throws IOException {
|
public void encodeInto(ChannelHandlerContext ctx, ByteBuf out) {
|
||||||
this.idsu = (TileIDSU) SimplePacket.readTileEntity(in);
|
out.writeInt(idsu.xCoord);
|
||||||
buttonID = in.readInt();
|
out.writeInt(idsu.yCoord);
|
||||||
channel = in.readInt();
|
out.writeInt(idsu.zCoord);
|
||||||
PacketBuffer buffer = new PacketBuffer(in);
|
out.writeInt(buttonID);
|
||||||
newName = buffer.readStringFromBuffer(9);
|
out.writeInt(channel);
|
||||||
}
|
PacketBuffer buffer = new PacketBuffer(out);
|
||||||
|
try {
|
||||||
|
buffer.writeStringToBuffer(newName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void decodeInto(ChannelHandlerContext ctx, ByteBuf in) {
|
||||||
if(!idsu.getWorldObj().isRemote){
|
this.x = in.readInt();
|
||||||
idsu.handleGuiInputFromClient(buttonID, channel, player, newName);
|
this.y = in.readInt();
|
||||||
}
|
this.z = in.readInt();
|
||||||
}
|
buttonID = in.readInt();
|
||||||
|
channel = in.readInt();
|
||||||
|
PacketBuffer buffer = new PacketBuffer(in);
|
||||||
|
try {
|
||||||
|
newName = buffer.readStringFromBuffer(9999999);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClientSide(EntityPlayer player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleServerSide(EntityPlayer player) {
|
||||||
|
idsu = (TileIDSU) player.getEntityWorld().getTileEntity(x, y, z);
|
||||||
|
idsu.handleGuiInputFromClient(buttonID, channel, player, newName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
229
src/main/java/techreborn/packets/PacketPipeline.java
Normal file
229
src/main/java/techreborn/packets/PacketPipeline.java
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
package techreborn.packets;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.handler.codec.MessageToMessageCodec;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.network.INetHandler;
|
||||||
|
import net.minecraft.network.NetHandlerPlayServer;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||||
|
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||||
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
|
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Packet pipeline class. Directs all registered packet data to be handled by
|
||||||
|
* the packets themselves.
|
||||||
|
*
|
||||||
|
* @author sirgingalot some code from: cpw
|
||||||
|
*/
|
||||||
|
@ChannelHandler.Sharable
|
||||||
|
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket> {
|
||||||
|
|
||||||
|
private EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||||
|
private LinkedList<Class<? extends AbstractPacket>> packets = new LinkedList<Class<? extends AbstractPacket>>();
|
||||||
|
private boolean isPostInitialised = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register your packet with the pipeline. Discriminators are automatically
|
||||||
|
* set.
|
||||||
|
*
|
||||||
|
* @param clazz the class to register
|
||||||
|
* @return whether registration was successful. Failure may occur if 256
|
||||||
|
* packets have been registered or if the registry already contains
|
||||||
|
* this packet
|
||||||
|
*/
|
||||||
|
public boolean registerPacket(Class<? extends AbstractPacket> clazz) {
|
||||||
|
if (this.packets.size() > 256) {
|
||||||
|
// You should log here!!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.packets.contains(clazz)) {
|
||||||
|
// You should log here!!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isPostInitialised) {
|
||||||
|
// You should log here!!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.packets.add(clazz);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In line encoding of the packet, including discriminator setting
|
||||||
|
@Override
|
||||||
|
protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception {
|
||||||
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
|
Class<? extends AbstractPacket> clazz = msg.getClass();
|
||||||
|
if (!this.packets.contains(msg.getClass())) {
|
||||||
|
throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
byte discriminator = (byte) this.packets.indexOf(clazz);
|
||||||
|
buffer.writeByte(discriminator);
|
||||||
|
msg.encodeInto(ctx, buffer);
|
||||||
|
FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
|
||||||
|
out.add(proxyPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
// In line decoding and handling of the packet
|
||||||
|
@Override
|
||||||
|
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
|
||||||
|
ByteBuf payload = msg.payload();
|
||||||
|
byte discriminator = payload.readByte();
|
||||||
|
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
|
||||||
|
if (clazz == null) {
|
||||||
|
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPacket pkt = clazz.newInstance();
|
||||||
|
pkt.decodeInto(ctx, payload.slice());
|
||||||
|
|
||||||
|
EntityPlayer player;
|
||||||
|
switch (FMLCommonHandler.instance().getEffectiveSide()) {
|
||||||
|
case CLIENT:
|
||||||
|
player = this.getClientPlayer();
|
||||||
|
pkt.handleClientSide(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SERVER:
|
||||||
|
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||||
|
player = ((NetHandlerPlayServer) netHandler).playerEntity;
|
||||||
|
pkt.handleServerSide(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
out.add(pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to call from FMLInitializationEvent
|
||||||
|
public void initalise() {
|
||||||
|
this.channels = NetworkRegistry.INSTANCE.newChannel("TechRebornPackPipeLine", this);
|
||||||
|
registerPackets();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerPackets() {
|
||||||
|
registerPacket(PacketIdsu.class);
|
||||||
|
registerPacket(PacketSendIDSUManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to call from FMLPostInitializationEvent
|
||||||
|
// Ensures that packet discriminators are common between powerSink and client
|
||||||
|
// by using logical sorting
|
||||||
|
public void postInitialise() {
|
||||||
|
if (this.isPostInitialised) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isPostInitialised = true;
|
||||||
|
Collections.sort(this.packets, new Comparator<Class<? extends AbstractPacket>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Class<? extends AbstractPacket> clazz1, Class<? extends AbstractPacket> clazz2) {
|
||||||
|
int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName());
|
||||||
|
if (com == 0) {
|
||||||
|
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return com;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private EntityPlayer getClientPlayer() {
|
||||||
|
return Minecraft.getMinecraft().thePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this message to everyone.
|
||||||
|
* <p/>
|
||||||
|
* Adapted from CPW's code in
|
||||||
|
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||||
|
*
|
||||||
|
* @param message The message to send
|
||||||
|
*/
|
||||||
|
public void sendToAll(AbstractPacket message) {
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||||
|
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this message to the specified player.
|
||||||
|
* <p/>
|
||||||
|
* Adapted from CPW's code in
|
||||||
|
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||||
|
*
|
||||||
|
* @param message The message to send
|
||||||
|
* @param player The player to send it to
|
||||||
|
*/
|
||||||
|
public void sendTo(AbstractPacket message, EntityPlayerMP player) {
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
|
||||||
|
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this message to everyone within a certain range of a point.
|
||||||
|
* <p/>
|
||||||
|
* Adapted from CPW's code in
|
||||||
|
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||||
|
*
|
||||||
|
* @param message The message to send
|
||||||
|
* @param point The
|
||||||
|
* {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
|
||||||
|
* around which to send
|
||||||
|
*/
|
||||||
|
public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) {
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
|
||||||
|
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this message to everyone within the supplied dimension.
|
||||||
|
* <p/>
|
||||||
|
* Adapted from CPW's code in
|
||||||
|
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||||
|
*
|
||||||
|
* @param message The message to send
|
||||||
|
* @param dimensionId The dimension id to target
|
||||||
|
*/
|
||||||
|
public void sendToDimension(AbstractPacket message, int dimensionId) {
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
||||||
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
|
||||||
|
this.channels.get(Side.SERVER).writeAndFlush(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send this message to the powerSink.
|
||||||
|
* <p/>
|
||||||
|
* Adapted from CPW's code in
|
||||||
|
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
|
||||||
|
*
|
||||||
|
* @param message The message to send
|
||||||
|
*/
|
||||||
|
public void sendToServer(AbstractPacket message) {
|
||||||
|
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
||||||
|
this.channels.get(Side.CLIENT).writeAndFlush(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package techreborn.packets;
|
package techreborn.packets;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -11,34 +12,39 @@ import techreborn.tiles.idsu.IDSUManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketSendIDSUManager extends SimplePacket {
|
public class PacketSendIDSUManager extends AbstractPacket {
|
||||||
|
|
||||||
String json;
|
String json;
|
||||||
|
|
||||||
public PacketSendIDSUManager() {
|
public PacketSendIDSUManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketSendIDSUManager(String json, EntityPlayer player) {
|
public PacketSendIDSUManager(String json) {
|
||||||
this.json = json;
|
this.json = json;
|
||||||
this.player = player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeData(ByteBuf out) throws IOException {
|
public void encodeInto(ChannelHandlerContext ctx, ByteBuf out) {
|
||||||
PacketBuffer buffer = new PacketBuffer(out);
|
PacketBuffer buffer = new PacketBuffer(out);
|
||||||
buffer.writeStringToBuffer(json);
|
try {
|
||||||
writePlayer(player, out);
|
buffer.writeStringToBuffer(json);
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readData(ByteBuf in) throws IOException {
|
public void decodeInto(ChannelHandlerContext ctx, ByteBuf in) {
|
||||||
PacketBuffer buffer = new PacketBuffer(in);
|
PacketBuffer buffer = new PacketBuffer(in);
|
||||||
json = buffer.readStringFromBuffer(Integer.MAX_VALUE / 4);
|
try {
|
||||||
player = readPlayer(in);
|
json = buffer.readStringFromBuffer(9999999);
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void handleClientSide(EntityPlayer player) {
|
||||||
ClientSideIDSUManager.CLIENT.loadFromString(json, player.worldObj);
|
ClientSideIDSUManager.CLIENT.loadFromString(json, player.worldObj);
|
||||||
|
|
||||||
if(player.worldObj != null){
|
if(player.worldObj != null){
|
||||||
|
@ -57,4 +63,9 @@ public class PacketSendIDSUManager extends SimplePacket {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleServerSide(EntityPlayer player) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
45
src/main/java/techreborn/tiles/TileFarm.java
Normal file
45
src/main/java/techreborn/tiles/TileFarm.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package techreborn.tiles;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import techreborn.api.farm.IFarmLogicContainer;
|
||||||
|
import techreborn.api.farm.IFarmLogicDevice;
|
||||||
|
import techreborn.farm.FarmTree;
|
||||||
|
import techreborn.util.Inventory;
|
||||||
|
|
||||||
|
public class TileFarm extends TileMachineBase {
|
||||||
|
|
||||||
|
public Inventory inventory= new Inventory(14, "TileFarm", 64);
|
||||||
|
|
||||||
|
IFarmLogicDevice logicDevice;
|
||||||
|
|
||||||
|
public TileFarm() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
|
inventory.readFromNBT(tagCompound);
|
||||||
|
super.readFromNBT(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||||
|
inventory.writeToNBT(tagCompound);
|
||||||
|
super.writeToNBT(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
if(inventory.hasChanged){
|
||||||
|
if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){
|
||||||
|
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
|
||||||
|
logicDevice = device.getLogicFromStack(inventory.getStackInSlot(0));
|
||||||
|
} else {
|
||||||
|
logicDevice = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(logicDevice != null){
|
||||||
|
logicDevice.tick(this);
|
||||||
|
}
|
||||||
|
super.updateEntity();
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,13 +85,13 @@ public class IDSUManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketSendIDSUManager getPacket(World world, EntityPlayer player) {
|
public PacketSendIDSUManager getPacket(World world) {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(getWorldDataFormWorld(world).idsuValues);
|
String json = gson.toJson(getWorldDataFormWorld(world).idsuValues);
|
||||||
if (getWorldDataFormWorld(world).idsuValues.isEmpty()) {
|
if (getWorldDataFormWorld(world).idsuValues.isEmpty()) {
|
||||||
json = "EMPTY";
|
json = "EMPTY";
|
||||||
}
|
}
|
||||||
return new PacketSendIDSUManager(json, player);
|
return new PacketSendIDSUManager(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromString(String json, World world) {
|
public void loadFromString(String json, World world) {
|
||||||
|
|
|
@ -9,12 +9,14 @@ import ic2.api.tile.IEnergyStorage;
|
||||||
import ic2.core.IC2;
|
import ic2.core.IC2;
|
||||||
import ic2.core.block.TileEntityBlock;
|
import ic2.core.block.TileEntityBlock;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import techreborn.Core;
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.packets.PacketHandler;
|
import techreborn.packets.PacketHandler;
|
||||||
|
@ -29,8 +31,8 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name;
|
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name;
|
||||||
IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save();
|
IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save();
|
||||||
if (worldObj.isRemote) {
|
if (worldObj.isRemote) {
|
||||||
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(worldObj, player), player);
|
Core.packetPipeline.sendTo(IDSUManager.INSTANCE.getPacket(worldObj), (EntityPlayerMP) player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +63,10 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
this.maxStorage = maxStorage1;
|
this.maxStorage = maxStorage1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TileIDSU(){
|
||||||
|
this(5, 2048, 100000000);
|
||||||
|
}
|
||||||
|
|
||||||
public float getChargeLevel() {
|
public float getChargeLevel() {
|
||||||
float ret = (float) this.getEnergy() / (float) this.maxStorage;
|
float ret = (float) this.getEnergy() / (float) this.maxStorage;
|
||||||
if (ret > 1.0F) {
|
if (ret > 1.0F) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ tile.techreborn.storage2.sapphire.name=Block of Sapphire
|
||||||
tile.techreborn.storage2.peridot.name=Block of Peridot
|
tile.techreborn.storage2.peridot.name=Block of Peridot
|
||||||
tile.techreborn.storage2.yellow_garnet.name=Block of Yellow Garnet
|
tile.techreborn.storage2.yellow_garnet.name=Block of Yellow Garnet
|
||||||
tile.techreborn.storage2.red_garnet.name=Block of Red Garnet
|
tile.techreborn.storage2.red_garnet.name=Block of Red Garnet
|
||||||
|
tile.techreborn.farm.name=Farm
|
||||||
|
|
||||||
|
|
||||||
#Fluids
|
#Fluids
|
||||||
|
|
BIN
src/main/resources/assets/techreborn/textures/gui/farm.png
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/farm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
src/main/resources/assets/techreborn/textures/gui/farm.psd
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/farm.psd
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue