Jump to content

XVicarious

Members
  • Posts

    22
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

XVicarious's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. It all works after moving to forge Gradle.
  2. No, I'm using latest for 1.6.4 I believe. I'm out right now so I can confirm that when I get home in about an hour and a half.
  3. I'm not trying to obfuscate anything from CoFHCore. and the classes arent in my mod. But my classes that are derived FROM those classes aren't being obfuscated correctly.
  4. I'm basing a mod around Thermal Expansion and I extend a couple classes from CoFHCore. I don't know if it is intended or not, but classes that are derived from those CoFHCore classes (which in turn are derived from vanilla Minecraft classes (ItemBlock, and TileEntity specifically) cause odd errors where they don't obfuscate. I tried not extending the class that was the easiest to reimplement (one method) and it worked until I ran into a case where the other extended class was used (the worldObj pointer) and it turns out that class wasn't obfuscated. Is this a bug, its it intended, or did I just not set up my development environment properly? edit: I accidentally posted here instead of modder support, sorry. can a moderator move this thread please?
  5. Got it all sorted, thanks!
  6. It is running many many times.
  7. package us.xvicario.soultether.handler; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.PrintStream; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import us.xvicario.soultether.RPGLevel; import us.xvicario.soultether.TileEntityLevelUpStation; public class PacketHandler implements IPacketHandler { private EntityPlayer player; public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { this.player = ((EntityPlayer)player); if (packet.channel.equals("RPGLEVEL")) { handlePacket(packet, player); } } private void handlePacket(Packet250CustomPayload packet, Player player) { World world = this.player.worldObj; DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data)); try { int bookId = dis.readInt(); int dimension = dis.readInt(); int x = dis.readInt(); int y = dis.readInt(); int z = dis.readInt(); TileEntityLevelUpStation te = (TileEntityLevelUpStation)DimensionManager.getWorld(dimension).getBlockTileEntity(x, y, z); ItemStack levelUpBook = new ItemStack(RPGLevel.itemLevelUpBook, 1, 0); te.setInventorySlotContents(0, levelUpBook); this.player.addExperienceLevel(-20); } catch (IOException e) { System.out.println("Failed to Read Packet"); } } }
  8. It is supposed to be 20 levels. But it takes how many it feels like. Like if i have 10s of thousands it will go wild with them. Or if I have 21 it will take all 21.
  9. I got it working thanks so much! Just one thing. using player.addExperienceLevel(-20); seems to take away a much larger chunk of experienced than I'd think it would.
  10. Okay its starting to make sense. And after registering my packet handler in my @NetworkMod I should be good to go correct? I'll try this out when I get home.
  11. So I send a packet to the server, and then in the PacketHandler I have it call my tileentity.addItemStacktoSlot()? So the handler would be like: If you get an itementity in a packet, do this If you get an integer in a packet, do this EDIT: I've been looking around again and found this example: https://github.com/dvd604/Xperium/blob/master/net/dvd/xperium/server/XperiumPacketHandler.java So I have two channels, if it comes in on say "rpglevel_lus" do the stuff for the TileEntity and if it comes in on "rpglevel_xpl" do the stuff to the player. So I'd send two packets. One being a TileEntityData packet and the other being a CustomPayload and have it parse the integer data from there and apply it to the player?
  12. I figured that was the problem. I read the article on the wiki about sending packets, but still don't quite get it. Mind maybe pointing me in the right direction on how to do that? I get how to send like integers and bytes. But it doesn't really explain like how do I send an ItemStack and how does it know. Or how do I send the experience level and how do I tell it what that is? Custom packets? I don't know I feel in over my head with this one.
  13. Basically my problem is this: The server doesn't know that there is a new item in the custom GUI slot. If I try to take it, it disappears. I don't know why, or how to fix it. I've spend countless hours googling and everything and can't figure this out. Help would be greatly appreciated. GUI http://pastebin.com/QNEEK9HA GUIHandler http://pastebin.com/LduXKXsv TileEntity http://pastebin.com/UcCYqp66 Basically this: Click Button -> New Item Appears -> Try to take item -> Item Disappears! ->
  14. Okay, it is still more or less happening. I even scrapped it all and followed the tutorial from the wiki to the tee. EDIT: I know what it is. My buttons need to send the changes to the server, but how do I do that?
  15. Thanks, I ended up figuring that out. One last problem that is holding me up. I know it has something to with either sync, or nbt (or both i suppose). When I get an item out of my custom block/tileentity it does not save that item in my inventory, nor does it save the experience I take from the player (also it always seems to set it to 11 no matter how much you have). edit: also nbt does not seem to be saving LevelUpStationGUI.java package us.xvicario.rpglevel; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; public class LevelUpStationGUI extends GuiContainer { public static final ResourceLocation textureGUI = new ResourceLocation("rpglevel", "textures/gui/levelUpGui.png"); public TileEntityLevelUpStation levelUpStation; public static EntityPlayer player; public LevelUpStationGUI(EntityPlayer player,InventoryPlayer inventoryPlayer, TileEntityLevelUpStation entity) { super(new LevelUpStationContainer(player, inventoryPlayer,entity)); this.levelUpStation = entity; this.player = player; this.xSize = 176; this.ySize = 166; } public void drawGuiContainerForegroundLayer(int par1, int par2) { String name = this.levelUpStation.isInvNameLocalized() ? this.levelUpStation.getInvName() : I18n.getString(this.levelUpStation.getInvName()); this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, 4210752); this.fontRenderer.drawString(I18n.getString("container.inventory"), 8, this.ySize-96+2, 4210752); } @Override public void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1f, 1f, 1f, 1f); //int texture = mc.renderEngine.getTexture("/gui/levelUpGui.png"); //this.mc.renderEngine.bindTexture(texture); this.mc.renderEngine.bindTexture(textureGUI); this.buttonList.add(new GuiButton(0,guiLeft+8,this.ySize-112,20,20, "Mining")); this.buttonList.add(new GuiButton(1,guiLeft+8,this.ySize-90,20,20, "Attack")); this.buttonList.add(new GuiButton(2,guiLeft+30,this.ySize-112,20,20, "Defense")); this.buttonList.add(new GuiButton(3,guiLeft+30,this.ySize-90,20,20, "Archery")); //new GuiButton() drawTexturedModalRect((width-xSize)/2,(height-ySize)/2,0,0,xSize,ySize); } public void actionPerformed(GuiButton button) { if (this.player.experienceLevel >= 20) { ItemStack levelUpBook; switch(button.id) { case 0: levelUpBook = new ItemStack(RPGLevel.itemLevelUpBook,1,0); this.levelUpStation.setInventorySlotContents(0, levelUpBook); break; case 1: levelUpBook = new ItemStack(RPGLevel.itemLevelUpBook,1,1); this.levelUpStation.setInventorySlotContents(0, levelUpBook); break; case 2: levelUpBook = new ItemStack(RPGLevel.itemLevelUpBook,1,2); this.levelUpStation.setInventorySlotContents(0,levelUpBook); break; case 3: levelUpBook = new ItemStack(RPGLevel.itemLevelUpBook,1,3); this.levelUpStation.setInventorySlotContents(0, levelUpBook); break; } this.player.addExperienceLevel(-10); } } } BlockLevelUpStation.java package us.xvicario.rpglevel; import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockLevelUpStation extends BlockContainer { protected BlockLevelUpStation(int par1, Material par2Material, boolean active) { super(par1, par2Material); setCreativeTab(CreativeTabs.tabDecorations); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityLevelUpStation(); } public void onBlockAdded(World par1World,int x, int y, int z) { super.onBlockAdded(par1World, x, y, z); setDefaultDirection(par1World,x,y,z); par1World.markBlockForUpdate(x, y, z); } private void setDefaultDirection(World par1World, int x, int y, int z) { TileEntity blockEntity = par1World.getBlockTileEntity(x, y, z); if (par1World.isRemote) { return; } int i = par1World.getBlockId(x, y, z-1); int j = par1World.getBlockId(x,y,z+1); int k = par1World.getBlockId(x-1, y, z); int l = par1World.getBlockId(x+1, y, z); byte byte0 = 3; if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j]) { byte0 = 3; } if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i]) { byte0 = 2; } if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l]) { byte0 = 5; } if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k]) { byte0 = 4; } ((TileEntityLevelUpStation)blockEntity).setFrontDirection(byte0); } public boolean renderAsNormalBlock() { return true; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister icon) { this.blockIcon = icon.registerIcon("rpglevel:levelup"); } @SideOnly(Side.CLIENT) public Icon getIcon(int side, int metadata) { return this.blockIcon; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TileEntityLevelUpStation levelUpStation = (TileEntityLevelUpStation)world.getBlockTileEntity(x, z, z); FMLNetworkHandler.openGui(player, RPGLevel.instance, RPGLevel.guiID, world, x, y, z); } return true; } } LevelUpGUIHandler.java package us.xvicario.rpglevel; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; public class LevelUpGUIHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getBlockTileEntity(x, y, z); if (entity != null) { switch(ID) { case RPGLevel.guiID: if (entity instanceof TileEntityLevelUpStation) { return new LevelUpStationContainer(player, player.inventory,(TileEntityLevelUpStation) entity); } } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getBlockTileEntity(x, y, z); if (entity != null) { switch(ID) { case RPGLevel.guiID: if (entity instanceof TileEntityLevelUpStation) { return new LevelUpStationGUI(player ,player.inventory,(TileEntityLevelUpStation) entity); } } } return null; } } ClientProxy.java package us.xvicario.rpglevel.proxy; import us.xvicario.rpglevel.LevelUpStationContainer; import us.xvicario.rpglevel.TileEntityLevelUpStation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { } public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity != null) { switch(ID) { case 0: return new LevelUpStationContainer(player, player.inventory, (TileEntityLevelUpStation)tileEntity); } } return null; } } LevelUpStationContainer.java package us.xvicario.rpglevel; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class LevelUpStationContainer extends Container { private TileEntityLevelUpStation levelUpStation; public LevelUpStationContainer(EntityPlayer player, InventoryPlayer inventory, TileEntityLevelUpStation entity) { this.levelUpStation = entity; this.addSlotToContainer(new Slot(entity,0,145,35)); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { this.addSlotToContainer(new Slot(inventory,j+i*9+9,8+j*18,84+i*18)); } } for (int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(inventory,i,8+(i*18),142)); } } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return this.levelUpStation.isUseableByPlayer(entityplayer); } public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); i++) { ICrafting icrafting = (ICrafting) this.crafters.get(i); } } public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { super.slotClick(par1, par2, par3, par4EntityPlayer); return new ItemStack(Item.wheat); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); //null checks and checks if the item can be stacked (maxStackSize > 1) if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); //merges the item into player inventory since its in the tileEntity if (slot < 9) { if (!this.mergeItemStack(stackInSlot, 0, 35, true)) { return null; } } //places it into the tileEntity is possible since its in the player inventory else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } } TileEntityLevelUpStation.java package us.xvicario.rpglevel; 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; import net.minecraft.tileentity.TileEntity; public class TileEntityLevelUpStation extends TileEntity implements IInventory { public int front; private ItemStack[] levelUpItemStacks; public TileEntityLevelUpStation() { levelUpItemStacks = new ItemStack[1]; } public void setFrontDirection(int f) { this.front = f; } public int getFrontDirection() { return this.front; } @Override public int getSizeInventory() { return levelUpItemStacks.length; } @Override public void closeChest() {} @Override public ItemStack decrStackSize(int i, int j) { if (levelUpItemStacks[i] != null) { if (levelUpItemStacks[i].stackSize <= j) { ItemStack itemstack = levelUpItemStacks[i]; levelUpItemStacks[i] = null; return itemstack; } ItemStack itemstack1 = levelUpItemStacks[i].splitStack(j); if (levelUpItemStacks[i].stackSize == 0) { levelUpItemStacks[i] = null; } return itemstack1; } else { return null; } } @Override public String getInvName() { return "container.levelUp"; } @Override public int getInventoryStackLimit() { return 1; } @Override public ItemStack getStackInSlot(int i) { return levelUpItemStacks[i]; } @Override public ItemStack getStackInSlotOnClosing(int i) { if (levelUpItemStacks[i] != null) { ItemStack itemstack = levelUpItemStacks[i]; levelUpItemStacks[i] = null; return itemstack; } else { return null; } } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return false; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return false; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return entityplayer.getDistanceSq((double)xCoord+0.5D,(double)yCoord+0.5D,(double)zCoord+0.5D) <= 64D; } @Override public void openChest() {} @Override public void setInventorySlotContents(int i, ItemStack itemstack) { levelUpItemStacks[0] = itemstack; } public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items"); levelUpItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.tagAt(i); byte byte0 = nbttagcompound.getByte("Slot"); if (byte0 >= 0 && byte0 < levelUpItemStacks.length) { levelUpItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } front = par1NBTTagCompound.getInteger("FrontDirection"); } public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("FrontDirection", (int)front); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < levelUpItemStacks.length; i++) { if (levelUpItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte)i); levelUpItemStacks[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } par1NBTTagCompound.setTag("Items", nbttaglist); } }
×
×
  • Create New...

Important Information

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