Jump to content

TheDav1311

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by TheDav1311

  1. Thank you, that solves the problem. And the extended block storage comes from the original code (Random Block Updates in the WorldServer.class), and I didn't remove them.....
  2. I didn't find a method to get the ID out of a world Yeah, that was dump That the world dies slowly
  3. I need a more efficient way to do something like this: In a forest the ticks per second going down to ca. 6. @SubscribeEvent public void world_tick(WorldTickEvent event) { if(!event.world.isRemote) { WorldServer world = (WorldServer) event.world; if(!world.equals(DimensionManager.getWorld(SolarApocalypse.dimID))) return; int ticks = world.getGameRules().getInt("randomTickSpeed"); int day = WorldProviderSolar.getDataFor(world).day; Chunk[] array = world.getChunkProvider().getLoadedChunks().toArray(new Chunk[world.getChunkProvider().getLoadedChunkCount()]); if(array.length>1) for(int i=0; i < ticks; i++) { Chunk chunk = array[rand.nextInt(array.length)]; for (ExtendedBlockStorage extendedblockstorage : chunk.getBlockStorageArray()) { if(extendedblockstorage != Chunk.NULL_BLOCK_STORAGE && extendedblockstorage.getNeedsRandomTick()) { for (int c = 0; c< ticks; c++) { int x = rand.nextInt(16) + chunk.xPosition*16; int z = rand.nextInt(16) + chunk.zPosition*16; BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)); this.change_block(world, pos, day, true); } } } } } } /* * changes block beneath the BlockPos */ private void change_block(WorldServer world, BlockPos up, int day, boolean surface) { boolean needs_clean_up = false; BlockPos down = up.down(); Block block = world.getBlockState(down).getBlock(); if(block.equals(Blocks.GRASS) || block.equals(Blocks.GRASS_PATH) || block.equals(Blocks.MYCELIUM) || block.equals(Blocks.DIRT)) { world.setBlockState(down, Blocks.DIRT.getStateFromMeta(1), 2); needs_clean_up = true; } else if(surface && block.isFlammable(world, down, EnumFacing.UP) && !world.getBlockState(up).getBlock().equals(Blocks.FIRE)) { world.setBlockState(down, Blocks.FIRE.getDefaultState(), 2); } else if(block.equals(Blocks.DIRT)) { world.setBlockState(down, Blocks.GRAVEL.getDefaultState(), 2); needs_clean_up = true; } else if(block.equals(Blocks.GRAVEL)) { world.setBlockState(down, Blocks.SAND.getDefaultState(), 2); } else if(block.equals(Blocks.SAND)) { needs_clean_up = true; this.change_block(world, down, day, false); } if(surface && needs_clean_up) { world.setBlockState(up, Blocks.AIR.getDefaultState(), 2); } }
  4. looks like you don't have a jdk.
  5. I want to save as an example an integer to the world. My problem is: I can save and load without a problem, but with a restart of the client i get a "null" public class Test { private final static String nbt = "test"; @SubscribeEvent public void test(PlayerInteractEvent.RightClickItem event) { World world = event.getWorld(); TestWorldSavedData data = new TestWorldSavedData(nbt); data.test = 10; world.getPerWorldStorage().setData(nbt, data); } @SubscribeEvent public void test(PlayerInteractEvent.RightClickEmpty event) { System.out.println(event.getWorld().getPerWorldStorage().getOrLoadData(TestWorldSavedData.class, nbt)); } public static class TestWorldSavedData extends WorldSavedData { public int test; public TestWorldSavedData(String name) { super(name); } @Override public void readFromNBT(NBTTagCompound tag) { test= tag.getInteger(nbt); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { tag.setInteger(nbt, test); return tag; } } }
  6. okey...? Then I will stop and restart the daylight-circle every few ticks. Or is this a bad idea?
  7. I would like to change the duration of a day in the overworld with a dynamic variable. The only thing I know is: The duration is only a fix integer in this method: WorldProvider#calculateCelestialAngle
  8. Thank you, that works fine.
  9. I want to have a player list on both sides. And here all players at the client side: Minecraft.getMinecraft().theWorld.playerEntities;
  10. 2 Things: First: I asked to get a player from a String. Second: The client must know the other players to render them, right? And there are EntityClientPlayerMPs and I want to get them.
  11. At the server side there is this Method: EntityPlayerMP playerExample = MinecraftServer.getServer().getConfigurationManager().func_152612_a("ExampleGuy"); Is there something like that at the client side?
  12. I get this Error code, but Minecraft starts and load my mod: I started a new Mod so I have not much code: Main class package de.troubleInStevesTown.main; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import de.troubleInStevesTown.block.*; import de.troubleInStevesTown.item.*; import de.troubleInStevesTown.utility.*; @Mod(modid = TST.MODID, name = TST.NAME,version = TST.VERSION) public class TST { @SidedProxy(clientSide = "de.troubleInStevesTown.main.ClientProxy", serverSide = "de.troubleInStevesTown.main.CommonProxy") public static CommonProxy proxy; public static final String MODID = "TroubleInStevesTown"; public static final String NAME = "Trouble in Steve's Town"; public static final String VERSION = "1.0"; @EventHandler public void preInit(FMLPreInitializationEvent event) { System.out.println("Hey Pre"); } @EventHandler public void init(FMLInitializationEvent event) { TSTBlocks.registerBlocks(); TSTBlocks.registerTileEntitys(); TSTItems.registerItems(); System.out.println("Hey Init"); } @EventHandler public void postInit(FMLPostInitializationEvent event) { System.out.println("Hey Post"); } } The other classes are simply empty or have a empty method. I marked the the "@EventHandler" one time out, but same error.
  13. I'm confused. I follow exactly this steps: http://www.minecraftforge.net/wiki/Installation/Source There they say: The system variable should call PATH And if I call it JAVA_HOME: And the both path are right.
  14. PATH system variable:
  15. I don't understand how I get in this way a ResourceLocation of a specific Item
  16. Is there a way to get the ResourceLocationm of an Item? I want to use it in a GUI. I only found protected methods
  17. In this case I need your full code
  18. With a Array I don't know how to delete, but you get it in this way. Random rand = new Random(); for(int m = 0; m < 6; m++) { int r = rand.nextInt(YOURLIST.size() - 1); ItemStack stack = YOURLIST[r]; player.inventory.addItemStackToInventory(stack); } I would use a ArrayList in your situation.
  19. What kind of list you use?
  20. You save there three ItemStacks. And I think it would be easier to handle with the ItemStacks as with the Integer of the ItemStacks
  21. You should double the list if you need it twice. Random rand = new Random(); for(int m = 0; m < 6; m++) { int r = rand.nextInt(YOURLIST.size() - 1); ItemStack stack = YOURLIST.get(r); player.inventory.addItemStackToInventory(stack); //if you want not 2 times the same one YOURLIST.remove(r); }
  22. Save all things in the TileEntity, nothing in the Block. And if you want save more Stacks in there make a Container.
  23. ok That was the solution for the trading station. But my VariableBlock has still the Problem, and why I should use a key if there is no String in it? @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); iconStack = ItemStack.loadItemStackFromNBT(nbt); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if(iconStack != null){iconStack.writeToNBT(nbt);} }
  24. My problem is that my TileEntitys not saving something like a ItemStack in a Slot if I restart the world. 2 Examples public class TileEntityVariableBlock extends TileEntity { private ItemStack iconStack; public void setIconStack(ItemStack stack) { iconStack = stack; } public IIcon getIcon(int side) { return iconStack != null ? Block.getBlockFromItem(iconStack.getItem()).getIcon(side, iconStack.getItemDamage()) : null; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); iconStack = ItemStack.loadItemStackFromNBT(nbt); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if(iconStack != null){iconStack.writeToNBT(nbt);} } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); } } public class TileEntityTradingStation extends TileEntity implements IInventory { private ItemStack[] inv; public TileEntityTradingStation() { inv = new ItemStack[9]; } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int slot) { return inv[slot]; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { inv[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public ItemStack decrStackSize(int slot, int amt) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amt) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amt); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory", 0); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } @Override public String getInventoryName() { return "Traiding Station"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if(slot == 0 && stack.getItem() == main.Coin) { return true; } return false; } } @EventHandler private void FMLInit(FMLInitializationEvent event) { registerTileEntitys(); //more Stuff } private void registerTileEntitys() { GameRegistry.registerTileEntity(TileEntityVariableBlock.class, "TileEntityVariableBlock"); GameRegistry.registerTileEntity(TileEntityTradingStation.class, "TileEntityTradingStation"); }
  25. I add this but: It doesn't work with the reload @Override public Packet getDescriptionPacket() { S35PacketUpdateTileEntity packet = (S35PacketUpdateTileEntity) super.getDescriptionPacket(); NBTTagCompound tag = packet != null ? packet.func_148857_g() : new NBTTagCompound(); addInfoToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); NBTTagCompound tag = pkt.func_148857_g(); loadInfoFromNBT(tag); } private void addInfoToNBT(NBTTagCompound tag) { if(iconStack != null) iconStack.writeToNBT(tag); } private void loadInfoFromNBT(NBTTagCompound tag) { iconStack = ItemStack.loadItemStackFromNBT(tag); }
×
×
  • Create New...

Important Information

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