TLHPoE
Members-
Posts
638 -
Joined
-
Last visited
Everything posted by TLHPoE
-
Had the same problem, TGG resolved it.
-
GameData.getBlockRegistry(); GameData.getItemRegistry();
-
Well, you asked for a canon.
-
First you'll want to get a key to write in, then you'll need to write the melody that'll be iterating through out the song. After that, you'll just need to write it down in rounds.
-
[1.7.2] Apply Vertical Motion When Jumping (Double Jumping)
TLHPoE replied to TLHPoE's topic in Modder Support
I'm checking the keyboard in a player tick event on the client. package ttm.handler.event; import org.lwjgl.input.Keyboard; import ttm.Reference; import ttm.network.PacketMessage; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; public class FMLClientEventHandler { private boolean canJump = true; @SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { if(Keyboard.getEventKey() == Keyboard.KEY_SPACE) { if(canJump && Keyboard.getEventKeyState()) { new PacketMessage(Reference.PacketMessages.JUMP).sendToServer(); canJump = false; } else if(!canJump && !Keyboard.getEventKeyState()) { canJump = true; } } } } -
[1.7.2] Apply Vertical Motion When Jumping (Double Jumping)
TLHPoE replied to TLHPoE's topic in Modder Support
Ok, the initial jump is on both sides, but it seems that motion only takes effect on the client side? I'm using packets so it's only going to be called on the server side. So should I also call it on the client side? -
[1.7.2] Apply Vertical Motion When Jumping (Double Jumping)
TLHPoE replied to TLHPoE's topic in Modder Support
I should be on server side. The code I posted would be in my LivingJumpEvent, which I cancel with my own method, and then I call the event from a packet that was sent from the client. I'll go see if it's trying to set anything in the client. -
I'm currently attempting to add double jumping, and I have everything else sorted but the actual jumping. I recently discovered the fact that you can add all the motion you want when the player is jumping, but the motion will only start to take place when he hits the ground. For example, while the player is air borne, I add 10 to motionY. It doesn't affect the player, until the player hits the ground. At that point, the player flies into the air like a rocket. Here's my code: double amt = 1; if(player.motionY < 0) { amt += (player.motionY * -1); } player.addVelocity(0, amt, 0);
-
I don't think you really need a custom item renderer to achieve this. On each render go through all of the slots (or atleast the slots you want to have the orange background), and check if they have your item. If they do, draw the orange slot.
-
Thanks everyone, TGG fixed it.
-
I'm calling the draw method during the post event of RenderGameOverlayEvent. http://pastebin.com/xQcsNvuv Here's a picture of the current situation (sorry about the craziness): Finally here's a picture of the textures: If the picture couldn't explain it, the transparent parts of the textured rectangles I'm drawing are being drawn as black areas instead of transparent areas.
-
Is there anyway to detect when an itemstack is put into and taken out of a slot? I can do both by using the putStack method in the Slot class, but doesn't get called when you just take an itemstack out of the slot. I've also tried comparing the inventory during the last tick and the inventory during the current tick. package ttm.handler.event; import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import ttm.inventory.InventoryPlayerExtended; import ttm.util.LogUtil; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; public class FMLServerEventHandler { public HashMap<String, ItemStack[]> lastInventoryMap = new HashMap<String, ItemStack[]>(); @SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { if(event.phase == Phase.START) { EntityPlayer player = event.player; InventoryPlayerExtended inventory = InventoryPlayerExtended.forPlayer(player); if(lastInventoryMap.get(player.getDisplayName()) == null) { lastInventoryMap.put(player.getDisplayName(), inventory.inventory); } else { ItemStack[] lastInventory = lastInventoryMap.get(player.getDisplayName()); ItemStack[] currentInventory = inventory.inventory; for(int i = 0; i < 5; i++) { ItemStack lastStack = lastInventory[i]; ItemStack currentStack = currentInventory[i]; if(lastStack == null && currentStack != null) { LogUtil.info("EQUIP:" + currentStack.getDisplayName()); } else if(lastStack != null && currentStack == null) { LogUtil.info("UNEQUIP:" + lastStack.getDisplayName()); } else if(lastStack != null && currentStack != null) { if(!lastStack.equals(currentStack)) { LogUtil.info("LAST:" + lastStack.getDisplayName()); LogUtil.info("CURRENT:" + currentStack.getDisplayName()); } } } lastInventoryMap.remove(player.getDisplayName()); lastInventoryMap.put(player.getDisplayName(), inventory.inventory); } } } } For some reason, it prints "EQUIP: item.blah" and then "UNEQUIP: item.blah" in the next tick. Solved: The putStack method passes the itemstack that is put into it, and the onPickupFromSlot method passes the itemstack that is taken out of it.
-
What does the operation integer in AttributeModifier represent? I'm guessing that it's a mathematical operation done to a number, but what integers represent what operation?
-
I'm not sure whether it's not saving properly or not loading properly. I can put items into the slots, but when I close and reopen, it isn't there. Inventory Class: package ttm.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; public class InventoryPlayerExtended implements IInventory { public EntityPlayer player; public ItemStack[] inventory = new ItemStack[9]; public InventoryPlayerExtended(EntityPlayer player) { this.player = player; } @Override public ItemStack decrStackSize(int par1, int par2) { ItemStack[] aitemstack = this.inventory; if(aitemstack[par1] != null) { ItemStack itemstack; if(aitemstack[par1].stackSize <= par2) { itemstack = aitemstack[par1]; aitemstack[par1] = null; return itemstack; } else { itemstack = aitemstack[par1].splitStack(par2); if(aitemstack[par1].stackSize == 0) { aitemstack[par1] = null; } return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int par1) { ItemStack[] aitemstack = this.inventory; if(aitemstack[par1] != null) { ItemStack itemstack = aitemstack[par1]; aitemstack[par1] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { inventory[par1] = par2ItemStack; } @Override public int getSizeInventory() { return this.inventory.length; } @Override public ItemStack getStackInSlot(int par1) { return inventory[par1]; } public void dropAllItems() { int i; for(i = 0; i < this.inventory.length; ++i) { if(this.inventory[i] != null) { this.player.func_146097_a(this.inventory[i], true, false); this.inventory[i] = null; } } } public void copyInventory(InventoryPlayerExtended inventory) { int i; for(i = 0; i < this.inventory.length; ++i) { this.inventory[i] = ItemStack.copyItemStack(inventory.inventory[i]); } } public NBTTagList writeToNBT(NBTTagList par1NBTTagList) { System.err.println("WRITE"); int i; NBTTagCompound nbttagcompound; for(i = 0; i < this.inventory.length; ++i) { if(this.inventory[i] != null) { nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte) (i)); this.inventory[i].writeToNBT(nbttagcompound); par1NBTTagList.appendTag(nbttagcompound); } } return par1NBTTagList; } public void readFromNBT(NBTTagList par1NBTTagList) { System.err.println("READ"); this.inventory = new ItemStack[9]; for(int i = 0; i < par1NBTTagList.tagCount(); ++i) { NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot") & 255; ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); if(itemstack != null) { if(j >= 0 && j < this.inventory.length) { this.inventory[j] = itemstack; } } } } @Override public String getInventoryName() { return "container.inventory.extended"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() { } @Override public boolean isUseableByPlayer(EntityPlayer var1) { return true; } @Override public void openInventory() { if(!player.worldObj.isRemote) { NBTTagList nbttaglist = player.getEntityData().getTagList("InventoryExtended", 10); this.readFromNBT(nbttaglist); } } @Override public void closeInventory() { if(!player.worldObj.isRemote) { NBTTagList nbttaglist = player.getEntityData().getTagList("InventoryExtended", 10); this.writeToNBT(nbttaglist); } } @Override public boolean isItemValidForSlot(int var1, ItemStack var2) { return true; } public static InventoryPlayerExtended forPlayer(EntityPlayer player) { InventoryPlayerExtended res = new InventoryPlayerExtended(player); res.openInventory(); return res; } } The prints in the read and write methods are being called correctly.
-
Ok, reflection isn't an option any more. Are there are updated tutorials for ASM?
-
I have my own Inventory class that I would like to replace the default inventory with. Is there a way with reflection to replace the type of the 'inventory' field in EntityPlayer with my class? If so, when should I be replacing it?
-
Anything?
-
Do you ever write to the NBT? If not, then that's your problem.
-
Is there a method that gets run when minecraft Loads [1.7.2.]
TLHPoE replied to CarbonBasedGhost's topic in Modder Support
If an event is located in the cpw package, you register it in the FMLCommonHandler.instance().bus(), or if it's located in the minecraftforge package, you register it MinecraftForge.EVENT_BUS. There are some exceptions, like the ore gen events which are registered in the MinecraftForge.ORE_EVENT_BUS (something along those lines). I believe that most events that have the Living prefix are to be registered in the MinecraftForge.EVENT_BUS. -
Yeah, the index is out of bounds so the list returns a null. (I think) Here's the crash log if you need it: ---- Minecraft Crash Report ---- // Sorry Time: 6/15/14 11:51 PM Description: Ticking memory connection java.lang.IndexOutOfBoundsException: Index: 49, Size: 45 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at net.minecraft.inventory.Container.slotClick(Container.java:474) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:721) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:747) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at net.minecraft.inventory.Container.slotClick(Container.java:474) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@6838d45 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:721) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:747) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 783455912 bytes (747 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 7103 (397768 bytes; 0 MB) allocated, 3693 (206808 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.03 FML v7.2.211.1124 Minecraft Forge 10.12.2.1124 4 mods loaded, 4 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.211.1124} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1124.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.2.1124} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1124.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available ttm{Indev} [Terraria to Minecraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 5800 (324800 bytes; 0 MB) allocated, 5681 (318136 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player543'/170, l='New World', x=32.50, y=75.00, z=259.50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
-
Is there a cap on how many slots a container can hold? The code should be adding about 62 slots, but the slots list has a size of 45 when it's done adding the slots. The weird part is that all of the slots are rendered, but if I try to click on one of the slots that are added after the first 45 are added, I crash with an NPE stating that the index is out of bounds. Container Class: package ttm.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import ttm.util.LogUtil; public class ContainerInventory extends Container { public IInventory inventory; public ContainerInventory() { super(); inventory = new InventoryT(); int currentSlot = 0; for(int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(inventory, currentSlot, 10 + (18 * i), 14)); currentSlot++; } for(int i = 0; i < 9; i++) { for(int l = 0; l < 6; l++) { this.addSlotToContainer(new Slot(inventory, currentSlot, 10 + (18 * i), 52 + (18 * l))); currentSlot++; } } } @Override public boolean canInteractWith(EntityPlayer var1) { return true; } }
-
I get this crash log when trying to generate my custom world type: ---- Minecraft Crash Report ---- // This doesn't make any sense! Time: 6/12/14 3:09 PM Description: Exception initializing level java.lang.NullPointerException: Exception initializing level at net.minecraft.world.biome.WorldChunkManager.findBiomePosition(WorldChunkManager.java:250) at net.minecraft.world.WorldServer.createSpawnPosition(WorldServer.java:789) at net.minecraft.world.WorldServer.initialize(WorldServer.java:770) at net.minecraft.world.World.<init>(World.java:301) at net.minecraft.world.WorldServer.<init>(WorldServer.java:103) at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63) at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:442) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.world.biome.WorldChunkManager.findBiomePosition(WorldChunkManager.java:250) at net.minecraft.world.WorldServer.createSpawnPosition(WorldServer.java:789) at net.minecraft.world.WorldServer.initialize(WorldServer.java:770) -- Affected level -- Details: Level name: New World All players: 0 total; [] Chunk stats: ServerChunkCache: 0 Drop: 0 Level seed: 6065247161752847507 Level generator: ID 04 - UNDEAD_OUTLAST, ver 0. Features enabled: true Level generator options: Level spawn location: World: (0,0,0), Chunk: (at 0,0,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 0 game time, 0 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.world.World.<init>(World.java:301) at net.minecraft.world.WorldServer.<init>(WorldServer.java:103) at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63) at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:442) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:746) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 929456488 bytes (886 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.03 FML v7.2.196.1084 Minecraft Forge 10.12.1.1084 11 mods loaded, 11 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available FML{7.2.196.1084} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1084.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Forge{10.12.1.1084} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1084.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available enderrepositories{1.2} [Ender Repositories] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available fans{1.1} [Fans] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available flappyworld{1.2} [Flappy World] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available legions{1.0} [Legions] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available realmoffera{1.0} [Realm of Fera] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available undeadoutlast{1.0} [undead Outlast] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available tlhpoeCore{1.3} [TLHPoE Core] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available tlhtweaks{1.0} [TLH Tweaks] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' WorldTypeUndeadOutlast: package undeadoutlast.world; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.world.World; import net.minecraft.world.WorldType; import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.chunk.IChunkProvider; public class WorldTypeUndeadOutlast extends WorldType { public WorldTypeUndeadOutlast() { super("UNDEAD_OUTLAST"); } @Override public WorldChunkManager getChunkManager(World world) { return new WorldChunkManagerOU(); } @Override public IChunkProvider getChunkGenerator(World world, String generatorOptions) { return new ChunkProviderOU(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()); } @Override public int getSpawnFuzz() { return 100; } @Override @SideOnly(Side.CLIENT) public boolean showWorldInfoNotice() { return true; } } WorldChunkManagerOU: package undeadoutlast.world; import java.util.List; import java.util.Random; import net.minecraft.world.ChunkPosition; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; import undeadoutlast.ServerProxy; public class WorldChunkManagerOU extends WorldChunkManager { public WorldChunkManagerOU() { super(); } } ChunkProviderOU: package undeadoutlast.world; import net.minecraft.world.World; import net.minecraft.world.gen.ChunkProviderEnd; import net.minecraft.world.gen.ChunkProviderGenerate; public class ChunkProviderOU extends ChunkProviderGenerate { public ChunkProviderOU(World par1World, long par2, boolean par3) { super(par1World, par2, par3); } }
-
Is there any other way to cover up the side bits of a gui without resorting to glScissor?
-
In your code, your beginning x position is 0, but mine starts at 298. How would I go about scaling 298?
-
Ok, how would I scale the x position though? ScaledResolutionT sr = new ScaledResolutionT(mc.gameSettings, this.width, this.height); int scale = sr.getScaleFactor(), scissorX = 298, scissorY = 20, scissorWidth = 256, scissorHeight = 438; GL11.glScissor(0, mc.displayHeight - (scissorY + scissorHeight) * scale, (scissorWidth + scissorX) * scale, scissorHeight * scale);