Jump to content

nerdboy64

Members
  • Posts

    23
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

nerdboy64's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. In case anyone else finds this thread and has a similar problem, I've found the solution. There is a method in Entity called canBeCollidedWith(), which is set by default to return false. The name is somewhat misleading, however, as it actually determines whether or not the entity will respond to interactions such as right-clicking. Overriding it to return true (see below) causes the entity to work properly. @Override public boolean canBeCollidedWith(){ return true; }
  2. EDIT: I've solved the problem now. If you have a similar problem, see my comment below. I'm trying to add a custom entity to my mod, and it's supposed to perform an action when right clicked by the player while holding a specific item. However, for some reason the game doesn't think the entity exists as far as right clicking goes. I've tried using EntityInteractEvent, which works for vanilla entities but not mine, as well as Minecraft.getMinecraft().objectMouseOver.entityHit, which has similar results. I've also tried overriding interactFirst() in my entity's class, which does absolutely nothing. The entity is an artillery cannon, and the item is a pair of binoculars which sets the target coordinates for the cannon. My two theories are that either (A) the entity's bounding box is in the wrong place or nonexistent, or (B) the entity is not registered properly so the game ignores it. Any ideas as to what could be causing this and how to fix it? EntityArtillery.java: Relevant parts of main mod class: ItemBinoculars.java: Relevant method from event handler class:
  3. I'm working on a mod that opens a GUI with a keypress and allows you to edit item names, enchantments, lore, etc. At the moment, I have created the basic GUI and added the player's inventory to it as well as the slot for the item you want to edit. It will open and display just fine, but when I try to pick up an item, it reverts back to its original slot after a fraction of a second. I've hunted around, but all the tutorials I find are outdated. I've found one other help thread on the topic, but the OP never released the code that fixed it so it wasn't any help. Anyone know how to fix this problem? Relevant code is below. I found the problem. See the edit below. My container: package mapassist; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.Slot; import net.minecraft.world.World; public class ContainerItemEdit extends Container { public InventoryPlayer inventory; public IInventory item = new InventoryBasic("Item", false, 1); World world; int x, y, z; public ContainerItemEdit(InventoryPlayer inventory, World world, int x, int y, int z){ this.inventory = inventory; this.world = world; this.x = x; this.y = y; this.z = z; addSlotToContainer(new Slot(inventory, 36, 8, 20)); bindPlayerInventory(inventory); } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return true; } protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + (i * 9) + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } Key handler class (opens the container): package mapassist; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; public class KeyHandler extends KeyBindingRegistry.KeyHandler{ private static KeyBinding[] keys = { new KeyBinding("Open Mapmaker's Assistant", 19) }; public KeyHandler() { super(keys, new boolean[keys.length]); } @Override public String getLabel() { return "Key bindings for Mapmaker's Assistant"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(tickEnd && kb.keyCode == keys[0].keyCode && Minecraft.getMinecraft().currentScreen == null && player.capabilities.isCreativeMode){ //player.addChatMessage("Congratulations! You pressed the R key!"); player.openGui(MapAssist.instance, 0, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ); } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { EnumSet<TickType> ticks = EnumSet.of(TickType.CLIENT); return ticks; } } Base mod class: package mapassist; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; @Mod(modid="mapassist", name="Mapmaker's Assistant", version="0.1.0") @NetworkMod(clientSideRequired=true, serverSideRequired=true, channels={"mapassist"}, packetHandler=PacketHandler.class) public class MapAssist { @SidedProxy(clientSide="mapassist.ProxyClient", serverSide="mapassist.ProxyCommon") public static ProxyCommon proxy; @Mod.Instance(value="mapassist") public static MapAssist instance; public static final short ITEMEDIT = 1; @EventHandler public void load(FMLInitializationEvent event){ NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler()); } } EDIT: Shortly after posting this, I figured out what the problem was. Keypresses are only registered client-side, so I just had to set up a packet handler to open the container on the server. For anyone else who wants to do the same thing, the new code is below: New key handler: package mapassist; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; public class KeyHandler extends KeyBindingRegistry.KeyHandler{ private static KeyBinding[] keys = { new KeyBinding("Open Mapmaker's Assistant", 19) }; public KeyHandler() { super(keys, new boolean[keys.length]); } @Override public String getLabel() { return "Key bindings for Mapmaker's Assistant"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(tickEnd && kb.keyCode == keys[0].keyCode && Minecraft.getMinecraft().currentScreen == null && player.capabilities.isCreativeMode){ //player.addChatMessage("Congratulations! You pressed the R key!"); player.openGui(MapAssist.instance, 0, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ); Packet250CustomPayload pkt = new Packet250CustomPayload(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream data = new DataOutputStream(bytes); try { data.writeByte(1); } catch (IOException e) { e.printStackTrace(); } pkt.channel = "mapassist"; pkt.data = bytes.toByteArray(); pkt.length = pkt.data.length; PacketDispatcher.sendPacketToServer(pkt); } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { EnumSet<TickType> ticks = EnumSet.of(TickType.CLIENT); return ticks; } } Packet handler: package mapassist; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { ByteArrayInputStream bytes = new ByteArrayInputStream(packet.data); DataInputStream data = new DataInputStream(bytes); try{ if(data.readByte() == 1){ EntityPlayer entityplayer = ((EntityPlayer)player); entityplayer.openGui(MapAssist.instance, 0, entityplayer.worldObj, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ); } } catch(IOException e){ e.printStackTrace(); } } }
  4. I tried that method, but I got an error with my @Override I'll have to give it a second look.
  5. I noticed that, when I updated to the latest version of Forge SRC, IArmorTextureProvider had been marked as deprecated. Since it still functions properly, it wasn't a pressing issue and thus I didn't post this in the support forum. I'm just wondering what the replacement will be when it, inevitably, gets removed. I'm sure it's linked to the 1.5 texture system, but I can't find any new methods or variables that suggest armor-rendering capability. Has anyone discovered the new armor rendering system yet?
  6. After more experimentation, it seems like there's a problem with EnumHelper.addArmorMaterial. Turns out that, deep in the bowels of EnumHelper, is one of many methods called addEnum. I can't even begin to understand it, but it appears to be unable to find a field called "$VALUES," which prevents it from assigning the enum and thus returns null. I updated my MCP to the latest version of Forge SRC, and I still get this problem. EDIT: I changed something--not really sure what--in EnumHelper and it works fine now.
  7. I am aware of how errors work. I did some more research, and it turns out that EnumHelper.addArmorMaterial is returning null, which rather throws a wrench into the works of the ItemArmor constructor. Unfortunately, I can't figure out what's actually wrong with my call of that method, so I still need help.
  8. AdventureKit is the mod's main class, which means that A, it has no constructor, and B, when something goes wrong with any part of the mod, it goes up the class hierarchy and eventually ends up there.
  9. I'm almost done updating one of my mods to 1.5, but I can't seem to get around one problem: armor. Eclipse doesn't give me any compiling errors, but when I run the game is crashes with a nullPointerException. Here is the error; I had to copy it from the command line since the game just gave a black screen: 2013-04-06 17:17:47 [iNFO] [sTDERR] Exception in thread "Minecraft main thread" java.lang.ExceptionInInitializerError 2013-04-06 17:17:47 [iNFO] [sTDERR] at java.lang.Class.forName0(Native Method) 2013-04-06 17:17:47 [iNFO] [sTDERR] at java.lang.Class.forName(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:446) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267) 2013-04-06 17:17:47 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) 2013-04-06 17:17:47 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267) 2013-04-06 17:17:47 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98) 2013-04-06 17:17:47 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.loadMods(Loader.java:503) 2013-04-06 17:17:47 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:160) 2013-04-06 17:17:47 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:407) 2013-04-06 17:17:47 [iNFO] [sTDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44) 2013-04-06 17:17:47 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:729) 2013-04-06 17:17:47 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source) 2013-04-06 17:17:47 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException 2013-04-06 17:17:47 [iNFO] [sTDERR] at net.minecraft.item.ItemArmor.<init>(ItemArmor.java:50) 2013-04-06 17:17:47 [iNFO] [sTDERR] at advkit.ItemHeadlamp.<init>(ItemHeadlamp.java:12) 2013-04-06 17:17:47 [iNFO] [sTDERR] at advkit.AdventureKit.<clinit>(AdventureKit.java:43) 2013-04-06 17:17:47 [iNFO] [sTDERR] ... 29 more Here is the constructor from the armor class: public ItemHeadlamp(int par1) { super(par1, AdventureKit.special, 0, 0); setCreativeTab(CreativeTabs.tabTools); } Here is the EnumArmorMaterial from my main class: public static EnumArmorMaterial special = EnumHelper.addArmorMaterial("SPECIAL", 1, new int[]{0,0,0,0}, 0); All those zeros are because I don't want it to give any protection value, but simply exist as a flag that tells the mod to make light around the player. I don't see what the problem could possibly be. If anyone has had this problem updating armor to 1.5, please tell me if you found the fix for this.
  10. I don't know how to do this with just a block, but if you're willing to have a tile entity then you can simply use the updateEntity() method to increment a timer with every tick. 20 ticks = 1 second, so it would reappear after the timer reached 100. The actual change could be handled with metadata, where 0 is normal and 1 is invisible/non-collidable.
  11. I need a way to write text to the player's HUD to make an ammo counter. Anyone know how to do this? I've seen this sort of thing asked before, but none of the threads I've seen have been answered.
  12. Actually fixed it now. It had something to do with the float values at the end of all the sound methods.
  13. In my mod, I have several custom sounds. All of them are in the same folder. When I call world.playSound(), certain sounds play and certain sounds don't. Every time I test the sounds in Eclipse, it's always the same sounds that work and don't work. I've checked the names, and those are fine. I know it's not a problem with sound files in the wrong folder because they're all in the same one as I've already stated. Sometimes, the ones that don't work show something along the lines of this in the console: 2012-08-24 14:19:46 [iNFO] [sTDOUT] Error in class 'CodecWav' 2012-08-24 14:19:46 [iNFO] [sTDOUT] url null in method 'initialize' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Error in class 'CodecWav' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Audio input stream null in method 'readAll' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Sound buffer null in method 'loadSound' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Source 'sound_7' was not created because an error occurred while loading reloadBolt.wav 2012-08-24 14:19:46 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL' 2012-08-24 14:19:46 [iNFO] [sTDOUT] Source 'sound_7' not found in method 'play' One sound actually plays the wrong sound rather than no sound at all. I've listened to all the sounds outside of the game and there is nothing wrong with them. I am using Forge build #200 in Minecraft 1.3.2 with MCP 7.2. Anyone have some insight into the problem?
  14. Upon closer inspection of afterBlockRender, I discovered that overrideBlockTexture must be -1 for it to work. Added that at the end of renderBlockGunRack and it worked.
  15. Changing to setTextureFile and removing override code for getTextureFile: Check. Lowering number of calls to getTileEntity: Check. Implementing beforeBlockRender and afterBlockRender: Check, unless I did it wrong. I just put those at the beginning and end of my renderWorldBlock() method, right? Like this: public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { ForgeHooksClient.beforeBlockRender(block, renderer); if (modelId == ClientProxySG.GunRackRenderID){ return renderBlockGunRack(block, x, y, z, renderer); } return false; } public boolean renderBlockGunRack(Block block, int i, int j, int k, RenderBlocks renderblocks){ //if(block.getRenderType() == ClientProxySG.GunRackRenderID){ Tessellator var5 = Tessellator.instance; //int var6 = block.getBlockTexture(renderblocks.blockAccess, i, j, k, 0); int var6 = 128; TileEntityNewGunRack ent = (TileEntityNewGunRack) renderblocks.blockAccess.getBlockTileEntity(i, j, k); if(ent != null) var6 = ((TileEntityNewGunRack)renderblocks.blockAccess.getBlockTileEntity(i, j, k)).texture; renderblocks.overrideBlockTexture = var6; var5.setBrightness(block.getMixedBrightnessForBlock(renderblocks.blockAccess, i, j, k)); float var7 = 1.0F; var5.setColorOpaque_F(var7, var7, var7); int var22 = (var6 & 15) << 4; int var8 = var6 & 240; double var9 = (double)((float)var22 / 256.0F); double var11 = (double)(((float)var22 + 15.99F) / 256.0F); double var13 = (double)((float)var8 / 256.0F); double var15 = (double)(((float)var8 + 15.99F) / 256.0F); int var17 = renderblocks.blockAccess.getBlockMetadata(i, j, k); double var18 = 0.0D; double var20 = 0.05000000074505806D; ForgeHooksClient.afterBlockRender(block, renderblocks); if (var17 == 5) { var5.addVertexWithUV((double)i + var20, (double)(j + 1) + var18, (double)(k + 1) + var18, var9, var13); var5.addVertexWithUV((double)i + var20, (double)(j + 0) - var18, (double)(k + 1) + var18, var9, var15); var5.addVertexWithUV((double)i + var20, (double)(j + 0) - var18, (double)(k + 0) - var18, var11, var15); var5.addVertexWithUV((double)i + var20, (double)(j + 1) + var18, (double)(k + 0) - var18, var11, var13); } if (var17 == 4) { var5.addVertexWithUV((double)(i + 1) - var20, (double)(j + 0) - var18, (double)(k + 1) + var18, var11, var15); var5.addVertexWithUV((double)(i + 1) - var20, (double)(j + 1) + var18, (double)(k + 1) + var18, var11, var13); var5.addVertexWithUV((double)(i + 1) - var20, (double)(j + 1) + var18, (double)(k + 0) - var18, var9, var13); var5.addVertexWithUV((double)(i + 1) - var20, (double)(j + 0) - var18, (double)(k + 0) - var18, var9, var15); } if (var17 == 3) { var5.addVertexWithUV((double)(i + 1) + var18, (double)(j + 0) - var18, (double)k + var20, var11, var15); var5.addVertexWithUV((double)(i + 1) + var18, (double)(j + 1) + var18, (double)k + var20, var11, var13); var5.addVertexWithUV((double)(i + 0) - var18, (double)(j + 1) + var18, (double)k + var20, var9, var13); var5.addVertexWithUV((double)(i + 0) - var18, (double)(j + 0) - var18, (double)k + var20, var9, var15); } if (var17 == 2) { var5.addVertexWithUV((double)(i + 1) + var18, (double)(j + 1) + var18, (double)(k + 1) - var20, var9, var13); var5.addVertexWithUV((double)(i + 1) + var18, (double)(j + 0) - var18, (double)(k + 1) - var20, var9, var15); var5.addVertexWithUV((double)(i + 0) - var18, (double)(j + 0) - var18, (double)(k + 1) - var20, var11, var15); var5.addVertexWithUV((double)(i + 0) - var18, (double)(j + 1) + var18, (double)(k + 1) - var20, var11, var13); } //} return true; } So far, the result is the same.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.