Jump to content

CrashHermit

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by CrashHermit

  1. @diesieben07 Thanks, that's one step down and thank you for the suggestion @jeffryfisher, optimization of the code will eventually happen. This works almost perfectly for what I am trying to do. I think the plan here is going to be get the list of current TE's by using event#world#tickableTicleEntites, store them in a hashmap and then remove all the tile entities from the event#world#tickableTicleEntites list. The problem I'm running into now is trying to figure out a way to clear the hashmap of TE's that have been removed from the world. Here is what I have so far. private static HashMap<Integer, TileEntity> storageTEs = new HashMap<Integer, TileEntity>(); @SubscribeEvent public void calendarTime(WorldTickEvent event) { if(event.phase == TickEvent.Phase.START && event.world.provider.getDimension() == 0) { List<TileEntity> allTEs = event.world.tickableTileEntities; for (int i = 0; i < allTEs.size(); i++) { TileEntity tile = allTEs.get(i); storageTEs.put(i, tile); allTEs.remove(i); } for(int i = 0; i < storageTEs.size(); i++) { TileEntity tile = storageTEs.get(i); if(rand.nextDouble() < 0.9) { System.out.println("DENY"); } else { ((ITickable) tile).update(); System.out.println("ALLOW"); } } } }
  2. Ah I see, thanks for that. I was able to get tile entities to tick by checking to see if they were an instance of ITickable, recasting them as ITickable and calling the update method on them. This does what I was intending. Here is the change in code if anyone needs it. @SubscribeEvent public void calendarTime(WorldTickEvent event) { if(event.phase == TickEvent.Phase.START && event.world.provider.getDimension() == 0) { List<TileEntity> allTEs = event.world.loadedTileEntityList; for(int i = 0; i < allTEs.size(); i++) { Block block = allTEs.get(i).getBlockType(); BlockPos pos = allTEs.get(i).getPos(); World world = allTEs.get(i).getWorld(); TileEntity tile = allTEs.get(i); for(int j = 0; j < 10; j++) { if(tile != null && !tile.isInvalid()) { if(tile instanceof ITickable) { ((ITickable) tile).update(); } } } } } } I have another question though, now I know there is a way to increase the tick rate of tile entities, is there a way to slow them down?
  3. Hello there, I'm trying to speed up the tile entity tick rates in my world by getting a list of all the loaded tile entities and using the World#scheduleBlockUpdate on them several times. The code below shows my attempt to make a block tick 10 times faster. My thinking was if I schedule a block update 10 times each tick then it would be 10 times faster, but in testing it there is no speed increase at all. Am I not understanding how world.scheduleBlockUpdate works or is it something else I am doing wrong? @SubscribeEvent public void calendarTime(WorldTickEvent event) { if(event.phase == TickEvent.Phase.START && event.world.provider.getDimension() == 0) { List<TileEntity> allTEs = event.world.loadedTileEntityList; for(int i = 0; i < allTEs.size(); i++) { Block block = allTEs.get(i).getBlockType(); BlockPos pos = allTEs.get(i).getPos(); World world = allTEs.get(i).getWorld(); for(int j = 0; j < 10; j++) { world.scheduleBlockUpdate(pos, block, j, 1); } } } }
  4. Well that is disappointing there isn't an easy way to do, thank you for the reply. I'm thinking for now maybe I should narrow the scope of my mod to just affect vanilla crops.
  5. I'm attempting to create a mod that modifies the growth rate of crops. I'm currently using the BlockCrops.Pre but that doesn't work for modded crops like Pam's Harvestcraft. So i'm attempting create a method that will look up the blocks name and schedule an update tick for that block based on various factors. An event that is similar to BlockCrops.Pre that is fired for any block update and returns the blocks position would be very helpful. Are there any events like this?
×
×
  • Create New...

Important Information

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