Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Kant0sh

Members
  • Joined

  • Last visited

Everything posted by Kant0sh

  1. I have this: @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { return oldState.getBlock() != newSate.getBlock(); } i removed the crap... this: Minecraft.getMinecraft().theWorld.markBlockForUpdate(new BlockPos(message.x, message.y, message.z)); in the onMessage run method AND EVERYTHING WORKS!!!!!!! Thanks sooo much man!
  2. 2. & 3.: so in shouldRefresh i check if the block is still there and if not return true? i thought that if(!(worldObj.getBlockState(pos).getBlock() instanceof BigCauldronBlock)){ worldObj.setTileEntity(pos, null); return; } would do it... derp 1. do you mean in onMessage? because in the TE update (the place that calls after changing the waterlevel) i did that already even with a few ticks delay...
  3. 1. I want to render a changing water level in the cauldron upon filling it with buckets. After right clicking it with a bucket, the cauldron needs a manual blockupdate, and i dont know how to do that in the code. 2. After breaking the cauldron block, it removes the block and its tileentity from the world like usual, but as soon as i place a cauldron back in the same spot, it gets the water back, the previous one had in it. 3. when placing a chest in the spot where a filled cauldron was, the chest does not render at all, but behaves normally. still, the water level is somehow retained when removing the chest and placing a cauldron back... weird, is it not? might put up some screenshots if i get good ones
  4. Rendering works fine, but needs a block update... which i cant figure out how to do because even after a few ticks of delay, the metchods google brought up dont work. also, when i break the block the TE is removed and everything is as usual, but when i replace a Cauldron in the exact same spot, its waterLevel is back...? even if there was another block there (wll air is going to be there anyway). And if i place a chest there, it does not render and the waterLevel is still maintained. I will push again if you want to have another look
  5. https://github.com/Kant0sh/MD/tree/master/src/main/java/com/kant0sh/md <-- new GitHub push Please don't be too bothered by the messy code
  6. I'm honestly sorry for bothering you for so long but i can't seem to get anywhere... I have used the getActualState method to get the data from the TE to my block, then i've sent the packet with basically the same data to the client (or as the method is called, sendToAll) and now i have gotten the data basically everywhere i could possibly work with it. Still, i don't know how to effectively "change" or "update" my BlockState so that it tells minecraft to use the correct variant specified in the blockstate json.... what ive seen by googling just said use packets and then it works, but I'm missing an essential piece of code here
  7. public void setWaterLevel(int waterLevel) { this.waterLevel = waterLevel; } I created this setter alongside with a field in the Block class. I call this function in the Runnable in onMessage, as you described in your tutorial. Now i have a section in the onBlockActivated() method where world.isRemote is true and was trying to set the blockState of the class appropriately there. is there a method to do so or how do i tell the renderengine to render another model? state = (IBlockState) getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(LEVEL, waterLevel); that is my try to use a field already in the minecraft.block.Block class.
  8. I now have the correct state over in my Block class in the client side of the onBlockActivated! but how do i get it to update from there? just setting the state variable doesn't work and the blockState field is final
  9. could you specify what i have to send to where? i haven't been able to grasp Packets completely quite yet
  10. I need help with one more thing... the blockstate now changes to the correct values and responds correctly, but the model that's rendered doesn't change. Do i have to call some kind of update manually?
  11. getActualState requires a state as parameter.. what do i put in there? sorry for the dumb question
  12. I tried to apply it via the TileEntity with the first "Oh god why"... but even if I'm not applying anything, why would it always jump to 4? I edited the write to NBT to seve 0, and after reloading the world it still was immediately changed to 4 PS: btw most of the stuff you mentioned is left over from code i tampered with previously and just trial and error.... i left in what worked
  13. I'm working on a block that faces a direction and has five levels of water... so i can't store all that in a byte of meta. I just tried to save the water level in NBT, which worked, then I changed the shouldRefresh() to return false and added a statement to remove the TE in it's update method. After I started debugging, I saw that, no matter what is saved in NBT, the water level will always be set to 4 (the max) and even when i hardcoded the TE to set the value of the water level in the blockstate to 0, it was still debugged as 4 one line later! I have no idea.... any help is greatly appreciated! Source (GitHub): https://github.com/Kant0sh/MD/blob/master/src/main/java/com/kant0sh/md/tileEntities/BigCauldronTileEntity.java --> TileEntity class https://github.com/Kant0sh/MD/blob/master/src/main/java/com/kant0sh/md/blocks/BigCauldronBlock.java --> Block class https://github.com/Kant0sh/MD/blob/master/src/main/resources/assets/md/blockstates/bigCauldron.json --> Blockstates .json Quick Source! Essential parts of TE class: if(!(worldObj.getBlockState(pos).getBlock() instanceof BigCauldronBlock)){ worldObj.setTileEntity(pos, null); return; } worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(((BigCauldronBlock) worldObj.getBlockState(pos).getBlock()).LEVEL, this.getWaterLevel())); worldObj.scheduleUpdate(pos, worldObj.getBlockState(pos).getBlock(), 0); @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { return false; } // NBT read and write public int getWaterLevel() { return waterLevel; } public void setWaterLevel(int waterLevel) { this.waterLevel = waterLevel; } public int getMaxWaterLevel() { return 4; } Essential parts of Block class: public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 4); public BigCauldronBlock() { super("bigCauldron"); setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(LEVEL, 0)); } @Override public IBlockState getStateForEntityRender(IBlockState state) { return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH).withProperty(LEVEL, 0); } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumFacing = EnumFacing.getFront(meta); if(enumFacing.getAxis() == EnumFacing.Axis.Y){ enumFacing = enumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumFacing); } @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing) state.getValue(FACING)).getIndex(); } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[]{FACING, LEVEL}); } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new BigCauldronTileEntity(); } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } Blockstate .json: { "variants": { "facing=north,level=0": { "model": "md:bigCauldronEmpty" }, "facing=north,level=1": { "model": "md:bigCauldronLevel1" }, "facing=north,level=2": { "model": "md:bigCauldronLevel2" }, "facing=north,level=3": { "model": "md:bigCauldronLevel3" }, "facing=north,level=4": { "model": "md:bigCauldronLevel4" }, "facing=south,level=0": { "model": "md:bigCauldronEmpty", "y": 180 }, "facing=south,level=1": { "model": "md:bigCauldronLevel1", "y": 180 }, "facing=south,level=2": { "model": "md:bigCauldronLevel2", "y": 180 }, "facing=south,level=3": { "model": "md:bigCauldronLevel3", "y": 180 }, "facing=south,level=4": { "model": "md:bigCauldronLevel4", "y": 180 }, "facing=west,level=0": { "model": "md:bigCauldronEmpty", "y": 270 }, "facing=west,level=1": { "model": "md:bigCauldronLevel1", "y": 270 }, "facing=west,level=2": { "model": "md:bigCauldronLevel2", "y": 270 }, "facing=west,level=3": { "model": "md:bigCauldronLevel3", "y": 270 }, "facing=west,level=4": { "model": "md:bigCauldronLevel4", "y": 270 }, "facing=east,level=0": { "model": "md:bigCauldronEmpty", "y": 90 }, "facing=east,level=1": { "model": "md:bigCauldronLevel1", "y": 90 }, "facing=east,level=2": { "model": "md:bigCauldronLevel2", "y": 90 }, "facing=east,level=3": { "model": "md:bigCauldronLevel3", "y": 90 }, "facing=east,level=4": { "model": "md:bigCauldronLevel4", "y": 90 } } }
  14. Thanks for your help, but i just got it to work the way i wanted it to looked at the code of pahimar's ee3 and sorted out that the int parameter passed to the getColor method is the renderPass.... so all done now
  15. In my opinion, gradle does a great job at exceptions... you can almost always do what it says on screen so i would try running "gradlew setupDecompWorkspace --stacktrace" for more info and post the new error to pastebin again. What this tells you is essentially that a file that was downloaded either cancelled or just broke while transmitting... Edit: PS: i had that very same error too and just waited a bit... frustrating to not be able to code, but it worked then
  16. I want to create an item that has a very specific part colored by code, a bit like dyed leather armor, using a greyscale texture for coloring in, and an overlay with permanent colors. I got the basic multilayering done using two render passes, but the coloring is off when the item is held in the players hand, 3rd and 1st person... it's basically the wrong way around any advice would be much appreciated! Thanks Screenshot : http://i.imgur.com/sYUfUsB.png Item class : package mod3DPrinter.item; import mod3DPrinter.mod.Mod3DPrinter; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class FilamentItem extends DefaultItem { private IIcon[] icons; private String regname; private int color; private int c; public FilamentItem(String regname) { super(Mod3DPrinter.printerTab); this.regname = regname; this.color = 0xffffff; this.c = 0; } @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { return color; } @Override @SideOnly(Side.CLIENT) public boolean requiresMultipleRenderPasses() { return true; } @Override public int getRenderPasses(int meta){ return 2; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { icons = new IIcon[2]; icons[0] = iconRegister.registerIcon(Mod3DPrinter.MODID + ":" + regname); icons[1] = iconRegister.registerIcon(Mod3DPrinter.MODID + ":" + regname + "_overlay"); } @Override public IIcon getIcon(ItemStack itemStack, int renderPass) { if(renderPass == 0){ color = 0xff0000; }else{ color = 0xffffff; } return icons[renderPass]; } }
  17. Thank you so much! I love you now I finally have it! been working on it for like 5 days now... many thanks
  18. Bump.... if you want to you can also leave me a suggestion on a different approach, I totally would ditch what I have
  19. I'm working on the GUI functionality of my block for 4 days now, and I still cant pull it off about time to ask for some help... I'm trying to display a simple progress bar, and i pulled it off for singleplayer, not using messages, just using the getClient().getServer() function to get the serverside TileEntity, but this doesn't work for multiplayer unfortunately... So now, I'm sending a message containing a string (because sending too many things at once had me get an IndexOutOfBounds) in which i carry all the data required... the string gets created by the getEncodedMessageAsString() method in the PrinterTileEntity class, and gets passed into the constructor in the sendToAllAround() method which gets called in updateEntity(). Here comes the problem: The message that is received only contains the string i set as field, so if i did "String string;", i got a NullPointer, and if i did "String string = "";" i got an empty string variable through if you want to look at the code, and the issue i have up for three days, here is the links: GitHub: https://github.com/Kant0sh/threedeeprinter Issue: https://github.com/Kant0sh/threedeeprinter/issues/1 PrinterTileEntity.java: https://github.com/Kant0sh/threedeeprinter/blob/master/main/threedeeprinter/mod3DPrinter/tileEntity/PrinterTileEntity.java Message and MessageHandler in this package: https://github.com/Kant0sh/threedeeprinter/tree/master/main/threedeeprinter/mod3DPrinter/network/message Help would be much appreciated Edit: also, if you have GitHub, feel free to comment on the issue
  20. I recently looked at the TileEntityFurnace class of Vanilla Minecraft, and they used something like if(hammerItemStack.stackSize >= 0){ hammerItemStack = null; } I'm not sure and haven't tested it, but it might solve the issue with the ItemStack with size 0.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.