Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

CriscoMods

Members
  • Posts

    10
  • Joined

  • Last visited

Recent Profile Visitors

501 profile views

CriscoMods's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Good Idea. Works Ended up doing this if (this.InitializeBlocks) { if (this.isMaster) {this.setMaster(); } this.lazyQuery(); this.updateMasterBlockList(); } IntializeBlocks is set to true upon initialization, but to prevent this piece of code from running in a tick when the block is placed for the first time I set it to false . The flag is also set false in function updateMasterBlockList @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { EngineeringBlockTileEntity thisBlock = ((EngineeringBlockTileEntity) worldIn.getTileEntity(pos)); if (stack.hasDisplayName()) { TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof EngineeringBlockTileEntity) { thisBlock.setCustomName(stack.getDisplayName()); } } //don't initialize blocks upon placement thisBlock.InitializeBlocks = false; if (thisBlock.isAlone()) { thisBlock.setMaster(); System.out.println(thisBlock.isMaster);} super.onBlockPlacedBy(worldIn, pos, state, placer, stack); }
  2. Okay so I've simplified my connections a great deal. I've Overrided neighborChange. As blocks are added I pass a "masterEntity" to each block so that everyone is capable of updating this multiBlock blockCount to the masterEntity. Instead of having a list of tileEntities I opted for a list of BlockPos like you mentioned. As I'm writing this I realize I can pass a blockCount to each block instead meaning that I could maybe remove the blockPos list (still not sure what I will do). Then I can use the NBT system to store the block count. @Override public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor){ if (world.getTileEntity(neighbor) instanceof EngineeringBlockTileEntity) { //pass master from this block to the next EngineeringBlockTileEntity neighborEntity = (EngineeringBlockTileEntity) world.getTileEntity(neighbor); EngineeringBlockTileEntity thisEntity = (EngineeringBlockTileEntity)world.getTileEntity(pos); neighborEntity.masterEntity = thisEntity.masterEntity; //add neighbor block position to list of master list if (!thisEntity.masterEntity.connectedBlocks.contains(neighbor)) { neighborEntity.masterEntity.connectedBlocks.add(neighbor); } //update blockCount neighborEntity.masterEntity.blockCount = neighborEntity.masterEntity.connectedBlocks.size(); System.out.println(neighborEntity.masterEntity.blockCount); } } Then for removing blocks from the list I used remove() as you suggested and woah simple as heck @Override public void remove() { if (this.masterEntity != null) { this.masterEntity.connectedBlocks.remove(this.getPos()); } super.remove(); } I may not have completly understood and implemented a lazy query as you suggested but I was able to get this to work using less code because of your suggestion. I'm still trying to figure out how to have the block query around them upon reloading of a world. Thank you for your help it is much appreciated.
  3. //saving all tile entities List<CompoundNBT> connectedEntities = new ArrayList<>(); CompoundNBT entity; for (int entityInList = 0; entityInList <= this.masterEntity.connectedEntities.size();entityInList++) { entity = new CompoundNBT(); entity.putInt("x",this.masterEntity.connectedEntities.get(entityInList).pos.getX()); entity.putInt("y",this.masterEntity.connectedEntities.get(entityInList).pos.getY()); entity.putInt("z",this.masterEntity.connectedEntities.get(entityInList).pos.getZ()); connectedEntities.add(entity); } compound.put("connectedEntities", (INBT) connectedEntities); //restore saved entities List<CompoundNBT> connectedEntities = (List<CompoundNBT>) compound.get("connectedEntities"); CompoundNBT entity; if (connectedEntities!= null){ for (int entityInList = 0; entityInList < connectedEntities.size();entityInList++ ) { entity = connectedEntities.get(entityInList); this.masterEntity.connectedEntities.add((EngineeringBlockTileEntity)this.world.getTileEntity(new BlockPos(entity.getInt("x"),entity.getInt("y"),entity.getInt("z")))); }} So I'm trying to save list of TileEntities to a block, because the block uses the list to determine the number of blocks connected to each other. As the blocks are being placed the list expands. If I exit the world and comeback I cannot remove blocks that have already been placed. It crashes when it attempts to remove that block from the connectedEntities list because the list is empty. I'm trying to save it using the code above but it's not working. I just need some to be point me in the right direction. @Override public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { EngineeringBlockTileEntity entityRemoved = (EngineeringBlockTileEntity) worldIn.getTileEntity(pos); entityRemoved.masterEntity.connectedEntities.remove(entityRemoved); entityRemoved.masterEntity.blockCount = entityRemoved.masterEntity.connectedEntities.size(); super.onBlockHarvested(worldIn, pos, state, player); }
  4. Creating your own recipe type involves some amount of code. Not too much. I've been able to scrape up a lot of stuff off the web and figure out how to create multiple recipe types. Big thanks to turtywurty and his source code here https://github.com/DaRealTurtyWurty/1.15-Tut-Mod for your first machine you'll need to create 4 new classes for the custom recipe type. [1] IMachineNameRecipe.java [2] MachienNameRecipe.java [3] MachineNameSerializer.java and the most important [4] RecipeSerializerInit.java I say this is the most important because it is here in this file that you register your new recipe types for your different machines. You could essentially copy and paste this code and replace the machine names with the what ever your machine class is and it should work. Just pay special attention to IMillRecipe (IMachineNameRecipe), because you define a path to your recipe json files here. I have it set to mill_recipes so in my directory I see src/main/resources/data/MODID/recipes/mill_recipes and the same goes for file RecipeSerializerInit. Under the comment Machine Serializers you'll be able to see a bunch of other machines with their defined paths being defined as they're being registered. Last but not least, you have to be able to tell your tile entity where to go look for these recipes so I've attached a copy of my Mill TileEntity so you can see what functions it calls when it crushes items. *hint look at the tick function This is the best I can explain it. Good Luck IMillRecipe.java MillRecipe.java MillRecipeSerializer.java MillTileEntity.java RecipeSerializerInit.java
  5. oh... makes a bunch of sense. I'll do better next time I post thanks
  6. new to the site. Posting the image as text was easier to me. I see the full image on my side. Do you not see it as an image? Also do you know what Illegal forge reposting is? I accidentally shared a link to a site doing it on here and had no idea it was bad.
  7. FIGURED IT OUT Apparently you have to override the canHarvestBlock function and have it return true. After doing this I was able to harvest the blocks I was breaking.
  8. I'm trying to create my own custom tool class. I'm trying to avoid Registering objects as a pickaxe item, because I want to use the effective_on feature to be able to create a pickaxe that breaks dirt, cobblestone, wood, etc.. So I created my own class, Sledge Hammer, that extends ToolItem Then I create my tool Item by registering it as a new Instance of the class I just created. \ I pass an IItemTier, SLEDGE_HAMMER, which has a harvest level of 3. When I test this, the item shows up as it should, but when I break blocks with a harvest level of 2 or greater I do not receive the drop. I do receive the drop for blocks with harvest level 1. It does all this despite the IItemTier being defined with a harvest level of 3. Obviously I'm doing something wrong and I don't know what at this point. If anyone can point in me in the right direction that would be great. *What's even weirder is that the attackDamage and maxUses works as I defined it.
  9. There is actually a read function it just isn't named. read(@Nonnull CompoundNBT nbt) → func_230337_a_(BlockState p_230337_1_, CompoundNBT nbt) When you override the function let your IDE complete it for you. It will define the BlockState is an input that you will have to use. I was able to find this list of functions through this website. You will need to know what they are named when you start creating your GUIs. [removed link to website with illegal forge rehosting - diesieben07]
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.