mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Added XP Solidifier
This commit is contained in:
parent
970bfea08c
commit
51c25af85c
9 changed files with 416 additions and 11 deletions
|
@ -0,0 +1,141 @@
|
||||||
|
package ellpeck.actuallyadditions.blocks;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||||
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityXPSolidifier;
|
||||||
|
import ellpeck.actuallyadditions.util.BlockUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.INameableItem;
|
||||||
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.EnumRarity;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BlockXPSolidifier extends BlockContainerBase implements INameableItem{
|
||||||
|
|
||||||
|
private IIcon topIcon;
|
||||||
|
private IIcon onIcon;
|
||||||
|
private IIcon frontIcon;
|
||||||
|
|
||||||
|
public BlockXPSolidifier(){
|
||||||
|
super(Material.rock);
|
||||||
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
this.setHardness(1.5F);
|
||||||
|
this.setResistance(10.0F);
|
||||||
|
this.setStepSound(soundTypeStone);
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
||||||
|
int rotation = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||||
|
|
||||||
|
if (rotation == 0) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||||
|
if (rotation == 1) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||||
|
if (rotation == 2) world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||||
|
if (rotation == 3) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int par2){
|
||||||
|
return new TileEntityXPSolidifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightValue(IBlockAccess world, int x, int y, int z){
|
||||||
|
return world.getBlockMetadata(x, y, z) > 3 ? 12 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(int side, int meta){
|
||||||
|
if(side == 1) return this.topIcon;
|
||||||
|
if(side == 3) return this.frontIcon;
|
||||||
|
return this.blockIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
if(side == 1) return this.topIcon;
|
||||||
|
if(side == meta+2 && meta <= 3) return this.frontIcon;
|
||||||
|
else if(side == meta-2 && meta > 3) return this.onIcon;
|
||||||
|
return this.blockIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister iconReg){
|
||||||
|
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
|
||||||
|
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top");
|
||||||
|
this.onIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "On");
|
||||||
|
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Front");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||||
|
if(!world.isRemote){
|
||||||
|
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)world.getTileEntity(x, y, z);
|
||||||
|
if (solidifier != null) player.openGui(ActuallyAdditions.instance, GuiHandler.XP_SOLIDIFIER_ID, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
||||||
|
this.dropInventory(world, x, y, z);
|
||||||
|
super.breakBlock(world, x, y, z, block, par6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(){
|
||||||
|
return "blockXPSolidifier";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TheItemBlock extends ItemBlock{
|
||||||
|
|
||||||
|
private Block theBlock;
|
||||||
|
|
||||||
|
public TheItemBlock(Block block){
|
||||||
|
super(block);
|
||||||
|
this.theBlock = block;
|
||||||
|
this.setHasSubtypes(false);
|
||||||
|
this.setMaxDamage(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumRarity getRarity(ItemStack stack){
|
||||||
|
return EnumRarity.epic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack stack){
|
||||||
|
return this.getUnlocalizedName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||||
|
BlockUtil.addInformation(theBlock, list, 1, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetadata(int damage){
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,9 +80,14 @@ public class InitBlocks{
|
||||||
|
|
||||||
public static Block blockTreasureChest;
|
public static Block blockTreasureChest;
|
||||||
|
|
||||||
|
public static Block blockXPSolidifier;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||||
|
|
||||||
|
blockXPSolidifier = new BlockXPSolidifier();
|
||||||
|
BlockUtil.register(blockXPSolidifier, BlockXPSolidifier.TheItemBlock.class);
|
||||||
|
|
||||||
blockTestifiBucksGreenWall = new BlockGeneric("blockTestifiBucksGreenWall");
|
blockTestifiBucksGreenWall = new BlockGeneric("blockTestifiBucksGreenWall");
|
||||||
BlockUtil.register(blockTestifiBucksGreenWall, BlockGeneric.TheItemBlock.class);
|
BlockUtil.register(blockTestifiBucksGreenWall, BlockGeneric.TheItemBlock.class);
|
||||||
blockTestifiBucksWhiteWall = new BlockGeneric("blockTestifiBucksWhiteWall");
|
blockTestifiBucksWhiteWall = new BlockGeneric("blockTestifiBucksWhiteWall");
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package ellpeck.actuallyadditions.inventory;
|
||||||
|
|
||||||
|
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityXPSolidifier;
|
||||||
|
import invtweaks.api.container.InventoryContainer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
@InventoryContainer
|
||||||
|
public class ContainerXPSolidifier extends Container{
|
||||||
|
|
||||||
|
private TileEntityXPSolidifier solidifier;
|
||||||
|
|
||||||
|
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
|
this.solidifier = (TileEntityXPSolidifier)tile;
|
||||||
|
|
||||||
|
for(int i = 0; i < 2; i++){
|
||||||
|
for(int j = 0; j < 3; j++){
|
||||||
|
this.addSlotToContainer(new SlotOutput(solidifier, j+i*3, 62+j*18, 8+i*18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++){
|
||||||
|
for(int j = 0; j < 9; j++){
|
||||||
|
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 9; i++){
|
||||||
|
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer player){
|
||||||
|
return this.solidifier.isUseableByPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
|
final int inventoryStart = 6;
|
||||||
|
final int inventoryEnd = inventoryStart+26;
|
||||||
|
final int hotbarStart = inventoryEnd+1;
|
||||||
|
final int hotbarEnd = hotbarStart+8;
|
||||||
|
|
||||||
|
Slot theSlot = (Slot)this.inventorySlots.get(slot);
|
||||||
|
if(theSlot.getHasStack()){
|
||||||
|
ItemStack currentStack = theSlot.getStack();
|
||||||
|
ItemStack newStack = currentStack.copy();
|
||||||
|
|
||||||
|
if(currentStack.getItem() != null){
|
||||||
|
if(slot <= hotbarEnd && slot >= hotbarStart){
|
||||||
|
this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(slot <= inventoryEnd && slot >= inventoryStart){
|
||||||
|
this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(slot < inventoryStart){
|
||||||
|
this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newStack.stackSize == 0) theSlot.putStack(null);
|
||||||
|
else theSlot.onSlotChanged();
|
||||||
|
if(newStack.stackSize == currentStack.stackSize) return null;
|
||||||
|
theSlot.onPickupFromSlot(player, newStack);
|
||||||
|
|
||||||
|
return currentStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,8 @@ public class GuiHandler implements IGuiHandler{
|
||||||
return new ContainerEnergizer(entityPlayer, tile);
|
return new ContainerEnergizer(entityPlayer, tile);
|
||||||
case ENERVATOR_ID:
|
case ENERVATOR_ID:
|
||||||
return new ContainerEnervator(entityPlayer, tile);
|
return new ContainerEnervator(entityPlayer, tile);
|
||||||
|
case XP_SOLIDIFIER_ID:
|
||||||
|
return new ContainerXPSolidifier(entityPlayer.inventory, tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +116,8 @@ public class GuiHandler implements IGuiHandler{
|
||||||
return new GuiEnergizer(entityPlayer, tile);
|
return new GuiEnergizer(entityPlayer, tile);
|
||||||
case ENERVATOR_ID:
|
case ENERVATOR_ID:
|
||||||
return new GuiEnervator(entityPlayer, tile);
|
return new GuiEnervator(entityPlayer, tile);
|
||||||
|
case XP_SOLIDIFIER_ID:
|
||||||
|
return new GuiXPSolidifier(entityPlayer.inventory, tile, x, y, z, world);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -140,6 +144,7 @@ public class GuiHandler implements IGuiHandler{
|
||||||
public static final int DRILL_ID = 18;
|
public static final int DRILL_ID = 18;
|
||||||
public static final int ENERGIZER_ID = 19;
|
public static final int ENERGIZER_ID = 19;
|
||||||
public static final int ENERVATOR_ID = 20;
|
public static final int ENERVATOR_ID = 20;
|
||||||
|
public static final int XP_SOLIDIFIER_ID = 21;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
ModUtil.LOGGER.info("Initializing GuiHandler...");
|
ModUtil.LOGGER.info("Initializing GuiHandler...");
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package ellpeck.actuallyadditions.inventory.gui;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import ellpeck.actuallyadditions.inventory.ContainerXPSolidifier;
|
||||||
|
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||||
|
import ellpeck.actuallyadditions.network.gui.PacketGuiButton;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityXPSolidifier;
|
||||||
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiXPSolidifier extends GuiContainer{
|
||||||
|
|
||||||
|
private TileEntityXPSolidifier solidifier;
|
||||||
|
|
||||||
|
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiXPSolidifier");
|
||||||
|
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
private World world;
|
||||||
|
|
||||||
|
public GuiXPSolidifier(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){
|
||||||
|
super(new ContainerXPSolidifier(inventory, tile));
|
||||||
|
this.solidifier = (TileEntityXPSolidifier)tile;
|
||||||
|
this.xSize = 176;
|
||||||
|
this.ySize = 93+86;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void initGui(){
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
GuiButton buttonOne = new GuiInputter.SmallerButton(0, guiLeft+62, guiTop+44, "1");
|
||||||
|
GuiButton buttonFive = new GuiInputter.SmallerButton(1, guiLeft+80, guiTop+44, "5");
|
||||||
|
GuiButton buttonTen = new GuiInputter.SmallerButton(2, guiLeft+99, guiTop+44, "10");
|
||||||
|
GuiButton buttonTwenty = new GuiInputter.SmallerButton(3, guiLeft+62, guiTop+61, "20");
|
||||||
|
GuiButton buttonThirty = new GuiInputter.SmallerButton(4, guiLeft+80, guiTop+61, "30");
|
||||||
|
GuiButton buttonForty = new GuiInputter.SmallerButton(5, guiLeft+99, guiTop+61, "40");
|
||||||
|
GuiButton buttonFifty = new GuiInputter.SmallerButton(6, guiLeft+62, guiTop+78, "50");
|
||||||
|
GuiButton buttonSixtyFour = new GuiInputter.SmallerButton(7, guiLeft+80, guiTop+78, "64");
|
||||||
|
GuiButton buttonThousandTwentyEight = new GuiInputter.SmallerButton(8, guiLeft+99, guiTop+78, "128");
|
||||||
|
|
||||||
|
this.buttonList.add(buttonOne);
|
||||||
|
this.buttonList.add(buttonFive);
|
||||||
|
this.buttonList.add(buttonTen);
|
||||||
|
this.buttonList.add(buttonTwenty);
|
||||||
|
this.buttonList.add(buttonThirty);
|
||||||
|
this.buttonList.add(buttonForty);
|
||||||
|
this.buttonList.add(buttonFifty);
|
||||||
|
this.buttonList.add(buttonSixtyFour);
|
||||||
|
this.buttonList.add(buttonThousandTwentyEight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(GuiButton button){
|
||||||
|
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(x, y, z, world, button.id, Minecraft.getMinecraft().thePlayer));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawGuiContainerForegroundLayer(int x, int y){
|
||||||
|
AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.solidifier.getInventoryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawGuiContainerBackgroundLayer(float f, int x, int y){
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
||||||
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86);
|
||||||
|
|
||||||
|
this.mc.getTextureManager().bindTexture(resLoc);
|
||||||
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int x, int y, float f){
|
||||||
|
super.drawScreen(x, y, f);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,10 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
||||||
import ellpeck.actuallyadditions.util.*;
|
import ellpeck.actuallyadditions.util.INameableItem;
|
||||||
|
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -83,12 +86,6 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
if(this.getStoredPosition(stack) == null) this.clearStorage(stack);
|
if(this.getStoredPosition(stack) == null) this.clearStorage(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
|
|
||||||
if(KeyUtil.isAltPressed()) this.clearStorage(stack);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldPos getStoredPosition(ItemStack stack){
|
public WorldPos getStoredPosition(ItemStack stack){
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
if(tag != null){
|
if(tag != null){
|
||||||
|
@ -128,7 +125,7 @@ public class ItemPhantomConnector extends Item implements INameableItem{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||||
ItemUtil.addInformation(this, list, 2, "");
|
ItemUtil.addInformation(this, list, 1, "");
|
||||||
WorldPos coords = this.getStoredPosition(stack);
|
WorldPos coords = this.getStoredPosition(stack);
|
||||||
if(coords != null){
|
if(coords != null){
|
||||||
World world = coords.getWorld();
|
World world = coords.getWorld();
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class TileEntityBase extends TileEntity{
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
ModUtil.LOGGER.info("Registering TileEntities...");
|
ModUtil.LOGGER.info("Registering TileEntities...");
|
||||||
GameRegistry.registerTileEntity(TileEntityCompost.class, ModUtil.MOD_ID_LOWER + ":tileEntityCompost");
|
GameRegistry.registerTileEntity(TileEntityCompost.class, ModUtil.MOD_ID_LOWER+":tileEntityCompost");
|
||||||
GameRegistry.registerTileEntity(TileEntityFeeder.class, ModUtil.MOD_ID_LOWER + ":tileEntityFeeder");
|
GameRegistry.registerTileEntity(TileEntityFeeder.class, ModUtil.MOD_ID_LOWER + ":tileEntityFeeder");
|
||||||
GameRegistry.registerTileEntity(TileEntityGiantChest.class, ModUtil.MOD_ID_LOWER + ":tileEntityGiantChest");
|
GameRegistry.registerTileEntity(TileEntityGiantChest.class, ModUtil.MOD_ID_LOWER + ":tileEntityGiantChest");
|
||||||
GameRegistry.registerTileEntity(TileEntityGrinder.class, ModUtil.MOD_ID_LOWER + ":tileEntityGrinder");
|
GameRegistry.registerTileEntity(TileEntityGrinder.class, ModUtil.MOD_ID_LOWER + ":tileEntityGrinder");
|
||||||
|
@ -58,6 +58,7 @@ public class TileEntityBase extends TileEntity{
|
||||||
GameRegistry.registerTileEntity(TileEntityPhantomBooster.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomBooster");
|
GameRegistry.registerTileEntity(TileEntityPhantomBooster.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomBooster");
|
||||||
GameRegistry.registerTileEntity(TileEntityEnergizer.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnergizer");
|
GameRegistry.registerTileEntity(TileEntityEnergizer.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnergizer");
|
||||||
GameRegistry.registerTileEntity(TileEntityEnervator.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnervator");
|
GameRegistry.registerTileEntity(TileEntityEnervator.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnervator");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityXPSolidifier.class, ModUtil.MOD_ID_LOWER+":tileEntityXPSolidifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package ellpeck.actuallyadditions.tile;
|
||||||
|
|
||||||
|
|
||||||
|
import ellpeck.actuallyadditions.items.InitItems;
|
||||||
|
import ellpeck.actuallyadditions.items.ItemSpecialDrop;
|
||||||
|
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
|
||||||
|
import ellpeck.actuallyadditions.network.gui.IButtonReactor;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{
|
||||||
|
|
||||||
|
public TileEntityXPSolidifier(){
|
||||||
|
super(6, "xpSolidifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUpdate(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||||
|
return this.isItemValidForSlot(slot, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getFirstAvailSlot(ItemStack stack){
|
||||||
|
for(int i = 0; i < this.slots.length; i++){
|
||||||
|
if(this.slots[i] == null || (this.slots[i].isItemEqual(stack) && this.slots[i].stackSize+stack.stackSize <= this.slots[i].getMaxStackSize())) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] buttonAmounts = new int[]{1, 5, 10, 20, 30, 40, 50, 64, 128};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onButtonPressed(int buttonID, EntityPlayer player){
|
||||||
|
if(buttonID < buttonAmounts.length){
|
||||||
|
for(int i = 0; i < buttonAmounts[buttonID]; i++){
|
||||||
|
int slot = this.getFirstAvailSlot(new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal()));
|
||||||
|
if(slot >= 0 && this.getPlayerXP(player) >= ItemSpecialDrop.SOLID_XP_AMOUNT){
|
||||||
|
this.addPlayerXP(player, -ItemSpecialDrop.SOLID_XP_AMOUNT);
|
||||||
|
|
||||||
|
if(this.slots[slot] == null) this.slots[slot] = new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal());
|
||||||
|
else this.slots[slot].stackSize++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPlayerXP(EntityPlayer player){
|
||||||
|
return (int)(this.getExperienceForLevel(player.experienceLevel)+(player.experience*player.xpBarCap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPlayerXP(EntityPlayer player, int amount){
|
||||||
|
int experience = getPlayerXP(player)+amount;
|
||||||
|
player.experienceTotal = experience;
|
||||||
|
|
||||||
|
int level = 0;
|
||||||
|
while(getExperienceForLevel(level) <= experience){
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
player.experienceLevel = level-1;
|
||||||
|
|
||||||
|
int expForLevel = this.getExperienceForLevel(player.experienceLevel);
|
||||||
|
player.experience = (float)(experience-expForLevel)/(float)player.xpBarCap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getExperienceForLevel(int level){
|
||||||
|
if(level != 0){
|
||||||
|
if(level > 0 && level < 16) return level*17;
|
||||||
|
else if(level > 15 && level < 31) return (int)(1.5*Math.pow(level, 2)-29.5*level+360);
|
||||||
|
else return (int)(3.5*Math.pow(level, 2)-151.5*level+2220);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -158,8 +158,7 @@ tooltip.actuallyadditions.blockPhantomBooster.desc.1=When placed above a Phantom
|
||||||
tooltip.actuallyadditions.blockPhantomBooster.desc.2=(Max Amount above one Phantom Machine: 3)
|
tooltip.actuallyadditions.blockPhantomBooster.desc.2=(Max Amount above one Phantom Machine: 3)
|
||||||
|
|
||||||
item.actuallyadditions.itemPhantomConnector.name=Phantom Connector
|
item.actuallyadditions.itemPhantomConnector.name=Phantom Connector
|
||||||
tooltip.actuallyadditions.itemPhantomConnector.desc.1=Connects a Phantom Face to any Inventory Block!
|
tooltip.actuallyadditions.itemPhantomConnector.desc=Connects a Phantom Inventory to any Inventory Block!
|
||||||
tooltip.actuallyadditions.itemPhantomConnector.desc.2=Hold ALT to clear the stored TileEntity
|
|
||||||
|
|
||||||
item.actuallyadditions.itemMiscCup.name=Empty Cup
|
item.actuallyadditions.itemMiscCup.name=Empty Cup
|
||||||
tooltip.actuallyadditions.itemMiscCup.desc=Used to make Coffee in a Coffee Machine!
|
tooltip.actuallyadditions.itemMiscCup.desc=Used to make Coffee in a Coffee Machine!
|
||||||
|
|
Loading…
Reference in a new issue