Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/07/17 in all areas

  1. IntelliJ isn't the only program that does it, I've run into a few others. But every time it's "undo, undo, undo...ok redo...fuck, why did that just delete a line? Oh, stupid keybinds. FINE, I GUESS I'LL RETYPE IT." I don't mind ctrl-shift-z being redo and not ctrl-y, it's the binding something destructive to ctrl-y that irks me. Yeah, just completely fuck with someone who's never used your software before so they can't fix the mistake because they didn't know what your keybinds were, that's just brilliant.
    1 point
  2. what are you looking for the bonemeal to do? If you want growing plants, your have to incorporate an age property. Your cangrow.. return blockasphodelplant$enumplanttype != BlockTwoPlant.EnumPlantType.ASPHODELPLANT && blockasphodelplant$enumplanttype != BlockTwoPlant.EnumPlantType.ASPHODELPLANT; looks like it would always return false if plant type is ASPHODELPLANT, which in your case it would be, so cangrow always returns false, so grow is never called. I haven't had my coffee yet, but that's how I'm reading it.
    1 point
  3. Okay, I was playing with this a bit, coding it my own way and I have a few tips and suggestions. First of all, the world saved data class should also contain the fields that you're interested in changing. Those fields can in fact be simply a list of instances of another class, but the point is that you should be doing the converting between NBT read from file and the class field values. So the way I would do it is that the world saved data class will contain a list of the protected area instances. But the world saved data class should also be used to set the data in those area instances because you need to know when they change to markDirty() properly. Furthermore you have to develop the writeToNBT() and readFromNBT() methods. They should basically use tag lists to hold the list of areas which in turn hold the list of blocks within the area. So for example, here is my protected area class example (note that I only stored name and list of block positions, in your code you should add other things like tenant, taxes and such): public class ProtectedArea { private String name; private List<BlockPos> listBlocks = new ArrayList<BlockPos>(); /** * Instantiates a new protected area. * * @param parName the par name */ public ProtectedArea(String parName) { name = parName; } /** * Gets the name. * * @return the name */ public String getName() { return name; } /** * Adds the block position to the protected blocks list. * * @param parPos the par pos */ public void addBlock(BlockPos parPos) { listBlocks.add(parPos); } /** * Removes the block position from the protected blocks list. * * @param parPos the par pos */ public void removeBlock(BlockPos parPos) { listBlocks.remove(parPos); } /** * Clears the protected blocks. */ public void clearBlocks() { listBlocks.clear(); } /** * Gets the protected block list. * * @return the protected block list */ public List<BlockPos> getProtectedBlockList() { return listBlocks; } /** * Gets the block list tag. * * @return the block list tag */ public NBTTagList getBlockListTag() { NBTTagList tagList = new NBTTagList(); Iterator<BlockPos> iterator = listBlocks.iterator(); while (iterator.hasNext()) { BlockPos pos = iterator.next(); NBTTagCompound posCompound = new NBTTagCompound(); posCompound.setInteger("x", pos.getX()); posCompound.setInteger("y", pos.getY()); posCompound.setInteger("z", pos.getZ()); tagList.appendTag(posCompound); } return tagList; } } And my example of the class that extends WorldSavedData is: public class ProtectedAreaData extends WorldSavedData { private static final String DATA_NAME = MainMod.MODID + "_data_aree"; private List<ProtectedArea> listAreas = new ArrayList<ProtectedArea>(); /** * Instantiates a new protected area data. */ public ProtectedAreaData() { super(DATA_NAME); } /** * Instantiates a new protected area data. * * @param name the name */ public ProtectedAreaData(String name) { super(name); } /** * Gets the world saved data instance associated to a given world. * * @param world the world * @return the data instance */ public static ProtectedAreaData getDataInstance(World world) { MapStorage storage = world.getMapStorage(); ProtectedAreaData instance = (ProtectedAreaData) storage.getOrLoadData(ProtectedAreaData.class, DATA_NAME); if (instance == null) { instance = new ProtectedAreaData(); storage.setData(DATA_NAME, instance); } return instance; } /** * Adds the area to the list of protected areas. * * @param parArea the par area */ public void addArea(ProtectedArea parArea) { listAreas.add(parArea); markDirty(); } /** * Removes the area from the list of protected areas. * * @param parArea the par area */ public void removeArea(ProtectedArea parArea) { listAreas.remove(parArea); markDirty(); } /** * Clear the protected areas list. */ public void clearAreas() { listAreas.clear(); markDirty(); } /** * Gets the area by name. * * @param parName the par name * @return the area by name */ @Nullable public ProtectedArea getAreaByName(String parName) { Iterator<ProtectedArea> iterator = listAreas.iterator(); while (iterator.hasNext()) { ProtectedArea area = iterator.next(); if (area.getName().equals(parName)) { return area; } } return new ProtectedArea(parName); } /** * Adds the block to a given area. * * @param parName the par name * @param parPos the par pos */ public void addBlockToArea(String parName, BlockPos parPos) { getAreaByName(parName).addBlock(parPos); markDirty(); } /** * Removes the block from a given area. * * @param parName the par name * @param parPos the par pos */ public void removeBlockFromArea(String parName, BlockPos parPos) { getAreaByName(parName).removeBlock(parPos); markDirty(); } /** * Clear blocks from area. * * @param parName the par name */ public void clearBlocksFromArea(String parName) { getAreaByName(parName).clearBlocks(); markDirty(); } /** * Checks if a block position is protected. * * @param parPos the par pos * @return true, if is block pos protected */ public boolean isBlockPosProtected(BlockPos parPos) { Iterator<ProtectedArea> iteratorArea = listAreas.iterator(); while (iteratorArea.hasNext()) { ProtectedArea area = iteratorArea.next(); if (area.getProtectedBlockList().contains(parPos)) { return true; } } return false; } /* (non-Javadoc) * @see net.minecraft.world.storage.WorldSavedData#readFromNBT(net.minecraft.nbt.NBTTagCompound) */ //load @Override public void readFromNBT(NBTTagCompound nbt) { listAreas.clear(); NBTTagList tagListAreas = nbt.getTagList("Protected Areas", 10); // 10 indicates a list of NBTTagCompound Iterator<NBTBase> iterator = tagListAreas.iterator(); while (iterator.hasNext()) { NBTTagCompound areaCompound = (NBTTagCompound) iterator.next(); ProtectedArea area = new ProtectedArea(areaCompound.getString(areaCompound.getString("Area Name"))); listAreas.add(area); NBTTagList tagListPos = areaCompound.getTagList("Block List", 10); Iterator<NBTBase> iterator2 = tagListPos.iterator(); while (iterator2.hasNext()) { NBTTagCompound posCompound = (NBTTagCompound) iterator2.next(); BlockPos pos = new BlockPos( posCompound.getInteger("x"), posCompound.getInteger("y"), posCompound.getInteger("z") ); area.addBlock(pos); } } } /* (non-Javadoc) * @see net.minecraft.world.storage.WorldSavedData#writeToNBT(net.minecraft.nbt.NBTTagCompound) */ //save @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagList tagList = new NBTTagList(); // cycle through the list of areas Iterator<ProtectedArea> iteratorArea = listAreas.iterator(); while (iteratorArea.hasNext()) { NBTTagCompound tagCompound = new NBTTagCompound(); ProtectedArea area = iteratorArea.next(); tagCompound.setString("Area Name", area.getName()); tagCompound.setTag("Block List", area.getBlockListTag()); tagList.appendTag(tagCompound); } nbt.setTag("Protected Areas", tagList); return nbt; } } NOTE: I have not tested this code yet. But I think the general approach should work well. It is very similar to the world data implemented for the ItemMap. Now, when the player is changing things in your GUI you can use the methods to add the blocks and such as you need. In summary, I think you need to have the informations in fields that are in the world save data class and you should furthermore implement the writeToNBT() and readFromNBT() to suit the information you want to save. For syncing the client, you will have to send the world data yourself as a custom packet. The good news is that the minecraft packet can accept NBT directly as a payload. I hope that helps. I need to go to be as it is past midnight ...
    1 point
  4. Attempt to get an item. If it doesn't exist: do nothing
    1 point
  5. You were creating a standard ItemBlock rather than your custom ItemBlock subclass.
    1 point
  6. Oh, that's a nifty little page there... thanks! You, draco, are a lifesaver.
    1 point
  7. Well the BlockDoublePlant has a property HALF that tells you if the block represents the UPPER or LOWER block of the 2 block group. This property is stored in the blockstate. So when you do a IBlockState state= world.getBlockState(BlockPos); you can get the value by state.getValue(BlockDoublePlant.HALF); The BlockDoublePlant then traps events such as getItemDropped, etc to determine which blockstate is present (UPPER or LOWER) and do appropriate action. i.e. upper should turn to air if the bottom block is destroyed/harvested If you create a new class MyBlockDoublePlant and copy all the code over from BlockDoublePlant (extending BlockBush, implements IGrowable, net.minecraftforge.common.IShearable) then get rid of the variants you don't want, create your own EnumPlantTypes and tweak as needed. Should get you were you want to be. The json file for the blockstate would be similar to the double_rose.json, double_fern.json, etc taking note of the variants 'half=lower', 'half=upper'. In your modblocks, create each variant appropriately with the MyBlockDoublePlant (or whatever you call the class). You would also have to deal with generation in the biomes that you want, but that is next step if you were wanting auto generating plant.
    1 point
×
×
  • Create New...

Important Information

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