Everything posted by TLHPoE
-
Getting an Item from String
Dug a little deeper, found out how (I think). GameData.itemRegistry.get(name)
-
Getting an Item from String
Currently I have a GUI that sends a packet to the server with an item name, and then the server is supposed to get the item and do something. How would I get an item from just a name? I don't want to use IDs because they'll probably be removed completely I think.
-
[1.7.2] How send string via netty
If you're sending the packet from the client, the handleServer method has the player that sent it.
-
[1.6.4][SOLVED]Armor not giving player wearing it potion effects
Try adding this before doing all of that: if(!world.isRemote)
-
[1.7.2] Cannot find libraries, file structure strange in eclipse
Do gradlew --refresh-dependencies and then the usual commands.
-
Reobfuscation
Yes. Is the way I setup my workspace affecting this? I use the folder that forge installed in as the project, and I add a src folder for each mod that I have. My src folder tree looks like this: -src --Mod1 ---assets ---stuff --Mod2 ---assets ---stuff etc
-
Reobfuscation
When I do 'gradlew build', where does the reobf code go to? There's the jar in the build/libs but it only has a META-INF folder.
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
Oh my god. I did it. I had to bind the texture, and comment out code in the renderWorldBlock method.
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
I tried extending only TileEntitySpecialRenderer, and it didn't render it in the inventory. So I implemented ISimpleBlockRenderingHandler.
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
I've messed with almost everything at this point. I've tried commenting them out, rearranging them, tried extending TileEntitySpecialRenderer, and tried enabling GL_LIGHTING. Also I've looked at the Iron Chests repo, and tried duplicating cpw's way. Nothing Here's another pic of this craziness: And here's the code that causes it: package enderstorage.render; import net.minecraft.block.Block; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderstorage.tileentity.TileEntityExpEnderChest; @SideOnly(Side.CLIENT) public class TileEntityExpEnderChestRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { private final ResourceLocation texture = new ResourceLocation("enderstorage:textures/entity/expEnderChest.png");; private ModelChest model = new ModelChest(); TileEntityExpEnderChest idk = new TileEntityExpEnderChest(); public void renderTileEntityAt(TileEntityExpEnderChest tileentity, double x, double y, double z, float something) { int i = 0; if(tileentity.hasWorldObj()) { i = tileentity.getBlockMetadata(); } this.bindTexture(texture); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if(i == 2) { short1 = 180; } if(i == 3) { short1 = 0; } if(i == 4) { short1 = 90; } if(i == 5) { short1 = -90; } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = tileentity.field_145975_i + (tileentity.field_145972_a - tileentity.field_145975_i) * something; f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; model.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { renderTileEntityAt((TileEntityExpEnderChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); } @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); renderTileEntityAt(idk, 0, 0, 0, 0); GL11.glEnable(GL12.GL_RESCALE_NORMAL); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { renderTileEntityAt(world.getTileEntity(x, y, z), x, y, z, 0); return true; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return -24; } }
-
[1.6.4][SOLVED]Is it possible to activate code only for a specific player?
if(player.getDisplayName() == "TARGET") { //stuff }
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
Ok, I've got it kind of working. Only problem now is that it does this when I place it: Here's the code: package enderstorage.render; import net.minecraft.block.Block; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityEnderChestRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderstorage.tileentity.TileEntityExpEnderChest; @SideOnly(Side.CLIENT) public class TileEntityExpEnderChestRenderer extends TileEntityEnderChestRenderer implements ISimpleBlockRenderingHandler { private final ResourceLocation texture = new ResourceLocation("enderstorage:textures/entity/expEnderChest.png");; private ModelChest model = new ModelChest(); TileEntityExpEnderChest idk = new TileEntityExpEnderChest(); public void renderTileEntityAt(TileEntityExpEnderChest tileentity, double x, double y, double z, float something) { int i = 1; if(tileentity != null) { if(tileentity.hasWorldObj()) { i = tileentity.getBlockMetadata(); } } this.bindTexture(texture); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if(i == 2) { short1 = 180; } if(i == 3) { short1 = 0; } if(i == 4) { short1 = 90; } if(i == 5) { short1 = -90; } if(tileentity != null) { GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = tileentity.field_145975_i + (tileentity.field_145972_a - tileentity.field_145975_i) * something; f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; this.model.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); } this.model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { renderTileEntityAt((TileEntityExpEnderChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); } @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.idk, 0.0D, 0.0D, 0.0D, 0.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { this.renderTileEntityAt(world.getTileEntity(x, y, z), x, y, z, 0); return true; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return -24; } }
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
Ok, I've got every thing mostly working, except if I play it now, it bugs the world out. Also this: Code: package enderstorage.render; import net.minecraft.block.Block; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntityEnderChestRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderstorage.tileentity.TileEntityExpEnderChest; @SideOnly(Side.CLIENT) public class TileEntityExpEnderChestRenderer extends TileEntityEnderChestRenderer implements ISimpleBlockRenderingHandler { private final ResourceLocation texture = new ResourceLocation("enderstorage:textures/entity/expEnderChest.png");; private ModelChest model = new ModelChest(); public void renderTileEntityAt(TileEntityExpEnderChest tileentity, double x, double y, double z, float something) { int i = 1; if(tileentity != null) { if(tileentity.hasWorldObj()) { i = tileentity.getBlockMetadata(); } } this.bindTexture(texture); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if(i == 2) { short1 = 180; } if(i == 3) { short1 = 0; } if(i == 4) { short1 = 90; } if(i == 5) { short1 = -90; } if(tileentity != null) { GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = tileentity.field_145975_i + (tileentity.field_145972_a - tileentity.field_145975_i) * something; f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; this.model.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); } this.model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { renderTileEntityAt((TileEntityExpEnderChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); } @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { this.renderTileEntityAt(null, 0, 0, 0, 0); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); this.renderTileEntityAt(null, x, y, z, 0); GL11.glEnable(GL12.GL_RESCALE_NORMAL); return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return -24; } }
-
[1.6.4]Speed up in the water
player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(blah);
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
I'm using 1.7. I'll try what you suggested. Any pointers on what to do here? @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { }
-
java.lang.ClassCastException when opening GUI of custom furnace
Could you post the full crash? Post classes that are mentioned in the crash report.
-
[SOLVED]Rendering Block (that has a custom model) In Inventory
I have this custom chest that uses it's own render. It renders perfectly in the world, but it's icon is the flat obsidian texture. Block Code: package enderstorage.block; import java.util.Random; import net.minecraft.block.BlockEnderChest; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import enderstorage.EnderStorage; import enderstorage.Reference; import enderstorage.tileentity.TileEntityExpEnderChest; public class BlockExpEnderChest extends BlockEnderChest { public BlockExpEnderChest() { super(); setHardness(22.5F); setResistance(1000.0F); setStepSound(soundTypePiston); setLightLevel(0.5F); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { TileEntityExpEnderChest tileentityenderchest = (TileEntityExpEnderChest) world.getTileEntity(x, y, z); if(tileentityenderchest != null) { if(world.getBlock(x, y + 1, z).isNormalCube()) { return true; } else if(world.isRemote) { return true; } else { tileentityenderchest.func_145969_a(); player.openGui(EnderStorage.instance, Reference.EXP_ENDER_GUI_ID, world, x, y, z); return true; } } else { return true; } } @Override public int getRenderType() { return -1; } @Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(Blocks.ender_chest); } @Override public int quantityDropped(Random p_149745_1_) { return 1; } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityExpEnderChest(); } } TileEntity Code: package enderstorage.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntityEnderChest; import enderstorage.helper.BlockHelper; public class TileEntityExpEnderChest extends TileEntityEnderChest { public float field_145972_a; public float field_145975_i; public int field_145973_j; private int field_145974_k; public void updateEntity() { super.updateEntity(); if(++this.field_145974_k % 20 * 4 == 0) { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, BlockHelper.expEnderChest, 1, this.field_145973_j); } this.field_145975_i = this.field_145972_a; float f = 0.1F; double d1; if(this.field_145973_j > 0 && this.field_145972_a == 0.0F) { double d0 = (double) this.xCoord + 0.5D; d1 = (double) this.zCoord + 0.5D; this.worldObj.playSoundEffect(d0, (double) this.yCoord + 0.5D, d1, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if(this.field_145973_j == 0 && this.field_145972_a > 0.0F || this.field_145973_j > 0 && this.field_145972_a < 1.0F) { float f2 = this.field_145972_a; if(this.field_145973_j > 0) { this.field_145972_a += f; } else { this.field_145972_a -= f; } if(this.field_145972_a > 1.0F) { this.field_145972_a = 1.0F; } float f1 = 0.5F; if(this.field_145972_a < f1 && f2 >= f1) { d1 = (double) this.xCoord + 0.5D; double d2 = (double) this.zCoord + 0.5D; this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if(this.field_145972_a < 0.0F) { this.field_145972_a = 0.0F; } } } /** * Called when a client event is received with the event number and argument, see World.sendClientEvent */ public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { if(p_145842_1_ == 1) { this.field_145973_j = p_145842_2_; return true; } else { return super.receiveClientEvent(p_145842_1_, p_145842_2_); } } /** * invalidates a tile entity */ public void invalidate() { this.updateContainingBlockInfo(); super.invalidate(); } public void func_145969_a() { ++this.field_145973_j; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, BlockHelper.expEnderChest, 1, this.field_145973_j); } public void func_145970_b() { --this.field_145973_j; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, BlockHelper.expEnderChest, 1, this.field_145973_j); } public boolean func_145971_a(EntityPlayer p_145971_1_) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : p_145971_1_.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; } } Renderer Code: package enderstorage.render; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.tileentity.TileEntityEnderChestRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderstorage.tileentity.TileEntityExpEnderChest; @SideOnly(Side.CLIENT) public class TileEntityExpEnderChestRenderer extends TileEntityEnderChestRenderer { private final ResourceLocation texture = new ResourceLocation("enderstorage:textures/entity/expEnderChest.png");; private ModelChest model = new ModelChest(); public void renderTileEntityAt(TileEntityExpEnderChest tileentity, double x, double y, double z, float something) { int i = 0; if(tileentity.hasWorldObj()) { i = tileentity.getBlockMetadata(); } this.bindTexture(texture); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if(i == 2) { short1 = 180; } if(i == 3) { short1 = 0; } if(i == 4) { short1 = 90; } if(i == 5) { short1 = -90; } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = tileentity.field_145975_i + (tileentity.field_145972_a - tileentity.field_145975_i) * something; f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; this.model.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); this.model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { renderTileEntityAt((TileEntityExpEnderChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); } }
-
java.lang.ClassCastException when opening GUI of custom furnace
Code?
-
[SOLVED][1.7.2] Saving custom KeyBinding
One way you could make it a toggle is use KeyInputEvent. It's a FML event so register it in FMLCommonHandler.instance().bus() I'm not so sure what's wrong with the saving thing, I'll look into that.
-
[1.6.4]Speed up in the water
This probably isn't the most efficient way (plz dont yell at me draco/ben/someone): //Put this in a ticker if(player.isWet()) { //Set to your speed } else { //Set to default speed }
-
java.lang.ClassCastException when opening GUI of custom furnace
I found this in your TileEntity: import net.minecraft.tileentity.TileEntityFurnace; Change all references to TileEntityFurnace to your tile entity.
-
[SOLVED][1.7.2] Saving custom KeyBinding
Code for your key binding? Also you could just do: if(KeyBindingHandler.toggleInfoScreenKey.isPressed()) { //Render stuffs } You will have to tweak that so that it truly is a toggle.
-
Integer in (Persisted) NBTTagCompound Not Setting
Ok, thanks. I had that code in a LivingSpawnEvent, but I guess I did something wrong.
-
Integer in (Persisted) NBTTagCompound Not Setting
Sorry, I'm getting a bit sleepy. package enderstorage.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import enderstorage.EnderStorage; public class PacketRefreshExp extends AbstractPacket { public int exp = 0; public PacketRefreshExp setExp(int exp) { this.exp = exp; return this; } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { buffer.writeInt(exp); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { exp = buffer.readInt(); } @Override public void handleClientSide(EntityPlayer player) { EnderStorage.currentStored = exp; } @Override public void handleServerSide(EntityPlayer player) { } }
-
Integer in (Persisted) NBTTagCompound Not Setting
I'm not sending the exact packet back. This is the PacketRefreshExp code: package enderstorage.network; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import enderstorage.EnderStorage; public class PacketRequestChangeExp extends AbstractPacket { public int exp = 0; public PacketRequestChangeExp setExp(int exp) { this.exp = exp; return this; } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { buffer.writeInt(exp); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { exp = buffer.readInt(); } @Override public void handleClientSide(EntityPlayer player) { } @Override public void handleServerSide(EntityPlayer player) { NBTTagCompound nbt = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); System.err.println("Stored: " + nbt.getInteger("EnderStorageExp")); nbt.setInteger("EnderStorageExp", nbt.getInteger("EnderStorageExp") + 1); EnderStorage.packetHandler.sendTo(new PacketRefreshExp().setExp(nbt.getInteger("EnderStorageExp")), (EntityPlayerMP) player); } } As stated before, I'm not using the exp field because I'm testing with it. Additionally, it updates the client just fine.
IPS spam blocked by CleanTalk.