Jump to content

XVicarious

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by XVicarious

  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); } }
  16. I was just about to say I had figured that out, thanks! Edit: I seem to get a nullpointer if (event.entityPlayer.getItemInUse().getItem() instanceof ItemPickaxe ) { //ItemPickaxe itemInUsePickaxe = (ItemPickaxe)itemInUse.getItem(); ((ItemPickaxe)event.entityPlayer.getItemInUse().getItem()).efficiencyOnProperMaterial = (float) (((ItemPickaxe)event.entityPlayer.getItemInUse().getItem()).efficiencyOnProperMaterial * 3.0); System.out.printf("RUNNING"); }
  17. Right now my code is more or less: class { playerInteractEvent { if item is this { do this; } } } but how do I call it? I have an instance made in my main mod class.
  18. I was wondering how I'd detect if a player is using a pickaxe or something of the like. I know how to do it (getItemInUse()) but how would I go about detecting it. Like some kind of listener? Also I know how to use the player interact event, but how do I have it detect that?
  19. I was using an unobfuscated version. Thanks...
  20. I wrote a mod and it works in the test environment, but not on a production server. It can't find methods (I also had this problem with Enchantment.setName() and Enchantment.getName(). It works when I test it launching from eclipse, but not when I run in production. The error log is here: 2013-12-23 17:25:43 [iNFO] [sTDERR] java.lang.NoSuchMethodError: net.minecraft.nbt.NBTTagCompound.getCompoundTag(Ljava/lang/String;)Lnet/minecraft/nbt/NBTTagCompound; 2013-12-23 17:25:43 [iNFO] [sTDERR] at us.xvicario.soultether.EnchantmentSoulTether.onPlayerRespawn(EnchantmentSoulTether.java:71) 2013-12-23 17:25:43 [iNFO] [sTDERR] at cpw.mods.fml.common.registry.GameRegistry.onPlayerRespawn(GameRegistry.java:397) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.management.ServerConfigurationManager.func_72368_a(ServerConfigurationManager.java:470) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.func_72458_a(NetServerHandler.java:895) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet205ClientCommand.func_73279_a(SourceFile:30) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.network.TcpConnection.func_74428_b(TcpConnection.java:462) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:141) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:54) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.dedicated.DedicatedServerListenThread.func_71747_b(SourceFile:30) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:691) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:276) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:587) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484) 2013-12-23 17:25:43 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:583) 2013-12-23 17:25:43 [sEVERE] [Minecraft-Server] Encountered an unexpected exception NoSuchMethodError java.lang.NoSuchMethodError: net.minecraft.nbt.NBTTagCompound.getCompoundTag(Ljava/lang/String;)Lnet/minecraft/nbt/NBTTagCompound; at us.xvicario.soultether.EnchantmentSoulTether.onPlayerRespawn(EnchantmentSoulTether.java:71) at cpw.mods.fml.common.registry.GameRegistry.onPlayerRespawn(GameRegistry.java:397) at net.minecraft.server.management.ServerConfigurationManager.func_72368_a(ServerConfigurationManager.java:470) at net.minecraft.network.NetServerHandler.func_72458_a(NetServerHandler.java:895) at net.minecraft.network.packet.Packet205ClientCommand.func_73279_a(SourceFile:30) at net.minecraft.network.TcpConnection.func_74428_b(TcpConnection.java:462) at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:141) at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:54) at net.minecraft.server.dedicated.DedicatedServerListenThread.func_71747_b(SourceFile:30) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:691) at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:276) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:587) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484) at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:583) If you need more of hte log or anything ask, it is my friend who is hosting it and this is what he gave me.
  21. Is there a way that I can return if a block was destroyed by fire?
  22. So I am developing my first (well 2nd really) mod. I am adding slabs (of wool) and I got it all to work, except for the part that the slabs, the first 8 in the id are laid on the ground, and the other 8 are on the top. I have no clue what is going wrong... package us.xvicario.minecraft.EssentialStuff.common; import java.util.List; import us.xvicario.minecraft.EssentialStuff.common.mod_EssentialStuff; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockWoolSlab extends Block { private final boolean isDoubleSlab; public BlockWoolSlab(int id, boolean par2) { super(id, Material.cloth); this.isDoubleSlab = par2; setBlockName("woolSlab"); Block added = setCreativeTab(CreativeTabs.tabBlock); System.out.println(added.toString()); if (par2) { opaqueCubeLookup[id] = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(255); } public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean var5 = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0; if (var5) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } public void setBlockBoundsForItemRender() { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } public boolean isOpaqueCube() { return this.isDoubleSlab; } public int func_85104_a(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { return this.isDoubleSlab ? par9 : (par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | ; } @Override public int damageDropped(int par1) { return par1; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlab; } public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if (this.isDoubleSlab) { return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5)) { return false; } else { int var6 = par2 + Facing.offsetsXForSide[Facing.faceToSide[par5]]; int var7 = par3 + Facing.offsetsYForSide[Facing.faceToSide[par5]]; int var8 = par4 + Facing.offsetsZForSide[Facing.faceToSide[par5]]; boolean var9 = (par1IBlockAccess.getBlockMetadata(var6, var7, var8) & != 0; return var9 ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) /** * Takes a block ID, returns true if it's the same as the ID for a stone or wooden single slab. */ private static boolean isBlockSingleSlab(int par0) { return par0 == mod_EssentialStuff.woolSingleSlab.blockID; } /** * Returns the slab block name with step type. */ //public abstract String getFullSlabName(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1World, int par2, int par3, int par4) { return super.getDamageValue(par1World, par2, par3, par4) & 7; } @SideOnly(Side.CLIENT) public int idPicked(World par1World, int par2, int par3, int par4) { return isBlockSingleSlab(this.blockID) ? this.blockID : (this.blockID == mod_EssentialStuff.woolDoubleSlab.blockID ? Block.stoneSingleSlab.blockID : (this.blockID == Block.woodDoubleSlab.blockID ? Block.woodSingleSlab.blockID : Block.stoneSingleSlab.blockID)); } @Override public int getBlockTextureFromSideAndMetadata(int side, int metadata) { if (metadata == 0) { return 64; } else { metadata = ~(metadata & 15); return 113 + ((metadata & >> 3) + (metadata & 7) * 16; } } @SideOnly(Side.CLIENT) public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) { for (int ix = 0; ix < 16; ix++) { subItems.add(new ItemStack(this, 1, ix)); } } } If you need any more information, please just ask. edit: I fixed it, but I dont understand the part of the code that determines what the slab is on, If someone can explain it to me. else { boolean var5 = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0; if (var5) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } }
×
×
  • Create New...

Important Information

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