
TheDav1311
Members-
Posts
73 -
Joined
-
Last visited
Everything posted by TheDav1311
-
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.....
-
I didn't find a method to get the ID out of a world Yeah, that was dump That the world dies slowly
-
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); } }
-
looks like you don't have a jdk.
-
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; } } }
-
okey...? Then I will stop and restart the daylight-circle every few ticks. Or is this a bad idea?
-
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
-
[1.7.10] Get a Player from a String in the Client
TheDav1311 replied to TheDav1311's topic in Modder Support
Thank you, that works fine. -
[1.7.10] Get a Player from a String in the Client
TheDav1311 replied to TheDav1311's topic in Modder Support
I want to have a player list on both sides. And here all players at the client side: Minecraft.getMinecraft().theWorld.playerEntities; -
[1.7.10] Get a Player from a String in the Client
TheDav1311 replied to TheDav1311's topic in Modder Support
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. -
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?
-
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.
-
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.
-
PATH system variable:
-
I don't understand how I get in this way a ResourceLocation of a specific Item
-
Is there a way to get the ResourceLocationm of an Item? I want to use it in a GUI. I only found protected methods
-
In this case I need your full code
-
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.
-
What kind of list you use?
-
[1.7.10] TileEntity doesn't seems to save data
TheDav1311 replied to knokko's topic in Modder Support
You save there three ItemStacks. And I think it would be easier to handle with the ItemStacks as with the Integer of the ItemStacks -
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); }
-
[1.7.10] TileEntity doesn't seems to save data
TheDav1311 replied to knokko's topic in Modder Support
Save all things in the TileEntity, nothing in the Block. And if you want save more Stacks in there make a Container. -
[1.7.2] TileEntitys not saving at a world/server restart
TheDav1311 replied to TheDav1311's topic in Modder Support
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);} } -
[1.7.2] TileEntitys not saving at a world/server restart
TheDav1311 posted a topic in Modder Support
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"); } -
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); }