Jump to content

Ellbelly

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by Ellbelly

  1. Okay thanks, I think I have a better understanding now after researching those, are there certain instances that you would recommend using a capability over NBT?
  2. What is the best way to make an item that can have custom unique traits/properties assigned to it when the item is created. For example when the item spawns in the world it has arbitrary properties such as size and value. Not entirely sure how it all works with ItemStacks.
  3. EDIT: I think I need to add the feature to a biome generation. I should have seen someone posted something similar just before. EDIT 2: Welp I think I figured it out haha... almost... I believe its because diamond blocks can be placed on air whereas flowers cannot so its spawning them in the air. I'm trying to register a flower feature generation and I think I figured out how I need to register it but nothing is generating so I'm not sure if I'm doing it quite right. This is the code I'm using to register the feature and this is getting called in the constructor of my main class. ModFlowersFeature flowersFeature = new ModFlowersFeature(NoFeatureConfig::deserialize); flowersFeature.setRegistryName("mod_flowers"); ForgeRegistries.FEATURES.register(flowersFeature); And this is the flower feature and I'm using diamond blocks so that i can easily see if it works. public class ModFlowersFeature extends FlowersFeature { public ModFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> featureConfig) { super(featureConfig); } public BlockState getRandomFlower(Random random, BlockPos pos) { return Blocks.DIAMOND_BLOCK.getDefaultState(); } } If anyone knows what I'm doing wrong I would really appreciate the help.
  4. So the fluid system hasn't been ported over so this won't be achievable right now. But I guess my question still stands for the future unless it's possible that the rewrite will offer a way of doing this.
  5. I have been investigating the changes with 1.14 and have seen that you can now use intReferenceHolders in containers to really easily sync things like machine progress and energy storage across the client and server. So I am just wondering if there is any new way of easily syncing dynamic fluid tanks. Because you could obviously just sync the tanks current amount using the intReferenceHolder method if you knew it would always hold a certain type of fluid, however what about tanks that can hold any type of fluid. Is there an easy way to tell the client what type of fluid is in the tank?
  6. So when you say disable it there aren't any specific methods for doing this?
  7. Okay so is there any way to register an item only if an ore exists or should I just make a configuration option to enable and disable it?
  8. Is it bad to have an item registry event be conditional based on whether or not an ore dictionary item exists?
  9. I had changed some code before I posted the question while I was testing so I tried re-implementing my initial code and now its working flawlessly. I couldn't tell you what I'm doing differently. Sorry to bother you and thanks for the advice anyway. If I have any other issues relating to this I'll post my code.
  10. Does any one have advise on the best way to change a tile entites item calability based off it's state. For example, if I have a tile entity where it has an item handler capability and if you shift right click on a side of the block it disables the capability from that side. I have been messing around with different ways of achieving this but when I set the blocks state to not give the item capability on a certain side I have to reload the world before the connecting block updates to no longer accept items from that side. I call a block update when I change the state so I was wondering if there is anything I might be missing with the capabilities system around changing a tile entities capability? Thanks.
  11. I am trying to create a diamond powered rail everything works apart from the accelerated motion. When a redstone signal is added the rail lights up 9 blocks but the accelerated effect only works on the block directly next to the redstone signal. I have added the code at the bottom which makes the cart accelerate when it is powered and stop when it is not powered but I think it is making it only work with the rail that is next to the redstone signal. If anyone knows how to make all of the rails connected to the redstone signal accelerate the minecart I would greatly appreciate your help. In the image below I pushed a minecart from the right and with my rail it speed up and stopped right after the redstone signal but with the vanilla rail it kept going until the unpowered one which is what I want my rail to do. [/img] package com.ellybelly.netheradditions.block; import net.minecraft.block.Block; import net.minecraft.block.BlockRailBase; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import com.ellybelly.netheradditions.creativetab.CreativeTab; import com.ellybelly.netheradditions.reference.Reference; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockDiamondRailPowered extends BlockRailBase { @SideOnly(Side.CLIENT) protected IIcon icon; public BlockDiamondRailPowered() { super(true); this.setCreativeTab(CreativeTab.NETHERADDITIONS_TAB); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int j) { return (j & == 0 ? this.blockIcon : this.icon; } @Override public String getUnlocalizedName() { return String.format("tile.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconregister) { super.blockIcon = iconregister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()))); this.icon = iconregister.registerIcon("netheradditions" + ":" + this.getTextureName() + "_powered"); } protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } public float getRailMaxSpeed(World world, EntityMinecart cart, int x, int y, int z) { return 0.6f; } protected boolean func_150058_a(World world, int x, int y, int z, int i, boolean j, int k) { if (k >= { return false; } else { int j1 = i & 7; boolean flag1 = true; switch (j1) { case 0: if (j) { ++z; } else { --z; } break; case 1: if (j) { --x; } else { ++x; } break; case 2: if (j) { --x; } else { ++x; ++y; flag1 = false; } j1 = 1; break; case 3: if (j) { --x; ++y; flag1 = false; } else { ++x; } j1 = 1; break; case 4: if (j) { ++z; } else { --z; ++y; flag1 = false; } j1 = 0; break; case 5: if (j) { ++z; ++y; flag1 = false; } else { --z; } j1 = 0; } return this.func_150057_a(world, x, y, z, j, k, j1) ? true : flag1 && this.func_150057_a(world, x, y - 1, z, j, k, j1); } } protected boolean func_150057_a(World world, int x, int y, int z, boolean i, int j, int k) { Block block = world.getBlock(x, y, z); if (block == this) { int j1 = world.getBlockMetadata(x, y, z); int k1 = j1 & 7; if (k == 1 && (k1 == 0 || k1 == 4 || k1 == 5)) { return false; } if (k == 0 && (k1 == 1 || k1 == 2 || k1 == 3)) { return false; } if ((j1 & != 0) { if (world.isBlockIndirectlyGettingPowered(x, y, z)) { return true; } return this.func_150058_a(world, x, y, z, j1, i, j + 1); } } return false; } protected void func_150048_a(World world, int x, int y, int z, int i, int j, Block block) { boolean flag = world.isBlockIndirectlyGettingPowered(x, y, z); flag = flag || this.func_150058_a(world, x, y, z, i, true, 0) || this.func_150058_a(world, x, y, z, i, false, 0); boolean flag1 = false; if (flag && (i & == 0) { world.setBlockMetadataWithNotify(x, y, z, j | 8, 3); flag1 = true; } else if (!flag && (i & != 0) { world.setBlockMetadataWithNotify(x, y, z, j, 3); flag1 = true; } if (flag1) { world.notifyBlocksOfNeighborChange(x, y - 1, z, this); if (j == 2 || j == 3 || j == 4 || j == 5) { world.notifyBlocksOfNeighborChange(x, y + 1, z, this); } } } public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) { if (world.isBlockIndirectlyGettingPowered(x, y, z)) { cart.motionX *= 3.5D; cart.motionY *= 0.0D; cart.motionZ *= 3.5D; } else { cart.motionX *= 0.0D; cart.motionY *= 0.0D; cart.motionZ *= 0.0D; } } }
  12. I am trying to generate a custom nether fortress, I have the 'MapGenNetherBridge' and 'StructureNetherBridgePieces' classes but I need to register them so that structure will generate. I have found the InitMapGenEvent class in forge but I am unsure how to sure it to register my custom fortress. I am not attaching any source has it is exactly the same as the minecraft nether fortress code apart from the block used in the structure. I just need to know how to use the InitMapGenEvent to initialize the generation of the custom fortress. Thanks.
  13. Okay so yesterday I got help with adding a random tickRate to make my block change into another block now that that is working I have the problem with my block being a leaf block and the leaves need to disappear if they are not connected to a wood block, but I already am using the tickUpdate to change it into a different block and I couldn't get both of them to work but on different tickUpdates. Now I don't know if this makes any sense but I have no idea how I could fix it. This is my block (the parts I need to show) package name.mod.common.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockLeavesBase; 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.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import name.block.common.MainCLass; public class BlockModLeaves2 extends BlockLeavesBase { public BlockModLeaves2(int par1) { super(par1, Material.leaves, true); this.setCreativeTab(CreativeTabs.tabDecorations); } @Override public void onBlockAdded(World world, int x, int y, int z) { world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world)); } @Override public int tickRate(World par1World) { Random random = new Random(); return 24000+random.nextInt(6000); } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { par1World.setBlock(par2, par3, par4, Mod.Leaves.blockID); } And I need to add this to it but it cant inter-fear with my updateTick that is already in it. And it needs tick randomly set to true but that stuffs up my tickRate. public BlockModLeaves2 (int par1, boolean par2) { super(par1, Material.leaves, true); this.setTickRandomly(true); } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte b0 = 1; int j1 = b0 + 1; if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2); if (Block.blocksList[j2] != null) { Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); } } } } } } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { int l = par1World.getBlockMetadata(par2, par3, par4); if ((l & != 0 && (l & 4) == 0) { byte b0 = 4; int i1 = b0 + 1; byte b1 = 32; int j1 = b1 * b1; int k1 = b1 / 2; if (this.adjacentTreeBlocks == null) { this.adjacentTreeBlocks = new int[b1 * b1 * b1]; } int l1; if (par1World.checkChunksExist(par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1)) { int i2; int j2; int k2; for (l1 = -b0; l1 <= b0; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2); Block block = Block.blocksList[k2]; if (block != null && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; } else if (block != null && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; } else { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; } } } } for (l1 = 1; l1 <= 4; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { for (k2 = -b0; k2 <= b0; ++k2) { if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) { if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; } } } } } } } l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1]; if (l1 >= 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4); } else { this.removeLeaves(par1World, par2, par3, par4); } } } } private void removeLeaves(World par1World, int par2, int par3, int par4) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } public void beginLeavesDecay(World world, int x, int y, int z) { world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); }
  14. YES! I think it works! As far as I can see it works like a treat! Thank you so much!
  15. Yes is works but that isn't random that way we had it before was random?
  16. It then gives me this error. The method tickRate(World, Random) of type BlockMod must override or implement a supertype method
  17. It would change almost instantly even if I had it a 6000.
  18. I worked! Thank you so much for sticking around and helping me! Just another thing when you said it could be way less if it was 7 could it still be only a few seconds and it would change?
  19. There were errors when I added it this is what I have now with no errors but nothing is happening? //declare this public int tickcount; //In the Constructor this.setTickRandomly(true); //---- public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if(tickcount < 50) { tickcount++; // <--- it says insert ";" to complete BlockStatements } else { par1World.setBlock(par2, par3, par4, Mod.Block.blockID); } }
  20. I have tried that but it doesn't work they just update almost instantly and they all update at the same rate?
  21. I have set this up and it works. (I don't know if it is the right way though) public void onBlockAdded(World par1World, int par2, int par3, int par4) { par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World)); } public int tickRate(World par1World) { return 6000; } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { par1World.setBlock(par2, par3, par4, Mod.Block.blockID); } Basically after about 5 minuets I am making my block change into a different block but I don't want it to be exactly 6000 ticks for each one. I have every thing setup and it works I just want to know if I can make the block change randomly after 6000 ticks.
  22. I need this code to be around 6000 ticks plus a random 100 to 1000 ticks? Is there a way to do it or does it have to be a set amount. public int tickRate(World par1World) { return 6000; }
×
×
  • Create New...

Important Information

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