Jump to content

ModernPatriot

Forge Modder
  • Posts

    32
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Germany
  • Personal Text
    Yay?

ModernPatriot's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Tamed the TER code: https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/tileentities/ter/RendererGearBox.java Problem persists but a bit differently. It doesnt render the third item anymore, it just renders the first, one rotating clockwise and the other counterclockwise. Heres a picture: (Edit:) Did not have enough time to change the te's code, will do. (Edit^2:) Changed the te's code, issues still the same: https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/tileentities/TileEntityGearBox.java
  2. Hey! So I'm struggling with one of my tile entities, which does save and write NBT-data, but on world reload or when exiting an then joining again the NBT-tags are overridden by the te and only then read. I know my code is super-messy right now and I am going to compact it when all kinks are worked out, but for the sake of my sanity while debugging I tried to write it in a way I understand it better in case of any problems. There isnt anything helpful in the log as far as I know. The te is registered correctly and does practically write/save; just not in the right order. Second problem is with the same te's tile entity renderer in which I try to render the items in the te, depending on how many slots are used. I wanted to render the te's items rotating around the block using sine and cosine functions and it does work for 2 items, however once a third one comes into play instead of the sine translating by a third of a revolution or two-thirds of a revolution this happens: This is how it looks (and how its supposed to look) in the case of 1/2 items: Extremely messy main class: https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/ModernIndustryMain.java Block class: https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/blocks/BlockGearBox.java Tile Entity class: https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/tileentities/TileEntityGearBox.java TER class (yes, its compactable by a lot, because of current debugging i expanded it as much as possible): https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/tileentities/ter/RendererGearBox.java Container class (currently fairly unused): https://github.com/ModernPatriotCode/Modern-Industry/blob/master/src/main/java/modepat/modernindustry/container/ContainerGearBox.java
  3. So I just managed to update to the 1.8.8 version of forge. As always some things have changed and I managed to change them accordingly except three things: WorldRenderer.setBrightness() WorldRenderer.addVertexWithUV() and IUpdatePlayerListBox.update() Is IUpdatePlayerListBox completely gone and do I have to use my own TickHandler now or is there another class for this? And how exactly have addVertexWithUV and setBrightness been changed?
  4. Thank you so much Jeffrey! Its slow but it finally works. @diesieben07 Windows memory splitting is a windows 10 software "feature" which activates once you have more or exactly 16 gigs of memory. Windows basically "splits" the ram into 16 pieces and allocates the pieces accordingly. The problem is that programs which need to access more than one gig directly (like the JVM) cant run like this. Atleast not when they think that they can take more than one gig. You cant really disable it. The best bet, according to some Users on stackoverflow is to run your program as fast as possible once windows starts up, because it takes some time till it starts the splitting.
  5. I can't allocate more than 1.5 gigs because of windows memory splitting. It really sucks that you can't even disable it. It still gives the same error once I allocate more. Because the gradle.properties way didnt work I searched for a while and came up with a way how I could change the memory allocation through the system variable _JAVA_OPTIONS. It changes the memory now without any error but the whole process is now stuck at decompileMc and doesnt do anything once it reaches this step. http://s24.postimg.org/bu92eqiqt/Screenshot_1.png[/img]
  6. I personally had to use 1gb because everything else crashed. But now Im getting following crash: http://s17.postimg.org/kl2b3nftb/Screenshot_2.png[/img] Why exactly does this happen and how can I fix this?
  7. So I just wanted to update from an older to the newest recommended version, but it fails at "DecompileMC" with the error >Java Heap Space. I checked my .bat and gradle files and they are correct. I already tried to alter the memory args but daemon always gave errors back. I even created a new workspace - same error. So how would i be able to resolve that error and how could I give JVM more ram to work with?
  8. Thank you very much! Gave a good inside how to
  9. Id like to create a fairly dynamic sword, which can change its damage values, its durability values and its enchantability values dynamically, based on certain NBTTagCompounds. Normally you'd change the ToolMaterial accordingly but because I need to use the ToolMaterial inside the constructor it has to be static and cant be dynamic, at least not in the way I need it to be. So how would I have to change my code? You can find the code for the SwordTemplate here.
  10. I just updated my forge version to the newest recommended one. Everything works fine except, because I use CCC to load external mods for integration, it asks again for the mcp conf dir. Problem: The directory seems to have changed. Has anyone any idea were it has been moved to?
  11. Thank you very much for replying this quick So Ive been going a lil wild with the code and I changed a lot, but it's still not rendering. Where's my error? BasicGearbox.class (IMPORTANT BITS) @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { BasicGearboxData bgd = (BasicGearboxData)worldIn.getTileEntity(pos); if(bgd.getInventoryContent() == null) { if(playerIn.getCurrentEquippedItem() != null) { //SOMETHING IN HAND, NOTHING IN INVENTORY int meta = playerIn.getCurrentEquippedItem().getMetadata(); bgd.setInventoryContent(new ItemStack(playerIn.getCurrentEquippedItem().getItem(), 1, meta)); if(playerIn.getCurrentEquippedItem().stackSize!=0 &! playerIn.capabilities.isCreativeMode == true) { playerIn.getCurrentEquippedItem().stackSize--; } return true; }else{ // NOTHING IN HAND AND INVENTORY return false; } }else{ if(playerIn.getCurrentEquippedItem() == null) { // SOMETHING IN INVENTORY, NOTHING IN HAND ItemStack inInv = bgd.getInventoryContent(); if(!worldIn.isRemote) { worldIn.spawnEntityInWorld(new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, inInv)); // Effects worldIn.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, "random.click", 0.3F, 1.3F-(worldIn.rand.nextFloat()*0.1F)); worldIn.playSoundEffect(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, "random.orb", 0.6F, 0.6F-(worldIn.rand.nextFloat()*0.2F)); // Reset bgd.setInventoryContent(null); } return true; }else{ //SOMETHING IN INVENTORY AND HAND return false; } } }[/Code] BasicGearboxData.class (TileEntity) [Code]public class BasicGearboxData extends TileEntityBase implements IInventory { private final long INVALID_TIME = 0; private long lastTime = INVALID_TIME; private double lastAngularPosition; private String customName; private ItemStack[] inventoryContent; public BasicGearboxData() { this.inventoryContent = new ItemStack[this.getSizeInventory()]; } public String getCustomName() { return this.customName; } public void setCustomName(String customName) { this.customName = customName; } // U S E D F O R R O T A T I N G public double getNextAngularPosition(double revsPerSecond) { long timeNow = System.nanoTime(); if (lastTime == INVALID_TIME) { lastTime = timeNow; lastAngularPosition = 0.0; } final double DEGREES_PER_REV = 360.0; final double NANOSECONDS_PER_SECOND = 1e9; double nextAngularPosition = lastAngularPosition + (timeNow - lastTime) * revsPerSecond * DEGREES_PER_REV / NANOSECONDS_PER_SECOND; nextAngularPosition = nextAngularPosition % DEGREES_PER_REV; lastAngularPosition = nextAngularPosition; lastTime = timeNow; return nextAngularPosition; } @Override public String getName() { return this.hasCustomName() ? this.customName : "container.basicgearbox"; } @Override public boolean hasCustomName() { return this.customName != null && !this.customName.equals("Basic Gearbox"); } @Override public IChatComponent getDisplayName() { return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName()); } @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int index) { if (index < 0 || index >= this.getSizeInventory()) return null; return this.inventoryContent[index]; } @Override public ItemStack decrStackSize(int index, int count) { if (this.getStackInSlot(index) != null) { ItemStack itemstack; if (this.getStackInSlot(index).stackSize <= count) { itemstack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); this.markDirty(); return itemstack; } else { itemstack = this.getStackInSlot(index).splitStack(count); if (this.getStackInSlot(index).stackSize <= 0) { this.setInventorySlotContents(index, null); } else { this.setInventorySlotContents(index, this.getStackInSlot(index)); } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { if (index < 0 || index >= this.getSizeInventory()) return; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) stack.stackSize = this.getInventoryStackLimit(); if (stack != null && stack.stackSize == 0) stack = null; this.inventoryContent[index] = stack; this.markDirty(); } @Override public int getInventoryStackLimit() { return 1; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64; } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { for (int i = 0; i < this.getSizeInventory(); i++) this.setInventorySlotContents(i, null); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); NBTTagList listItems = new NBTTagList(); for (int i = 0; i < this.getSizeInventory(); ++i) { if (this.getStackInSlot(i) != null) { NBTTagCompound insideInv = new NBTTagCompound(); insideInv.setByte("Slots", (byte) i); this.getStackInSlot(i).writeToNBT(insideInv); listItems.appendTag(insideInv); } } nbt.setTag("Items", listItems); worldObj.markBlockForUpdate(getPos()); if (this.hasCustomName()) { nbt.setString("CustomName", this.getCustomName()); } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList listItems = nbt.getTagList("Items", 10); for (int i = 0; i < listItems.tagCount(); ++i) { NBTTagCompound stackTag = listItems.getCompoundTagAt(i); int slot = stackTag.getByte("Slots") & 255; this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); } if (nbt.hasKey("CustomName", ) { this.setCustomName(nbt.getString("CustomName")); } } public void writeToPacket(ByteBuf buf){ ByteBufUtils.writeItemStack(buf, inventoryContent[0]); } public void readFromPacket(ByteBuf buf) { inventoryContent[0] = ByteBufUtils.readItemStack(buf); } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } public void setInventoryContent(ItemStack newStack){ inventoryContent[0] = newStack; worldObj.markBlockForUpdate(pos); } public ItemStack getInventoryContent() { return inventoryContent[0]; } } [/Code] BasicGearboxTESR.class [Code]public BasicGearboxTESR() { } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTicks, int partialBlockDamage) { Tessellator tessellator = Tessellator.getInstance(); BlockPos posB = tileentity.getPos(); World worldIn = tileentity.getWorld(); BasicGearboxData bgd = (BasicGearboxData)worldIn.getTileEntity(posB); int meta = bgd.getInventoryContent().getMetadata(); GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); ItemStack itemstack = new ItemStack(bgd.getInventoryContent().getItem(), 1, meta); if(itemstack != null){ BlockPos pos = tileentity.getPos(); double posX = pos.getX(); double posY = pos.getY(); double posZ = pos.getZ(); GlStateManager.scale(0.9D, 0.9D, 0.9D); GL11.glTranslated(posX, posY+1, posZ); Minecraft.getMinecraft().getRenderItem().renderItemModel(itemstack); tessellator.draw(); } GL11.glPopMatrix(); } }[/Code] DescHandler.class (For redirecting Packages) [Code]@ChannelHandler.Sharable public class DescHandler extends SimpleChannelInboundHandler<FMLProxyPacket>{ public static final String CHANNEL = Reference.MODID + "Description"; static { NetworkRegistry.INSTANCE.newChannel(CHANNEL, new DescHandler()); } public static void init() { } @Override protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception { ByteBuf bufB = msg.payload(); int x = bufB.readInt(); int y = bufB.readInt(); int z = bufB.readInt(); BlockPos pos = new BlockPos(x, y, z); TileEntity te = ReimaginedIndustries.proxy.getClientPlayer().worldObj.getTileEntity(pos); if(te instanceof BasicGearboxData) { ((BasicGearboxData)te).readFromPacket(bufB); } } }[/Code] TileEntityBase.class (Writing Packets) [Code]public class TileEntityBase extends TileEntity { public Packet getDescriptionPacket() { ByteBuf bufB = Unpooled.buffer(); bufB.writeInt(pos.getX()); bufB.writeInt(pos.getY()); bufB.writeInt(pos.getZ()); writeToPacket(bufB); PacketBuffer buf = new PacketBuffer(bufB); return new FMLProxyPacket(buf, DescHandler.CHANNEL); } public void writeToPacket(ByteBuf buf) { } public void readFromPacket(ByteBuf buf) { } }[/Code] Theres a bit more code in the Proxies and Main modfile but nothing important
  12. Im trying to render the item in the inventory of my block one block above it, but it doesnt seem to work. This may be pretty obvious because Im pretty bad when it comes to the TESR. P.S.: If there are/is more errors/inefficient code please point it out. Im kinda new to 1.8 modding and the last mod I did was in 1.2.5 or so TESR Class: public class BasicGearboxTESR extends TileEntitySpecialRenderer{ public BasicGearboxTESR() { } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double z, double y, float f, int i) { Tessellator tessellator = Tessellator.getInstance(); GL11.glPushMatrix(); if(tileentity instanceof BasicGearboxData) { ItemStack itemstack = new ItemStack(((BasicGearboxData) tileentity).getStackInSlot(0).getItem()); if(itemstack != null){ BlockPos pos = tileentity.getPos(); double posX = pos.getX(); double posY = pos.getY(); double posZ = pos.getZ(); GL11.glTranslated(posX, posY+1, posZ); Minecraft.getMinecraft().getRenderItem().renderItemModel(itemstack); tessellator.draw(); GL11.glPopMatrix(); } }else{ GL11.glPopMatrix(); } } } TileEntity class public class BasicGearboxData extends TileEntity implements IInventory { private final long INVALID_TIME = 0; private long lastTime = INVALID_TIME; private double lastAngularPosition; private String customName; private ItemStack[] inventoryContent; public BasicGearboxData() { this.inventoryContent = new ItemStack[this.getSizeInventory()]; } public String getCustomName() { return this.customName; } public void setCustomName(String customName) { this.customName = customName; } // U S E D F O R R O T A T I O N public double getNextAngularPosition(double revsPerSecond) { long timeNow = System.nanoTime(); if (lastTime == INVALID_TIME) { lastTime = timeNow; lastAngularPosition = 0.0; } final double DEGREES_PER_REV = 360.0; final double NANOSECONDS_PER_SECOND = 1e9; double nextAngularPosition = lastAngularPosition + (timeNow - lastTime) * revsPerSecond * DEGREES_PER_REV / NANOSECONDS_PER_SECOND; nextAngularPosition = nextAngularPosition % DEGREES_PER_REV; lastAngularPosition = nextAngularPosition; lastTime = timeNow; return nextAngularPosition; } @Override public String getName() { return this.hasCustomName() ? this.customName : "container.basicgearbox"; } @Override public boolean hasCustomName() { return this.customName != null && !this.customName.equals("Basic Gearbox"); } @Override public IChatComponent getDisplayName() { return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName()); } @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int index) { if (index < 0 || index >= this.getSizeInventory()) return null; return this.inventoryContent[index]; } @Override public ItemStack decrStackSize(int index, int count) { if (this.getStackInSlot(index) != null) { ItemStack itemstack; if (this.getStackInSlot(index).stackSize <= count) { itemstack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); this.markDirty(); return itemstack; } else { itemstack = this.getStackInSlot(index).splitStack(count); if (this.getStackInSlot(index).stackSize <= 0) { this.setInventorySlotContents(index, null); } else { this.setInventorySlotContents(index, this.getStackInSlot(index)); } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { if (index < 0 || index >= this.getSizeInventory()) return; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) stack.stackSize = this.getInventoryStackLimit(); if (stack != null && stack.stackSize == 0) stack = null; this.inventoryContent[index] = stack; this.markDirty(); } @Override public int getInventoryStackLimit() { return 1; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64; } @Override public void openInventory(EntityPlayer player) { // Not needed (yet) } @Override public void closeInventory(EntityPlayer player) { // Not needed (yet) } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { for (int i = 0; i < this.getSizeInventory(); i++) this.setInventorySlotContents(i, null); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); NBTTagList listItems = new NBTTagList(); for (int i = 0; i < this.getSizeInventory(); ++i) { if (this.getStackInSlot(i) != null) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); this.getStackInSlot(i).writeToNBT(stackTag); listItems.appendTag(stackTag); } } nbt.setTag("Items", listItems); if (this.hasCustomName()) { nbt.setString("CustomName", this.getCustomName()); } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList listItems = nbt.getTagList("Items", 10); for (int i = 0; i < listItems.tagCount(); ++i) { NBTTagCompound stackTag = listItems.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); } if (nbt.hasKey("CustomName", ) { this.setCustomName(nbt.getString("CustomName")); } } } ClientProxy class public class ClientProxy extends CommonProxy { @Override public void registerRenders() { ReimaginedBlocks.registerRenders(); ReimaginedItems.registerRenders(); } @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); } @Override public void init(FMLInitializationEvent e) { super.init(e); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } public void registerTESR() { ClientRegistry.bindTileEntitySpecialRenderer(BasicGearboxData.class, new BasicGearboxTESR()); } @SideOnly(Side.CLIENT) public static void registerSided() { } }
  13. Im kinda having troubles with this one: So is there a way to set the texture or color of a fluid yet or is it still unsupported?
×
×
  • Create New...

Important Information

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