Everything posted by Moritz
-
How to make something that breaks a block slowly on right click?
I have the thaumcraft source and he use onItemUse and just break the block instant. And there is no cool down or something. But you could make it like this that you add with itemNBT a custom cooldown. like this: Note its a custom Function you only need to call it in the onItemUseFunction public boolean onItemUseage(ItemStack stack, World world, int x, int y, int z) //More is { if(stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound().getCompoundTag("tool"); if(nbt.getInteger("coolDown") <= 0) { //Here do your break code nbt.setInteger("coolDown", 20); return true; } } return false; } public void onUpdate(ItemStack stack, World par2, EntityPlayer player) { if(stack.hasTagCompound()) { NBTTagCompoun nbt = stack.getTagCompound().getCompoundTag("tool"); if(nbt.getInteger("coolDown") > 0) { int between = nbt.getInteger("coolDown"); nbt.setInteger("coolDown", between-1); } } }
-
[1.6.4]Dual Input Furnace help - 2 inputs, 1 output no fuel slots (preferably).
Just make a recipeList, Hashmap is good enough. Just add to the onUpdate function something like that: public int progress = 0; @Override public void onUpdate() { if(recipeMatch()) { progress++; if(progress > 200)//Normal furnace Time { progress = 0; //put everything here what should happen if the progress is done. } } else { progress = 0; //so that it does not save the progress } }
-
Ore Dictionary: replacing single recipe
LOL. What happend here?
-
Ore Dictionary: replacing single recipe
You do not really need to override it. CraftingManager sort his recipe. So you need to do a custom craftingHandler. Not that from forge, You simply make it like that you have your standart crafting recipe. With 1 thing you set the recipe size to 1 then the craftingmanager sort it automaticly above the forge/vanilla stick recipes. How lower the recipe size is that lower he put the recipes size and the lowest number comes first. Actually i can not tell how you can make shaped shapless recipes in a custom craftinghandler. Just look at the normal shaped recipe. I hope that helps.
-
Vanilla Enchantments on custom Item
use the on update function to remove the enchantment what is not allowed. That is the only way when you still want to use the vanilla enchanting way. For my enchanter i created a new enchanting system
-
Problem with FluidTanks
Its easier to read but make much more code. Because you have to type everything 2 times. BC showed there the right way
-
Problem with FluidTanks
found the bug. The sendGuiInfoData had a missmatch with the packetID. i had 2 times number 3 And again my Container is in the TileEntity!
-
Problem with FluidTanks
I did that. You find it at the getDiscription Packet And the Container Sync is are in the functions "getInfoData" and "sendGuiInfoData" which are called from the container. So that could not be the problem. another Idea diesieben?
-
Problem with FluidTanks
My tanks have problems with storing the Fluid. its always null but he know what is inside of him. I mean when i put 1 water bucket and 1 lava bucket in then i get these back if i extract it. But when i want to display it on my GUI then the fluid is always null. here my code: GUI: package speiger.src.api.client.gui; import net.minecraft.block.Block; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; import speiger.src.api.common.container.ContainerCompressor; import speiger.src.api.common.tile.BasicCompressor; import cpw.mods.fml.common.Loader; public class GuiCompressor extends GuiContainer { private BasicCompressor tile; public GuiCompressor(InventoryPlayer par1, BasicCompressor par2) { super(new ContainerCompressor(par1, par2)); tile = par2; this.ySize = 178; } protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; int textID = codeID(par1 - cornerX, par2 - cornerY); switch(textID) { case 1: if(Loader.isModLoaded("BuildCraft|Energy"))this.drawCreativeTabHoveringText("Energy: "+tile.fuel+"MJ / "+3000+"MJ", par1-cornerX, par2-cornerY); else this.drawCreativeTabHoveringText("Energy: "+tile.fuel+" / "+3000, par1-cornerX, par2-cornerY); break; case 2: if(tile.first.getFluid() == null || tile.first.getFluid().fluidID == 0) this.drawCreativeTabHoveringText("Empty Tank: "+"0mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY); else if(tile.first.getFluid() != null && new ItemStack(tile.first.getFluid().fluidID, 1, 0) != null) this.drawCreativeTabHoveringText("Filled Tank: "+new ItemStack(tile.first.getFluid().fluidID, 1, 0)+" "+tile.first.getFluid().amount+"mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY); else this.drawCreativeTabHoveringText("Filled Tank: "+"Unknowen Liquid"+" "+tile.first.getFluid().amount+"mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY); break; case 3: if(tile.second.getFluid() == null || tile.second.getFluid().fluidID == 0) this.drawCreativeTabHoveringText("Empty Tank: "+"0mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY); else if(tile.second.getFluid() != null && new ItemStack(tile.second.getFluid().fluidID, 1, 0) != null) this.drawCreativeTabHoveringText("Filled Tank: "+new ItemStack(tile.second.getFluid().fluidID, 1, 0)+" "+tile.second.getFluid().amount+"mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY); else this.drawCreativeTabHoveringText("Filled Tank: "+"Unknowen Liquid"+" "+tile.second.getFluid().amount+"mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY); } } private static final ResourceLocation var4 = new ResourceLocation("spmodapi:textures/gui/SqueezingCompressor.png"); protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); if(tile.progress > 0) { this.drawTexturedModalRect(var5+49, var6+29, 55, 181, tile.progress / 12, 21); } if(tile.fuel > 0) { int fuel = tile.fuel / 190; this.drawTexturedModalRect(var5+134, var6+75+16-fuel, 176, 84+16-fuel, 12, fuel); } if(tile.getTankScaled(58, true) > 0) { this.displayGauge(var5, var6, 18, 68, tile.getTankScaled(58, true), tile.getLiquidID(true)); } if(tile.getTankScaled(58, false) > 0) { this.displayGauge(var5, var6, 18, 92, tile.getTankScaled(58, false), tile.getLiquidID(false)); } } private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) { if (liquid == null) { return; } int start = 0; Icon liquidIcon = null; Fluid fluid = liquid.getFluid(); if (fluid != null && fluid.getStillIcon() != null) { liquidIcon = fluid.getStillIcon(); } mc.renderEngine.bindTexture(BLOCK_TEXTURE); if (liquidIcon != null) { while (true) { int x; if (squaled > 16) { x = 16; squaled -= 16; } else { x = squaled; squaled = 0; } drawTexturedModelRectFromIcon(j + col, k + line + 58 - x - start, liquidIcon, 16, 16 - (16 - x)); start = start + 16; if (x == 0 || squaled == 0) { break; } } } mc.renderEngine.bindTexture(var4); drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60); } public int codeID(int x, int y) { if(x >=135 && x <=145 && y >= 76 && y <= 88)return 1; if(x >=68 && x<=83 && y>=18 && y<=75) return 2; if(x >=92 && x<=107 && y>=18 && y<=75) return 3; return -1; } } TileEntity: package speiger.src.api.common.tile; import java.util.ArrayList; import java.util.Random; import cpw.mods.fml.common.FMLLog; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; import speiger.src.api.api.recipes.EnumRecipeType; import speiger.src.api.api.recipes.recipe.INormalRecipe; import speiger.src.api.api.recipes.result.Result; import speiger.src.api.client.core.PathProxyClient; import speiger.src.api.common.container.ContainerCompressor; import speiger.src.api.common.debug.DebugCore; import speiger.src.api.common.functions.MachineRecipeMaker; import speiger.src.api.common.functions.WorldReading; public class BasicCompressor extends TileFacing implements IFluidHandler, IInventory, ISidedInventory { public Random rand = new Random(); public int progress = 0; public int fuel = 0; public int mode = 0; public int cound = 0; public FluidTank first = new FluidTank(16000); public FluidTank second = new FluidTank(16000); public ItemStack[] inventory = new ItemStack[14]; public boolean update = false; public boolean naturalEnergy = false; MachineRecipeMaker recipes = MachineRecipeMaker.getRecipes(); ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); ArrayList<FluidStack> liquidDrops = new ArrayList<FluidStack>(); @Override public int getTextureFromTile(int meta, int side) { if(side == 0 || side == 1)return 133; else if(side == ForgeDirection.getOrientation(facing).ordinal())return 131; else if(side == ForgeDirection.getOrientation(facing).getOpposite().ordinal())return 132; else return 134; } @Override public Packet getDescriptionPacket() { NBTTagCompound var1 = new NBTTagCompound(); super.writeToNBT(var1); var1.setInteger("rotation", facing); var1.setInteger("Progress", progress); var1.setInteger("Fuels", fuel); var1.setInteger("Mode", mode); if (first.getFluid() != null) { var1.setTag("FirstTank", first.getFluid().writeToNBT(new NBTTagCompound())); } if (second.getFluid() != null) { var1.setTag("Second", second.getFluid().writeToNBT(new NBTTagCompound())); } return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, var1); } @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { this.readFromNBT(pkt.data); } @Override public void updateEntity() { super.updateEntity(); if(update) { update = false; this.onInventoryChanged(); } updateBlock(); if(!this.worldObj.isRemote) { EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, DebugCore.detectRange); if(progress > 0 && fuel > 0) { if(cound >= DebugCore.tickrate) { if(player != null) { this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, this.getSoundFromMode(mode), DebugCore.loudness, DebugCore.range); } cound = 0; } else { cound++; } } if(first.getFluid() != null && first.getFluid().amount <= 0) { first.setFluid(null); } if(second.getFluid() != null && second.getFluid().amount <= 0) { second.setFluid(null); } updateSlots(); onBCUpdate(); onRedstoneUpdate(); fillBuckets(); doSomething(); createSymbol(); if(!drops.isEmpty() || !liquidDrops.isEmpty()) { if(!drops.isEmpty()) { emptyItemArray(); } if(!liquidDrops.isEmpty()) { emptyLiquidArray(); } } update = true; } } public String getSoundFromMode(int par1) { if(par1 == 0) return "textures.compressorSound"; else if(par1 == 1) return "textures.sqeezerSound"; else return "textures.mixerSound"; } public void createSymbol() { ItemStack display = new ItemStack(Block.pistonStickyBase); NBTTagCompound nbt = new NBTTagCompound(); nbt.setCompoundTag("display", new NBTTagCompound()); nbt.getCompoundTag("display").setString("Name", "Sqeezing Compressor"); display.setTagCompound(nbt); switch(mode) { case 0: PathProxyClient.addItemToolTip(display, "tip", "Compressing Mode"); break; case 1: PathProxyClient.addItemToolTip(display, "tip", "Sqeezing Mode"); break; case 2: PathProxyClient.addItemToolTip(display, "tip", "Mixing Mode"); } inventory[13] = display.copy(); } public void fillBuckets() { if(inventory[1] != null) { if(FluidContainerRegistry.isBucket(inventory[1]) || FluidContainerRegistry.isContainer(inventory[1])) { if(FluidContainerRegistry.isEmptyContainer(inventory[1]) && drops.isEmpty()) { if(first.getFluid() != null && first.getFluid().amount > 0) { ItemStack stack = FluidContainerRegistry.fillFluidContainer(first.getFluid(), inventory[1]); if(stack != null) { int size = FluidContainerRegistry.getFluidForFilledItem(stack).amount; if(first.getFluid().amount >= size) { inventory[1].stackSize--; if(inventory[1].stackSize <= 0) { inventory[1] = null; } first.drain(size, true); drops.add(stack.copy()); return; } } } } if(FluidContainerRegistry.isFilledContainer(inventory[1])) { if(liquidDrops.isEmpty() && drops.isEmpty()) { FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(inventory[1]); if(stack != null) { inventory[1].stackSize--; liquidDrops.add(stack.copy()); ItemStack chance = inventory[1].getItem().getContainerItemStack(inventory[1]); if(chance != null) { drops.add(chance.copy()); } if(inventory[1].stackSize <= 0) { inventory[1] = null; } return; } } } } } if(inventory[2] != null) { if(FluidContainerRegistry.isBucket(inventory[2]) || FluidContainerRegistry.isContainer(inventory[2])) { if(FluidContainerRegistry.isEmptyContainer(inventory[2]) && drops.isEmpty()) { if(second.getFluid() != null && second.getFluid().amount > 0) { ItemStack stack = FluidContainerRegistry.fillFluidContainer(second.getFluid(), inventory[2]); if(stack != null) { int size = FluidContainerRegistry.getFluidForFilledItem(stack).amount; if(second.getFluid().amount >= size) { inventory[2].stackSize--; if(inventory[2].stackSize <= 0) { inventory[2] = null; } second.drain(size, true); drops.add(stack.copy()); return; } } } } if(FluidContainerRegistry.isFilledContainer(inventory[2])) { if(liquidDrops.isEmpty() && drops.isEmpty()) { FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(inventory[2]); if(stack != null) { inventory[2].stackSize--; liquidDrops.add(stack.copy()); ItemStack chance = inventory[2].getItem().getContainerItemStack(inventory[2]); if(chance != null) { drops.add(chance.copy()); } if(inventory[2].stackSize <= 0) { inventory[2] = null; } return; } } } } } } public void updateBlock() { int var1 = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord); markBlockDirty(this.worldObj, this.xCoord, this.yCoord, this.zCoord); } public void markBlockDirty(World var0, int var1, int var2, int var3) { if (var0.blockExists(var1, var2, var3)) { var0.getChunkFromBlockCoords(var1, var3).setChunkModified(); } } public void onRedstoneUpdate() { if(fuel < 3000) { if(this.naturalEnergy && !isPowered()) { fuel+=10; naturalEnergy = false; } if(!this.naturalEnergy && isPowered()) { this.naturalEnergy = true; } } } public boolean isPowered() { return WorldReading.isGettingPowered(worldObj, xCoord, yCoord, zCoord) || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); } public void emptyLiquidArray() { for(int i = 0;i<liquidDrops.size();i++) { if(first.getFluid() == null) { first.fill(liquidDrops.get(i), true); liquidDrops.remove(i); continue; } else { if(first.fill(liquidDrops.get(i), false) > 0) { first.fill(liquidDrops.get(i), true); liquidDrops.remove(i); continue; } } if(second.getFluid() == null) { second.fill(liquidDrops.get(i), true); liquidDrops.remove(i); continue; } else { if(second.fill(liquidDrops.get(i), false) > 0) { second.fill(liquidDrops.get(i), true); liquidDrops.remove(i); continue; } } } } public void emptyItemArray() { for(int i = 0;i<drops.size();i++) { if(inventory[8] == null) { inventory[8] = drops.get(i).copy(); drops.remove(i); } } } public void updateSlots() { transferItems(3, 4); transferItems(4, 5); transferItems(5, 6); transferItems(6, 7); transferItems(8, 9); transferItems(8, 10); transferItems(8, 11); transferItems(8, 12); transferItems(9, 10); transferItems(9, 12); transferItems(9, 11); transferItems(10, 11); transferItems(10, 12); transferItems(11, 12); } public void transferItems(int slot0, int slot1) { if(inventory[slot0] != null) { if(inventory[slot1] == null) { inventory[slot1] = inventory[slot0].copy(); inventory[slot0] = null; update = true; } else if(inventory[slot1] != null && inventory[slot1].isItemEqual(inventory[slot0])) { if(inventory[slot1].stackSize + inventory[slot0].stackSize <= 64) { inventory[slot1].stackSize += inventory[slot0].stackSize; inventory[slot0] = null; update = true; } else { int stacksize = (inventory[slot1].stackSize + inventory[slot0].stackSize) - 64; inventory[slot1].stackSize = 64; inventory[slot0].stackSize = stacksize; update = true; } } } } public void doSomething() { int speed = getSpeedValue(); if(speed == 0) return; EnumRecipeType type = getRecipeTypeFromMode(mode); if(type == null)return; if(inventory[7] != null && recipes.hasMatchingRecipe(type, inventory[7].copy(), first, second, worldObj)) { if(fuel > 0 && drops.isEmpty() && liquidDrops.isEmpty()) { progress+=speed; fuel-=speed; if(progress >= 1000) { INormalRecipe recipe = recipes.getRecipe(type, inventory[7].copy(), first, second, worldObj); if(recipe != null && recipe.getResult() != null) { Result[] output = recipe.getResult(); for(int i = 0;i<output.length;i++) { Result current = output[i]; if(current.hasItemResult(this.worldObj) && current.getItemResult(this.worldObj) != null && rand.nextInt(100) < current.getItemResultChance(this.worldObj)) { drops.add(current.getItemResult(this.worldObj)); } if(current.hasLiquidResult(this.worldObj) && current.getLiquidResult(this.worldObj) != null && rand.nextInt(100) < current.getLiquidResultChance(this.worldObj)) { liquidDrops.add(current.getLiquidResult(this.worldObj)); } } recipe.runResult(inventory[7], first, second, worldObj); if(inventory[7].stackSize <= 0) { inventory[7] = inventory[7].getItem().getContainerItemStack(inventory[7]); } progress = 0; } else { progress = 0; } } } } else { progress = 0; } } public void onBCUpdate() { } public EnumRecipeType getRecipeTypeFromMode(int i) { if(i == 0) { return EnumRecipeType.Compressor; } if(i == 1) { return EnumRecipeType.Sqeezer; } if(i == 2) { return EnumRecipeType.Mixer; } return null; } public int getSpeedValue() { if(fuel > 0) { if(fuel > 100) { if(fuel > 500) { if(fuel > 1000) { return 4; } else { return 3; } } else { return 2; } } else { return 1; } } else { return 0; } } public int getSizeInventory() { return this.inventory.length; } public ItemStack getStackInSlot(int par1) { return this.inventory[par1]; } public ItemStack decrStackSize(int par1, int par2) { if (this.inventory[par1] != null) { ItemStack var3; if (this.inventory[par1].stackSize <= par2) { var3 = this.inventory[par1]; this.inventory[par1] = null; return var3; } else { var3 = this.inventory[par1].splitStack(par2); if (this.inventory[par1].stackSize == 0) { this.inventory[par1] = null; } return var3; } } else { return null; } } public ItemStack getStackInSlotOnClosing(int par1) { if (this.inventory[par1] != null) { ItemStack var2 = this.inventory[par1]; this.inventory[par1] = null; return var2; } else { return null; } } public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.inventory[par1] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } } public String getInvName() { return "Special Compressor"; } public int getInventoryStackLimit() { return 64; } public boolean isUseableByPlayer(EntityPlayer var1) { return true; } public void openChest() { } @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); this.inventory = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); byte var5 = var4.getByte("Slot"); if (var5 >= 0 && var5 < this.inventory.length) { this.inventory[var5] = ItemStack.loadItemStackFromNBT(var4); } } if (par1NBTTagCompound.hasKey("FirstTank")) { FluidStack stack = FluidStack.loadFluidStackFromNBT(par1NBTTagCompound.getCompoundTag("FirstTank")); if(stack != null) { first.setFluid(stack); } } if (par1NBTTagCompound.hasKey("Second")) { FluidStack fluid = FluidStack.loadFluidStackFromNBT(par1NBTTagCompound.getCompoundTag("Second")); if(fluid != null) { second.setFluid(fluid); } } progress = par1NBTTagCompound.getInteger("Progress"); fuel = par1NBTTagCompound.getInteger("Fuels"); mode = par1NBTTagCompound.getInteger("Mode"); } /** * Writes a tile entity to NBT. */ @Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.inventory.length; ++var3) { if (this.inventory[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte)var3); this.inventory[var3].writeToNBT(var4); var2.appendTag(var4); } } par1NBTTagCompound.setTag("Items", var2); par1NBTTagCompound.setInteger("rotation", facing); if (first.getFluid() != null) { par1NBTTagCompound.setTag("FirstTank", first.getFluid().writeToNBT(par1NBTTagCompound)); } if (second.getFluid() != null) { par1NBTTagCompound.setTag("Second", second.getFluid().writeToNBT(par1NBTTagCompound)); } par1NBTTagCompound.setInteger("Progress", progress); par1NBTTagCompound.setInteger("Fuels", fuel); par1NBTTagCompound.setInteger("Mode", mode); } public void closeChest() { } public FluidStack getLiquidID(boolean firsts) { if(firsts) { return first.getFluid(); } else { return second.getFluid(); } } public int getTankScaled(int i, boolean firsts) { if(firsts) { return first.getFluid() != null ? ((first.getFluid().amount / (275))) : 0; } else { return second.getFluid() != null ? ((second.getFluid().amount / (275))) : 0; } } public void getInfoData(int key, int value) { switch(key) { case 0: progress = value; break; case 1: fuel = value; break; case 2: mode = value; break; case 3: if (first.getFluid() == null) { first.setFluid(new FluidStack(value, 0)); } else { first.getFluid().fluidID = value; } break; case 4: if (first.getFluid() == null) { first.setFluid(new FluidStack(0, value)); } else { first.getFluid().amount = value; } break; case 5: if (second.getFluid() == null) { second.setFluid(new FluidStack(value, 0)); } else { second.getFluid().fluidID = value; } break; case 6: if (second.getFluid() == null) { second.setFluid(new FluidStack(0, value)); } else { second.getFluid().amount = value; } break; case 7: this.cound = value; } } public void sendGuiInfoData(ContainerCompressor par1, ICrafting par2) { par2.sendProgressBarUpdate(par1, 0, progress); par2.sendProgressBarUpdate(par1, 1, fuel); par2.sendProgressBarUpdate(par1, 2, mode); par2.sendProgressBarUpdate(par1, 3, first.getFluid() != null ? first.getFluid().fluidID : 0); par2.sendProgressBarUpdate(par1, 4, first.getFluid() != null ? first.getFluid().amount : 0); par2.sendProgressBarUpdate(par1, 5, second.getFluid() != null ? second.getFluid().fluidID : 0); par2.sendProgressBarUpdate(par1, 3, second.getFluid() != null ? second.getFluid().amount : 0); par2.sendProgressBarUpdate(par1, 6, cound); } public void breaks() { this.inventory[13] = null; this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, (String)null, 0, 0); } @Override public int[] getAccessibleSlotsFromSide(int var1) { if(var1 == 0 || var1 == 1) { return new int[]{3}; } return new int[]{12}; } @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { if(j == 0 || j == 1) { return true; } return false; } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { if(j == 0 || j == 1) { return false; } return true; } @Override public boolean isInvNameLocalized() { return false; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if(from.ordinal() == ForgeDirection.EAST.ordinal() || from.ordinal() == ForgeDirection.WEST.ordinal()) { if(first.fill(resource, false) > 0) { return first.fill(resource, doFill); } return 0; } if(from.ordinal() == ForgeDirection.NORTH.ordinal() || from.ordinal() == ForgeDirection.SOUTH.ordinal()) { if(second.fill(resource, false) > 0) { return second.fill(resource, doFill); } return 0; } if(first.fill(resource, false) > 0) { return first.fill(resource, doFill); } if(second.fill(resource, false) > 0) { return second.fill(resource, doFill); } return 0; } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return this.drain(from, resource.amount, doDrain); } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { if(from.ordinal() == ForgeDirection.EAST.ordinal() || from.ordinal() == ForgeDirection.WEST.ordinal()) { if(first.drain(maxDrain, false) != null) { return first.drain(maxDrain, doDrain); } return null; } if(from.ordinal() == ForgeDirection.NORTH.ordinal() || from.ordinal() == ForgeDirection.SOUTH.ordinal()) { if(second.drain(maxDrain, false) != null) { return second.drain(maxDrain, doDrain); } return null; } if(first.drain(maxDrain, false) != null) { return first.drain(maxDrain, doDrain); } if(second.drain(maxDrain, false) != null) { return second.drain(maxDrain, doDrain); } return null; } @Override public boolean canFill(ForgeDirection from, Fluid fluid) { return true; } @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { return true; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { return new FluidTankInfo[]{first.getInfo(), second.getInfo()}; } } What could be the problem?
-
how do i detect items in custom GUI slots?
the itemstack array in the tileentity symboles your Slots. Use onUpdate() in the tileentity and check your inventory and change the item how much you want.
-
Help with Smelting Recipe
maybe because you need to install the mods for testing!
-
Teleporting a Player to a new Dimension
I know i am proberly not the best person for this to answer but maybe my idea helps. Well when you rightclick a item you have 3 variables. (just thinking while typing) I know that the spawncoordinates are stored in a player. So you have access to them. I guess you mean with spawn the bed. There are variables where you can access the chunk coordinates. Point 1: Coordinates. Check! Point 2: Teleportation. Not knowen yet. After Reading a half hour the Source i found a way for teleport. Look in the Entity Class. There is a methode/function that is called Travel to dimension. Check it out. I hope it helps. Speiger
-
Help with Smelting Recipe
The getOreID is only for the hashmap in the oredictionary. No use for that. for(ItemStack ore : Oredictionary.getOres("oreCopper")) { if(ore != null) //i am always more than becarefull with that { if(ore.getItemDamage() != -1 || ore.getItemDamage() != OreDictionary.WILDCARDVALUE) { FurnaceRecipes.smelting().addSmelting(ore.itemID, ore.getItemDamage(), new ItemStack(Blocks.rockwoolBlock)); } else { FurnaceRecipes.smelting().addSmelting(ore.itemID, new ItemStack(Blocks.rockwoolBlock)); } } } Hope it help
-
How do I use ISpecialArmor to get a full set bonus?
You do not need ISpecialArmor for that. Use onArmorUpdate() and check if he have all amor parts you want on and then activate your effect.
-
getStrVsBlock and setToolClass Harvest Level
The bad thing is i have at the moment no access to my pneumatic drill. But my custom tool i have access to. Here this is the way i made it: Here how i made my tool: its a multitool. but you can do it as you want package speiger.src.api.common.items; import java.util.HashMap; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; import speiger.src.api.api.BlockStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemSpecialTool extends ItemSpmod { public Random rand = new Random(); public HashMap<Material, Boolean> validPick = new HashMap<Material, Boolean>(); public HashMap<Material, Boolean> validShovel = new HashMap<Material, Boolean>(); public HashMap<Material, Boolean> validAxe = new HashMap<Material, Boolean>(); public ItemSpecialTool(int par1) { super(par1, true); this.setAPICreativeTap(); MinecraftForge.setToolClass(this, "pickaxe", 1000); MinecraftForge.setToolClass(this, "axe", 1000); MinecraftForge.setToolClass(this, "shovel", 1000); addPickMaterial(); } public Material[] pickList = new Material[]{Material.anvil, Material.iron, Material.piston, Material.redstoneLight, Material.rock, Material.ice}; public Material[] shovelList = new Material[]{Material.cake, Material.clay, Material.craftedSnow, Material.glass, Material.grass, Material.ground, Material.materialCarpet, Material.sand, Material.snow}; public Material[] axeList = new Material[]{Material.cactus, Material.cloth, Material.coral, Material.leaves, Material.plants, Material.vine, Material.pumpkin, Material.wood}; public void addPickMaterial() { //Pickaxes for(int i = 0;i<pickList.length;i++) { validPick.put(pickList[i], true); } for(int i = 0;i<shovelList.length;i++) { validShovel.put(shovelList[i], true); } for(int i = 0;i<axeList.length;i++) { validAxe.put(axeList[i], true); } } @Override public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) { BlockStack block = new BlockStack(X, Y, Z, player.worldObj); NBTTagCompound nbt = itemstack.getTagCompound().getCompoundTag("Tool"); if(validPick.containsKey(block.getBlockFromStack().blockMaterial)) { int pick = nbt.getInteger("PickaxeSpeed"); nbt.setInteger("PickaxeSpeed", pick+1); return false; } else if(validShovel.containsKey(block.getBlockFromStack().blockMaterial)) { int shovel = nbt.getInteger("ShovelSpeed"); nbt.setInteger("ShovelSpeed", shovel+1); return false; } else if(validAxe.containsKey(block.getBlockFromStack().blockMaterial)) { int axe = nbt.getInteger("AxeSpeed"); nbt.setInteger("AxeSpeed", axe+1); return false; } else { return false; } } public static ItemStack createSpecialTool(int par1) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setCompoundTag("Tool", new NBTTagCompound()); nbt.getCompoundTag("Tool").setInteger("AxeSpeed", 0); nbt.getCompoundTag("Tool").setInteger("ShovelSpeed", 0); nbt.getCompoundTag("Tool").setInteger("PickaxeSpeed", 0); ItemStack stack = new ItemStack(par1, 1, 0); stack.setTagCompound(nbt); return stack; } @Override public boolean canHarvestBlock(Block par1Block) { return par1Block.blockHardness != -1; } @Override public float getStrVsBlock(ItemStack itemstack, Block block, int metadata) { NBTTagCompound nbt = itemstack.getTagCompound().getCompoundTag("Tool"); if(validPick.containsKey(block.blockMaterial)) { int pick = nbt.getInteger("PickaxeSpeed"); float end = (float) (0.001 * pick); if(end < 2F) { end+=2F; } return end; } else if(validAxe.containsKey(block.blockMaterial)) { int axe = nbt.getInteger("AxeSpeed"); float end = (float) (0.001 * axe); if(end < 2F) { end+=2F; } return end; } else if(validShovel.containsKey(block.blockMaterial)) { int shovel = nbt.getInteger("ShovelSpeed"); float end = (float) (0.001 * shovel); if(end < 2F) { end+=2F; } return end; } return 1F; } @Override @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3) { ItemStack out = createSpecialTool(par1); par3.add(out); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack par1, EntityPlayer par2, List par3, boolean par4) { NBTTagCompound nbt = par1.getTagCompound().getCompoundTag("Tool"); par3.add("Pickaxe Points: "+nbt.getInteger("PickaxeSpeed")); par3.add("Axe Points: "+nbt.getInteger("AxeSpeed")); par3.add("Shovel Points: "+nbt.getInteger("ShovelSpeed")); this.getInformation(par1, par2, par3, par4); } }
-
getStrVsBlock and setToolClass Harvest Level
Make a Arraylist with BlockMaterials or /and a Arraylist with blocks Then you only check if the arraylist contains this block/blockmaterial. Then you handle your action. Hope it helps^^"
-
Hoppers and custom furnaces [Solved]
Ahh the Vanilla Hopper code. I made a lot of new Hoppers with alot of functions i mean i made really a lot and there are about 200-300 differend hoppers in my mod. And for the extracting code i can tell you do not copy it from Vannilla Minecraft. it is useless. For that you have to copy the whole Hopper Class. I had to write my own Hopper Extracting code. Thats only a hint. . There will be Deployer Hoppers and there are still a lot planed. Speiger
-
[1.6.4] How to make "meta items" based on NBT Tags.
Feom that what i read you could create a interface that handle every case and you can store the maxDamage in every class. And the Item call the interface and call the functions you implemented. Like BC Pipes. Its a little bit advanced Programming but with that you have a modular Item.
-
ItemWorldSavedData
Do i need to register my WorldSavedData?
-
ItemWorldSavedData
I made a item and it uses already WorldSaveData to store my information. Now it works. But my problem is i forgot Something. What do i need to do that my worldSavedData gets saved? Speiger.
-
[SOLVED] Sword dynamic damage to entities (based on item damage)
you want to make it like this: damage of the sword is higher, entities get less damage. damage of the sword is lower, entities get more damage. if you want that then just make a math variable for that. And there is more than one way to make a entitybased or itembased damage. And you were right. its the HitEntity function. You can hurt entities on two ways. With the multimap function or with the hit entitiy function. You just need the entity you want to hurt/heal. i made a sword that damage 1 damage it 1 extra half heart and heals a full heart. this means it makes no damage
-
Trouble with server client sync at my Transdimensional Tiny Chest
Die7. i hope its ok that i write your name in this case (easier to write with phone) Thanks i hope with that i can shrink down a full integer to a short and make it back to a full Integer on the other side. I am still not good enought in java. But hey i am not old so i still can learn it.
-
Trouble with server client sync at my Transdimensional Tiny Chest
Hmmm good idea. A question how do i make out of a string a short that can be compiled back to a string and then to a Short again. When you tell me ideas please read the container Functions and then where they get used. Also the networkpacket (packet 105) cast the integer to a short. So i have to make a custom packet else i only stay at 32k.
-
Trouble with server client sync at my Transdimensional Tiny Chest
We are talking about a 32k integer. Its not possble to math it down and set it together at the other side without getting wrong informations! I already had another idea but that does not work too. There is only two ways! Make a custom packet for it (i tried but it was wrong and i have no clue how i can do it) Or forge change Vanilla MC in 1.7 then people limited at the 1.4&1.6
-
Trouble with server client sync at my Transdimensional Tiny Chest
thanks. I tried already. But i have another idea. I split it down into parts and put it later together.
IPS spam blocked by CleanTalk.