
thebest108
Members-
Posts
503 -
Joined
-
Last visited
Everything posted by thebest108
-
Alright so I recently tested my algorithm for moving 5000 blocks from one world to another, sadly its very slow So I profiled it for "Hot Spots" and found some interesting results, (My flood fill algorithm took 0% cpu time so it's not that) the things causing the lag seem to be basic functions that Minecraft does by default when placing and breaking blocks. Here's the breakdown of the biggest offenders: net.minecraft.world.storage.ThreadedFileIOBase.processQueue() (20.1%) paulscode.sound.SimpleThread.snooze() (19.6%) net.minecraft.server.MinecraftServer.run() (19.1%) net.minecraft.client.Minecraft.addScheduledTask() (18.7%) net.minecraft.world.World.getChunkFromChunkCoords() (7.9%) FlyingFortress.Entities.Ship.updateMinMax() (4.9%) FlyingFortress.Region.WorldUtils.RegionChunkProvider.provideChunk() (2.2%) It seems that most of the time is spent by the saving thread, but I'm not sure why Anyway let me give the code of mine that could also be causing the lag Starting with the makeWorld() method which I use to move the blocks from one world to another: int x = (int)(posX); int y = (int)posY; int z = (int)(posZ); BlockPos start = new BlockPos(x,y,z); SpatialDetector attatchedBlocks = new SpatialDetector(start, worldObj, 5000,true); ArrayList<BlockPos> detectedBlockPos = new ArrayList<BlockPos>(attatchedBlocks.foundSet.size()+1); boolean forcedStop = false; TIntIterator intIter = attatchedBlocks.foundSet.iterator(); while(intIter.hasNext()&&!forcedStop){ int hash = (Integer) intIter.next(); BlockPos fromHash = attatchedBlocks.getPosWithRespectTo(hash, start); if(fromHash.getY()+128-y<0){ forcedStop = true; } detectedBlockPos.add(fromHash); } if(forcedStop){ detectedBlockPos.clear(); } for(BlockPos global:detectedBlockPos){ IBlockState state = worldObj.getBlockState(global); BlockPos pos = global.add(-x,128-y,-z); region.setBlockState(pos, state,0); } ((ShipRegionServer)region).isNew=false; for(BlockPos global:detectedBlockPos){ NextTickListEntry scheduledUpdate; BlockPos local = global.add(-x,128-y,-z); //region.scheduleUpdate(new BlockPos(bs.x-x,bs.y+128-y,bs.z-z), region.getBlockState(new BlockPos(bs.x-x,bs.y+128-y,bs.z-z)).getBlock(), 0); Iterator tickListIter = ((WorldServer)worldObj).pendingTickListEntriesHashSet.iterator(); while(tickListIter.hasNext()){ scheduledUpdate = (NextTickListEntry)tickListIter.next(); if(scheduledUpdate.position.equals(global)){ region.scheduleUpdate(local, region.getBlockState(local).getBlock(), scheduledUpdate.priority); } } } for(BlockPos pos:detectedBlockPos){ BlockPos local = pos.add(-x,128-y,-z); TileEntity tile = worldObj.getTileEntity(pos); if(tile!=null){ if(tile instanceof IInventory){ IInventory inventory = ((IInventory)tile); TileEntity inRegion = region.getTileEntity(local); for(int i=0;i<inventory.getSizeInventory();i++){ ((IInventory)inRegion).setInventorySlotContents(i, inventory.getStackInSlot(i)); } inventory.clear(); } worldObj.getTileEntity(pos).invalidate(); } } for(BlockPos global:detectedBlockPos){ worldObj.setBlockState(global, Blocks.planks.getDefaultState(),; } for(BlockPos global:detectedBlockPos){ worldObj.setBlockState(global, Blocks.air.getDefaultState(), 3); } And the updateMinMax() method, I need it to keep track of the min/max xyz values of the current world private void updateMinMax(){ if(blockPositions.isEmpty()){ minX=0;minY=0;minZ=0;maxX=0;maxY=0;maxZ=0; return; } RegionChunkProvider provider = (RegionChunkProvider) region.getChunkProvider(); boolean good = false; for(BlockPos pos:blockPositions){ if(!good){ minX=pos.getX();minY=pos.getY();minZ=pos.getZ();maxX=pos.getX();maxY=pos.getY();maxZ=pos.getZ(); good = true; } if(!chunksInUse.contains(IntegerChunkCoordIntPair.toKeyFromPos(pos))){ int xCor = pos.getX()>>4; int zCor = pos.getZ()>>4; provider.addChunk(IntegerChunkCoordIntPair.toKeyFromPos(pos)); chunksInUse.add(IntegerChunkCoordIntPair.toKeyFromPos(pos)); if(!worldObj.isRemote){ ShipRegionServer server = (ShipRegionServer) region; server.chunkQueues.put(IntegerChunkCoordIntPair.toKeyFromPos(pos), new ArrayList<BlockPos>()); } } if(pos.getX()<minX){ minX = pos.getX(); } if(pos.getX()>maxX){ maxX = pos.getX(); } if(pos.getY()<minY){ minY = pos.getY(); } if(pos.getY()>maxY){ maxY = pos.getY(); } if(pos.getZ()<minZ){ minZ = pos.getZ(); } if(pos.getZ()>maxZ){ maxZ = pos.getZ(); } } } Any tips for getting past this terrible lag spike?
-
The ultimate Ships mod! With full world compatibility, a robust collision system, dynamic lighting and now physics! This mod aims to be what every other Ship mod isn't... finished. Latest Video: (Ships hitting the ground) [embed=425,349]<iframe width="560" height="315" src="https://www.youtube.com/embed/WTWAMOpxVVY" frameborder="0" allowfullscreen></iframe>[/embed]
-
The blockstates file for my block "RedstoneEngine" doesnt work, even though it uses the same model file as a block that does work. The only difference between these two blocks is that "RedstoneEngine" has a propertyDirection and the other block has no properties. Here's the broken blockstates for "RedstoneEngine" { "variants": { "facing=down": { "model": "flyingfortress:shitblock", "x": 90 }, "facing=up": { "model": "flyingfortress:shitblock", "x": 270 }, "facing=north": { "model": "flyingfortress:shitblock" }, "facing=south": { "model": "flyingfortress:shitblock", "y": 180 }, "facing=west": { "model": "flyingfortress:shitblock", "y": 270 }, "facing=east": { "model": "flyingfortress:shitblock", "y": 90 }, } } And here's the working blockstates for "shitBlock" { "variants": { "normal": { "model": "flyingfortress:shitblock" } } } Am I missing something obvious?
-
The log isn't really helping either Code: ResourceLocation loc = new ResourceLocation(FlyingFortressBase.MODID, "Cannon.obj"); try { IModel model = OBJLoader.instance.loadModel(loc); } catch (IOException e) { e.printStackTrace(); } Log: java.lang.NullPointerException: Rendering entity in world at net.minecraftforge.client.model.obj.OBJModel$Material.access$100(OBJModel.java:631) at net.minecraftforge.client.model.obj.OBJModel$Parser.parse(OBJModel.java:352) at net.minecraftforge.client.model.obj.OBJLoader.loadModel(OBJLoader.java:72) at FlyingFortress.Client.RenderBastard.RenderCannon.renderHead(RenderCannon.java:57) at FlyingFortress.Client.RenderBastard.RenderCannon.doRender(RenderCannon.java:42) at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:381) at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:338) at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:305) at FlyingFortress.Client.RenderBastard.CustomRenderGlobal.renderEntities(CustomRenderGlobal.java:618) at FlyingFortress.Client.RenderBastard.CustomEntityRenderer.renderWorldPass(CustomEntityRenderer.java:145) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1266) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1091) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
-
Entity teleports upwards whenever something collides with it
thebest108 replied to Asweez's topic in Modder Support
The problematic method is Entity.func_180426_a(), which is called whenever the entity receives a position packet from the server. By default that method moves entities up if they're colliding with something, just override the method so it doesnt do that. -
world.setBlockState() setting the wrong state?
thebest108 replied to thebest108's topic in Modder Support
No this is for simulating gas spread inside of blimp balloons. If there really isnt a way to store more than 16 states then I'll just program my own storage system. -
world.setBlockState() setting the wrong state?
thebest108 replied to thebest108's topic in Modder Support
oh >.< Well in that case how can I make a blockstate that holds more than 16 possibilities? -
Im not sure what's going on here, I set the blockState for a position and it doesn't change the state. worldObj.setBlockState() returns true though, so it should be going through. int heat = nextHeatValues.get(pos); if(heat>40){ IBlockState temp = FlyingFortressBase.hotAir.getStateFromMeta(heat); worldObj.setBlockState(pos, temp); System.out.print("Ideal:"+heat+" : Actual:"+FlyingFortressBase.hotAir.getMetaFromState(worldObj.getBlockState(pos))); }else{ worldObj.setBlockToAir(pos); } And my BlockHotAir code public class BlockHotAir extends Block{ public static final PropertyInteger heatValue = PropertyInteger.create("heatValue", 0, 1024); public BlockHotAir(Material materialIn) { super(materialIn); } @Override public void updateTick(World worldIn,BlockPos pos,IBlockState state,Random rand){ } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state){ } @Override public int tickRate(World worldIn){ return 1; } @Override public String getHarvestTool(IBlockState state){ return null; } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] {heatValue}); } @Override public IBlockState getStateFromMeta(int meta){ return getDefaultState().withProperty(heatValue, meta); } @Override public int getMetaFromState(IBlockState state){ int i = (Integer) state.getValue(heatValue); return i; } } The getStateFromMeta and getMetaFromState are working properly, yet the values on IBlockState temp = FlyingFortressBase.hotAir.getStateFromMeta(heat); worldObj.setBlockState(pos, temp); System.out.print("Ideal:"+heat+"Actual:"+FlyingFortressBase.hotAir.getMetaFromState(worldObj.getBlockState(pos))) don't match. I have no idea how to get around the game not setting the blockstate properly D: Also I've tried doing worldObj.setBlockToAir(pos) and then setting the state, and it's still wrong
-
[1.7.10] Easy way to test a Chunk Provider?
thebest108 replied to yoshiquest's topic in Modder Support
Yes that is entirely possible. I currently use a version that allows me to have worlds with around 10 chunks each and no more than that. My chunk provider allows me to bypass world generation and create worlds that are empty by default. Using a bit of ASM you can add this to a World constructor: chunkProvider = new RegionChunkProvider(this); This is the code I use: (Note that I convert the chunkIntPair's into Integers and store them in a Hashset in the Ship class, those integers access the Chunks using a HashMap<Integer,Chunk>) package FlyingFortress.Region.WorldUtils; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.List; import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.BlockPos; import net.minecraft.util.IProgressUpdate; import net.minecraft.world.MinecraftException; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.storage.AnvilChunkLoader; import FlyingFortress.Entities.Ship; import FlyingFortress.Region.ShipRegionServer; public class RegionChunkProvider implements IChunkProvider{ public EmptyChunk fakechunk; public HashMap<Integer,Chunk> hashToChunk = new HashMap<Integer,Chunk>(); public Ship parent; public World region; //Custom chunk storage System used by the Ship Regions public RegionChunkProvider(Ship ship,World worldIn){ parent = ship; region = worldIn; fakechunk = new EmptyChunk(region, 0, 0); for(int i:ship.chunksInUse){ IntegerChunkCoordIntPair pair = new IntegerChunkCoordIntPair(i); hashToChunk.put(i, new Chunk(region,pair.chunkXPos,pair.chunkZPos)); } } public void addChunk(int key){ IntegerChunkCoordIntPair pair = new IntegerChunkCoordIntPair(key); hashToChunk.put(key, new Chunk(region,pair.chunkXPos,pair.chunkZPos)); } public void removeChunk(int key){ hashToChunk.remove(key); IntegerChunkCoordIntPair pair = new IntegerChunkCoordIntPair(key); if(region instanceof ShipRegionServer){ AnvilChunkLoader loader = new AnvilChunkLoader(parent.getWorldDirectory()); try { loader.saveChunk(region, new EmptyChunk(region, pair.chunkXPos, pair.chunkZPos)); } catch (MinecraftException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } public void setChunk(int key, Chunk chunk){ hashToChunk.remove(key); hashToChunk.put(key, chunk); } @Override public boolean chunkExists(int x, int z) { int hash = IntegerChunkCoordIntPair.toKey(x, z); return hashToChunk.containsKey(hash); } @Override public Chunk provideChunk(int x, int z) { int hash = IntegerChunkCoordIntPair.toKey(x, z); Chunk chunk; if(hashToChunk.containsKey(hash)){ chunk= hashToChunk.get(hash); }else{ chunk= fakechunk; } return chunk; } @Override public Chunk provideChunk(BlockPos blockPosIn) { return provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4); } @Override public void populate(IChunkProvider p_73153_1_, int p_73153_2_,int p_73153_3_) {} @Override public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { return false; } @Override public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) { AnvilChunkLoader loader = new AnvilChunkLoader(parent.getWorldDirectory()); HashSet<Integer> chunksCopy = (HashSet<Integer>)parent.chunksInUse.clone(); HashMap<Integer,Chunk> hashToChunkCopy = (HashMap<Integer, Chunk>) hashToChunk.clone(); for(int i:chunksCopy){ Chunk chunk = hashToChunkCopy.get(i); try { loader.saveChunk(region, chunk); } catch (Exception e) { e.printStackTrace(); } } if(((ShipRegionServer)region).parent.isDead){ ((ShipRegionServer)region).parent.getWorldDirectory().delete(); } hashToChunkCopy.clear(); return true; } @Override public boolean unloadQueuedChunks() { return true; } //Set to false because I dont want this saving from both the Ship and the Region //Only the ship will make save requests @Override public boolean canSave() { return false; } @Override public String makeString() { return null; } @Override public List func_177458_a(EnumCreatureType p_177458_1_, BlockPos p_177458_2_) { return null; } @Override public BlockPos getStrongholdGen(World worldIn, String p_180513_2_,BlockPos p_180513_3_) { return null; } @Override public int getLoadedChunkCount() { return parent.chunksInUse.size(); } @Override public void recreateStructures(Chunk p_180514_1_, int p_180514_2_,int p_180514_3_) {} @Override public void saveExtraData() {} } My code isn't that important, but basically you could take direct control of what Minecraft receives as chunks as its coordinates. -
Ok, look in the Minecraft class and search for something like PlayerControllerMP or something. You should eventually find the method that interacts mouse input with the game's player controller. You can just copy/paste the code in their and simulate that whenever and wherever you feel like it. Just don't forget to use a sledgehammer
-
Is there a Forge hook to modify base classes?
thebest108 replied to MagnusCaligo's topic in Modder Support
I for one support the SledgeHammer approach to modding thoroughly! Snip - User was banned for 7 days for advocating breaking EVERYTHING because he is to lazy to learn to do things the correct way. -Lex -
[Solved] Entities moved in same loop don't update at the same time.
thebest108 replied to don_bruce's topic in Modder Support
If you really want seperate rendering, why don't you just change the xyz of the entity based on the parent; but do it in the renderEntity() method. That would look prefect no matter what. -
[Solved] Entities moved in same loop don't update at the same time.
thebest108 replied to don_bruce's topic in Modder Support
Personally I think you should just render all the parts at once. By that I mean disable rendering for every entity except your plane base, and in your plane base just do some extra GL11 translations/rotations and then render the other pieces in their local coordinates with respect to the plane base. I hope that made sense Really though, assuming your entities positions were set properly, the linear interpolation of positions between ticks won't be accurate when the plane is rotating, and you'll still see stuttering. Just put the render code from the other parts into the renderBase and you'll be good. -
My mod changes the game fundamentally. [embed=425,349]<iframe width="560" height="315" src="https://www.youtube.com/embed/hOn9rJdTnKg" frameborder="0" allowfullscreen></iframe>[/embed] Please help?
-
I need direct override of the Entity.moveEntity() method, the Entity.onUpdate() method, the World.tick() method, and the Explosion.doExplosionA() method. Everything is already working in my dev environment, but I'm having trouble getting the obfuscated method names. Whats the method name equivalent of FMLDeobfuscatingRemapper.INSTANCE.unmap("net/minecraft/world/World");
-
So I can get class names from FML so far using FMLDeobfuscatingRemapper.INSTANCE.unmap( "net/minecraft/world/World" ); to get the obfuscated version. My question is how do I get obfuscated method names as well? A lot of mods on github just seem to already have the obfuscated name and use that, but isn't there a better way? Also does forge detect coremods automatically in a non-dev environment, or do I need to do something extra to get it load? 1 more question, whats the description version of a boolean? Im talking about the descriptions like "(DDD)V" or "(Lnet/minecraft/util/BlockPos";I)I". Using "(B)V" doesnt work for Explosion.doExplosionB(boolean check)
-
Just make a tile entity, those are rerendered every frame.
-
[1.7.10] Correct way to get block under the player?
thebest108 replied to American2050's topic in Modder Support
? No look in the moveEntity() method, that's where vanilla minecraft determines the block below to making walking noises -
Not like anybody else has them. I dont need this
-
There's a file somewhere called entityRenderer and in that file there's some fields called thirdPersonDistance and thirdPersonDistanceTemp. This should be enough to get you started. Hint: look at the orientCamera() method too
-
Eh for 1 gift card I'd do it. Hate to tell you but unless you also kept files from 1.2.5 you can't deobsfucate. Tell me what mod you want deobsfucated
-
I kept a copy of my old mappings m8. I can deobstucate the mod for you for like a gift card