Everything posted by Zombiepriester
-
World crashes
- GUI-Item dragging
And this Project Red is exactly the same as Redpower(Blulectricity,Microblocks,...)- GUI-Item dragging
I use 1.4.7 because I want to use the Mod and I cant update my Minecraft because of RP2. Setting up the workspace is very simple and took me only 3 minutes.Please do it !- GUI-Item dragging
My Mod is for MC-Version 1.4.7.To use the files just put the two folders into the directory where your source-files are.- GUI-Item dragging
OK, here is the Mod: https://github.com/Zombiepriester/My_Mod/- GUI-Item dragging
Can I use Dropbox too ?- GUI-Item dragging
I dont know what a git repo is.- GUI-Item dragging
And what could be the reason that onBlockActivated is not called on Server ?- GUI-Item dragging
What is the problem, I have no Idea.Its naturaly that it dont opens when I say in if-clause:"Only open on Server", because Im playing in Singleplayer.- GUI-Item dragging
If i write: if(!par1World.isRemote){ Object tileD = (TileDisgenerator)par1World.getBlockTileEntity(x, y, z); par5EntityPlayer.openGui(OreGenerators.instance, 0, par1World, x, y, z); } Into the onBlockActivated Method, Nothing happens when I rightclicK the Block- GUI-Item dragging
- GUI-Item dragging
What can I do ?- GUI-Item dragging
The Gui dosent open- GUI-Item dragging
GuiHandler "says" CLIENT, Container-Constructer "says" CLIENT two times- GUI-Item dragging
where should I place the System.out.println and when should come a result of them ?- GUI-Item dragging
What would be the best possible result ?- GUI-Item dragging
For testing I set it to true and still it doesnt work.- GUI-Item dragging
Block: public class OreDisgenerator extends BlockContainer{ public OreDisgenerator(int id, Material Material) { super(id, 15, Material.iron); setStepSound(soundMetalFootstep); } public String getTextureFile(){ return "/modTextures/Blocks.png"; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World var1) { return new TileDisgenerator(); } @Override public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9){ Object tileD = (TileDisgenerator)par1World.getBlockTileEntity(x, y, z); par5EntityPlayer.openGui(OreGenerators.instance, 0, par1World, x, y, z); return true; } @Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { dropItems(world, x, y, z); super.breakBlock(world, x, y, z, par5, par6); } private void dropItems(World world, int x, int y, int z){ Random rand = new Random(); TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float rx = rand.nextFloat() * 0.8F + 0.1F; float ry = rand.nextFloat() * 0.8F + 0.1F; float rz = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } } } TileEntity: public class TileDisgenerator extends TileEntity implements IInventory { ItemStack[] items = new ItemStack[1]; @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int slot) { return items[slot]; } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { items[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public String getInvName() { return "Ore Disgenerator"; } @Override public int getInventoryStackLimit() { return 1; } @Override public void onInventoryChanged() { } @Override public boolean isUseableByPlayer(EntityPlayer var1) { return true; } @Override public void openChest() { } @Override public void closeChest() { } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); this.setInventorySlotContents(0, new ItemStack(tagCompound.getInteger("ItemID"), tagCompound.getInteger("StackSize"), 0)); } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setInteger("ItemID", this.getStackInSlot(0).itemID); tagCompound.setInteger("StackSize", this.getStackInSlot(0).stackSize); } } Container: public class ContainerDisgenerator extends Container{ private TileDisgenerator inv; public ContainerDisgenerator(InventoryPlayer inventory, TileDisgenerator entity) { inv = entity; addSlotToContainer(new Slot(entity, 0, 10, 29)); for (int i = 0; i < 3; i++) { for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(inventory, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventory, j, 8 + j * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer var1) { inv.isUseableByPlayer(var1); return false; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int i) { Slot slot = (Slot) getSlot(i); ItemStack itemstack1 = slot.getStack(); Slot slot1 = (Slot)this.getSlot(0); slot1.putStack(itemstack1); slot.putStack(null); return itemstack1; } } GUIHandler: public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tileEntity instanceof TileDisgenerator){ return new ContainerDisgenerator(player.inventory, (TileDisgenerator) tileEntity); } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tileEntity instanceof TileDisgenerator){ return new GUIDisgenerator(player.inventory, (TileDisgenerator) tileEntity); } return null; } } GUI: public class GUIDisgenerator extends GuiContainer{ Container DisCon; int x; int y; public GUIDisgenerator(InventoryPlayer inventory, TileDisgenerator tileD) { super(new ContainerDisgenerator(inventory,tileD)); DisCon = new ContainerDisgenerator(inventory,tileD); } protected void drawGuiContainerForegroundLayer() { fontRenderer.drawString("Ore Disgenerator", x+10, y+10, 0xffffff); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { x = (width - xSize) / 2; y = (height - ySize) / 2; int i = mc.renderEngine.getTexture("/modTextures/GUIDisgen.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(i); drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } @Override public void initGui() { super.initGui(); controlList.add(new GuiButton(1, x + (width -150)/2, y + 95, 150, 20, "Disgenerate"));//id,x,y,w,h,n } protected void actionPerformed(GuiButton guibutton) { System.out.println("geht"); } }- GUI-Item dragging
Hello, I'm programing my own Gui, this works relative good. BUT: I cant drag any Item into the Slot of my Gui, it jumps back to the Slot where it came from.How can I make this work ? Sorry for my English, I am German. - GUI-Item dragging
IPS spam blocked by CleanTalk.
Important Information
By using this site, you agree to our Terms of Use.