Added basic mod :)
This commit is contained in:
parent
6f4de388c1
commit
da25ed6add
18 changed files with 798 additions and 0 deletions
29
src/main/java/techreborn/Core.java
Normal file
29
src/main/java/techreborn/Core.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package techreborn;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import techreborn.blocks.BlockThermalGenerator;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
@Mod(modid = "techreborn", name = "TechReborn", version = "@MODVERSION@")
|
||||
public class Core {
|
||||
|
||||
public static Block thermalGenerator;
|
||||
|
||||
@Mod.Instance
|
||||
public static Core INSTANCE;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLPreInitializationEvent event){
|
||||
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other");
|
||||
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
|
||||
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
}
|
||||
|
||||
}
|
56
src/main/java/techreborn/blocks/BlockThermalGenerator.java
Normal file
56
src/main/java/techreborn/blocks/BlockThermalGenerator.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
|
||||
public class BlockThermalGenerator extends BlockContainer {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon top;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon other;
|
||||
|
||||
public BlockThermalGenerator() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister icon) {
|
||||
top = icon.registerIcon("techreborn:ThermalGenerator_top");
|
||||
other = icon.registerIcon("techreborn:ThermalGenerator_other");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int currentSide, int meta) {
|
||||
if (currentSide == 1) {
|
||||
return top;
|
||||
} else {
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileThermalGenerator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
29
src/main/java/techreborn/client/GuiHandler.java
Normal file
29
src/main/java/techreborn/client/GuiHandler.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package techreborn.client;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.client.gui.GuiThermalGenerator;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int thermalGeneratorID = 0;
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(ID == thermalGeneratorID){
|
||||
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(x, y, z), player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(ID == thermalGeneratorID){
|
||||
return new GuiThermalGenerator(player, (TileThermalGenerator)world.getTileEntity(x, y, z));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
37
src/main/java/techreborn/client/SlotFake.java
Normal file
37
src/main/java/techreborn/client/SlotFake.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package techreborn.client;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotFake extends Slot {
|
||||
|
||||
public boolean mCanInsertItem;
|
||||
public boolean mCanStackItem;
|
||||
public int mMaxStacksize = 127;
|
||||
|
||||
|
||||
public SlotFake(IInventory par1iInventory, int par2, int par3, int par4, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.mCanInsertItem = aCanInsertItem;
|
||||
this.mCanStackItem = aCanStackItem;
|
||||
this.mMaxStacksize = aMaxStacksize;
|
||||
}
|
||||
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return this.mCanInsertItem;
|
||||
}
|
||||
|
||||
public int getSlotStackLimit() {
|
||||
return this.mMaxStacksize;
|
||||
}
|
||||
|
||||
public boolean getHasStack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int par1) {
|
||||
return !this.mCanStackItem ? null : super.decrStackSize(par1);
|
||||
}
|
||||
}
|
16
src/main/java/techreborn/client/SlotOutput.java
Normal file
16
src/main/java/techreborn/client/SlotOutput.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package techreborn.client;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotOutput extends Slot {
|
||||
|
||||
public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
}
|
||||
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
public class ContainerThermalGenerator extends Container {
|
||||
public TileThermalGenerator tileThermalGenerator;
|
||||
public EntityPlayer player;
|
||||
|
||||
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) {
|
||||
super();
|
||||
this.tileThermalGenerator = tileThermalGenerator;
|
||||
this.player = player;
|
||||
|
||||
this.addSlotToContainer(new Slot(player.inventory, 40, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(player.inventory, 41, 80, 53));
|
||||
this.addSlotToContainer(new SlotFake(player.inventory, 42, 59, 42, false, false, 1));
|
||||
|
||||
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, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory , i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
35
src/main/java/techreborn/client/gui/GuiThermalGenerator.java
Normal file
35
src/main/java/techreborn/client/gui/GuiThermalGenerator.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
public class GuiThermalGenerator extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
|
||||
|
||||
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) {
|
||||
super(new ContainerThermalGenerator(tile, player));
|
||||
this.xSize = 176;
|
||||
this .ySize = 167;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l , 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
|
||||
this.fontRendererObj.drawString("0", 10, 30, 16448255);
|
||||
}
|
||||
}
|
39
src/main/java/techreborn/tiles/TileThermalGenerator.java
Normal file
39
src/main/java/techreborn/tiles/TileThermalGenerator.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import techreborn.Core;
|
||||
|
||||
public class TileThermalGenerator extends TileEntity implements IWrenchable {
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getFacing() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(short facing) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(Core.thermalGenerator, 1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue