Jump to content

hiotewdew

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by hiotewdew

  1. 20 hours ago, Siqhter said:

    Thanks, this is what I was looking for. Is there an example of how I should modify the blockstate in the neighborChanged method?

    Try looking at getStateForPlacement in BlockStairs. It gets the neighbor's blockstate and then uses withProperty to adjust the current one to match the others.

  2. 2 minutes ago, pH7 said:

    I have since stopped using IHasModel. That was not the issue, but I managed to sort it out. Basically:

     

    
    		ItemList.ITEMS.add(new ItemBlockVariants(this.setRegistryName(this.getRegistryName())));                 // line 41

    should have been:

    
    		ItemList.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName()));                 // line 41

    Damn syntax mistakes causing trouble ? This thread can now be closed.

     

    Thanks for the advice.

    Threads don't get "closed" really, just edit the title and add [SOLVED] just fyi

    • Like 1
  3. Currently trying to redo my armor to fix this bug: https://github.com/itsmeow/betteranimalsplus/issues/31

    But the texturemap isn't fitting on the actual 3d piece.

    I've got the item here: https://github.com/itsmeow/betteranimalsplus/blob/master/src/main/java/its_meow/betteranimalsplus/common/item/ItemHirschgeistSkullWearable.java

    with the texture defined inside.

    I've got the model here https://github.com/itsmeow/betteranimalsplus/blob/master/src/main/java/its_meow/betteranimalsplus/client/model/ModelHirschgeistHelmet.java

    (SkullArmorPiece in the same folder is our old one)

     

    And yet, the armor texture is still not fitting (and I think the bug still persists, any reason why it happens in the first place)? I've currently got the raw texturemap as the layer 1 and the real texture as layer 2 and it just doesn't fit

    See here for textures: https://github.com/itsmeow/betteranimalsplus/tree/master/src/main/resources/assets/betteranimalsplus/textures/models/armor

     

    Also, I think the original bug was because the head itself wasn't a child of bipedHead, but copied its rotation values and something about that is weird in the inventory renderer.

    But I'm still not sure because I've seen it like once with the new one. Also, the original bug does not ALWAYS happen in the inventory but instead when the player is at some specific rotations.

    By "not fit" I mean it's completely off (and I can't pinpoint the texture position, it seems to be jumbled all around)

    Basically:

    Why doesn't the texture fit?

    Is there a proper fix to this backwards inventory bug?

    How should the texture/model be exported from Tabula to make it correct?

  4. Figured it out. The first issue was in the onBlockHarvested method, I did a super call to BlockSkull.onBlockHarvested, causing 1/2 of the extra drops. The second issue was from the Block.harvestBlock method, which also calls a drop of the item as well as some stat collection. I override harvestBlock and removed the dropping code but kept the stats/hunger part. Also, since my onBlockHarvested was identical to BlockSkull's, I removed the override and let BlockSkull handle it. Now it drops as expected.

  5. On 12/27/2018 at 10:51 AM, diesieben07 said:

    It might not be. Still, why? This usually means you are pirating the game.

     

    You need to use ClientTickEvent, PlayedLoggedInEvent is server-side only. And that is not how @SideOnly works.

    Not to go too off topic, but /login can be used on servers as a staff security measure as well as for cracked server auth. So, it's not always malicious. I once had to use it on my online mode server because we had this hacker who somehow figured out that commands could be run by staff before they were authenticated (I have no idea how, but I'm not lying, he'd done it) and so I had to add a login command for staff to counteract it.

  6. 5 hours ago, Discult said:

    so wait let me get this right you want it to break only if in contact with water and this works in creative but when in survival you can break it and it drops 3x or when broke with water it drops 3x?

    No, I want it to break normally. But in creative, it gives item drops (none) as normal, unless water runs it over (like a torch). In survival, it drops 3x. If it's water, it drops 1x.

  7. I've got a class that overrides BlockSkull and I want it to drop the right item when it's broken, and I've overriden onBlockHarvested,  getItemDropped, and getDrops, and in creative mode it works as expected (no drop unless broken by water/other sources) but in survival it drops 3x unless broken by water/other sources. Here's my class:

    package its_meow.betteranimalsplus.common.block;
     
    import java.util.Random;
     
    import its_meow.betteranimalsplus.BetterAnimalsPlusMod;
    import net.minecraft.block.BlockSkull;
    import net.minecraft.block.ITileEntityProvider;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.EnumBlockRenderType;
    import net.minecraft.util.NonNullList;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.util.math.RayTraceResult;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
     
    public class BlockAnimalSkull extends BlockSkull implements ITileEntityProvider {
     
        public BlockAnimalSkull() {
            this.setHardness(1.0F);
            this.setSoundType(SoundType.STONE);
            this.translucent = true;
            this.fullBlock = false;
            this.setCreativeTab(BetterAnimalsPlusMod.tab);
        }
       
        /**
         * Called before the Block is set to air in the world. Called regardless of if the player's tool can actually
         * collect this block
         */
        @Override
        public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
        {
            if (player.capabilities.isCreativeMode)
            {
                state = state.withProperty(NODROP, Boolean.valueOf(true));
                worldIn.setBlockState(pos, state, 4);
            }
            this.dropBlockAsItem(worldIn, pos, state, 0);
            super.onBlockHarvested(worldIn, pos, state, player);
        }
     
        @Override
        public boolean hasTileEntity() {
            return true;
        }
     
        @Override
        public boolean isOpaqueCube(IBlockState state) {
            return false;
        }
     
        @Override
        public boolean isFullCube(IBlockState state) {
            return false;
        }
     
        @Override
        public boolean isTopSolid(IBlockState state) {
            return false;
        }
     
        @Override
        public boolean canDispenserPlace(World world, BlockPos pos, ItemStack stack) {
            return false;
        }
     
        @Override
        public EnumBlockRenderType getRenderType(IBlockState state)
        {
            return EnumBlockRenderType.INVISIBLE;
        }
     
     
     
        @Override
        public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
                EntityPlayer player) {
            return new ItemStack(this.getItemBlock(), 1);
        }
     
        @Override
        public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
            return new ItemStack(this.getItemBlock(), 1);
        }
       
        @Override
        public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
        {
            if (!((Boolean)state.getValue(NODROP)).booleanValue())
            {
                Random rand = world instanceof World ? ((World)world).rand : RANDOM;
     
                Item item = this.getItemDropped(state, rand, fortune);
                if (item != Items.AIR)
                {
                    drops.add(new ItemStack(item, 1));
                }
            }
        }
     
        /**
         * Get the Item that this Block should drop when harvested.
         */
        @Override
        public Item getItemDropped(IBlockState state, Random rand, int fortune)
        {
            return this.getItemBlock();
        }
     
     
        public ItemBlock getItemBlock() {
            return null;
        }
    }

    Don't worry, my actual implementations override getItemBlock(), so it doesn't pass null. This is a generic class.

  8. Figured it out. My get method uses both getMapStorage and getPerWorldStorage.

    public static ClaimSerializer get(World world) {
      // PER WORLD STORAGE
    		ClaimSerializer save = (ClaimSerializer) world.getPerWorldStorage().getOrLoadData(ClaimSerializer.class, DATA_NAME);
    		if(save == null) {
    			save = new ClaimSerializer();
              // MAP STORAGE!
    			world.getMapStorage().setData(DATA_NAME, save); 
    		}
    		return save;
    	}
  9. I'm working on a claim system mod, and I'm using WorldSavedData to serialize the claims, including UUIDs of owners/members. However, I've run into an issue. When the data is saved, it saves with the proper UUID, confirmed by NBTExplorer.

    image.png.ba1bf5e14d1151f7d893695623c43058.png

    However upon loading the data, if I use UUIDs instead of strings I get 000000-00000-0000 as my UUID

    and if I use strings and parse it into a UUID, I get an invalid string that causes a crash. (Presumably empty string or 00000-000-000)

    See comment below.

    The integer array loads properly and I've ensured everything is serverside.

    Another issue I've run into is that the data from the nether isn't saved.

    image.png.69014f443d0acbb8952b1c8d3d1d48d3.png

    There's no dat file, even though I am using perWorldStorage.

     

    Here's how my serializer works.

    It starts in my event handler, which has the following events:

    @SubscribeEvent
    	public void onWorldLoad(WorldEvent.Load e) {
    		if(!e.getWorld().isRemote) {
    			ClaimManager.getManager().deserialize(e.getWorld());
    		}
    	}
    
    	@SubscribeEvent
    	public void onWorldSave(WorldEvent.Save e) {
    		if(!e.getWorld().isRemote) {
    			ClaimManager.getManager().serialize(e.getWorld());
    		}
    	}

    Which both of the following fire properly and go to my ClaimManager (responsible for adding and removing claims from the official claims list)
    These two methods are the beef of the bunch:

    Spoiler

     

    
    /** Forces a world to save claim data 
    	 * @param world - The world to be saved **/
    	public void serialize(World world) {
    		if(!world.isRemote) {
    			ClaimSerializer store = ClaimSerializer.get(world);
    			for(ClaimArea claim : claims) {
    				if(claim.getDimensionID() == world.provider.getDimension()) {
    					int[] claimVals = claim.getSelfAsInt();
    					UUID owner = claim.getOwner();
    					UUID ownerOffline = claim.getOwnerOffline();
    					String serialName = claim.getSerialName();
    					NBTTagCompound data = new NBTTagCompound();
    					data.setIntArray("CLAIMINFO", claimVals);
    					data.setString("OWNERUID", owner.toString());
    					data.setString("OWNERUIDOFF", ownerOffline.toString());
    					System.out.println("Owner: " + owner);
    					for(EnumPerm perm : EnumPerm.values()) {
    						NBTTagCompound members = new NBTTagCompound();
    						for(UUID member : claim.getArrayForPermission(perm)) {
    							members.setString("MEMBER_" + member.toString(), member.toString());
    						}
    						data.setTag("MEMBERS_" + perm.name(), members);
    					}
    					store.data.setTag("CLAIM_" + serialName, data);
    					store.markDirty();
    					System.out.println("Saving claim: " + serialName);
    				}
    			}
    		}
    	}
    
    	/** Forces a world to load claim data. 
    	 * Overwrites new claim data since last load!
    	 * @param world - The world to be saved **/
    	public void deserialize(World world) {
    		if(!world.isRemote) {
    			ClaimSerializer store = ClaimSerializer.get(world);
    			NBTTagCompound comp = store.data;
    			if(comp != null ) {
    				for(String key : comp.getKeySet()) {
    					System.out.println("Loading " + key);
    					NBTTagCompound data = comp.getCompoundTag(key);
    					int[] claimVals = data.getIntArray("CLAIMINFO");
    					UUID owner = UUID.fromString(comp.getString("OWNERUID"));
    					UUID ownerOffline = UUID.fromString(comp.getString("OWNERUIDOFF"));
    					System.out.println("Owner: " + owner);
    					if(claimVals.length > 0 && claimVals[0] == 0 && claimVals[1] == world.provider.getDimension()) {
    						System.out.println("Valid version.");
    						ClaimArea claim = new ClaimArea(claimVals[1], claimVals[2], claimVals[3], claimVals[4], claimVals[5], owner, ownerOffline);
    						for(String key2 : data.getKeySet()) {
    							if(key2.startsWith("MEMBERS_")) {
    								NBTTagCompound members = data.getCompoundTag(key2);
    								for(String key3 : members.getKeySet()) {
    									if(key3.startsWith("MEMBER_")) {
    										UUID member = UUID.fromString(members.getString(key3));
    										claim.addMember(EnumPerm.valueOf(key2.replaceAll("MEMBERS_", "")), member);
    									}
    								}
    							}
    						}
    						this.addClaim(claim);
    					} else {
    						ClaimIt.logger.log(Level.FATAL, "Detected version that doesn't exist yet! Mod was downgraded? Claim cannot be loaded.");
    					}
    				}
    			}
    		}
    	}

     

    This is my actual WorldSavedData (ClaimSerializer):

    public class ClaimSerializer extends WorldSavedData {
    	private static final String DATA_NAME = Ref.MOD_ID + "_ClaimsData";
    	public NBTTagCompound data = new NBTTagCompound();
    	
    	public ClaimSerializer() {
    		super(DATA_NAME);
    	}
    	
    	public ClaimSerializer(String s) {
    		super(s);
    	}
    	
    	@Override
    	public void readFromNBT(NBTTagCompound nbt) {
    		data = nbt;
    	}
    	@Override
    	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    		compound = data;
    		return compound;
    	}
    	
    	public static ClaimSerializer get(World world) {
    		ClaimSerializer save = (ClaimSerializer) world.getPerWorldStorage().getOrLoadData(ClaimSerializer.class, DATA_NAME);
    		if(save == null) {
    			save = new ClaimSerializer();
    			world.getMapStorage().setData(DATA_NAME, save);
    		}
    		return save;
    	}
    }

     

    As you can see, it uses getPerWorldStorage, and is provided the world instance from the original event to return a storage, but for some reason nothing is saved to the nether. I've tested this on both a server and singleplayer. It always loads as an empty UUID and doesn't save nether info. The UUID issue only happens when the game is exited and started. Any ideas?

     

    For more context, my source: https://github.com/itsmeow/ClaimIt/tree/master/src/main/java/its_meow/claimit

  10. I'm currently updating Colored Chests and I've come across an issue. I'm using a single Block class to create multiple block instances with different colors. As in, I pass a color and a color name inside the initializer to the block, and register the new block class as it's own block with a custom registry name (appending the color name I gave it to "coloredchest"). However, upon restarting the world, the console prints "Registry Block: Found a missing id from the world coloredchests:coloredchest" and the blocks are gone. But I never register a block with that ID, they all have colors after the name.

    My Block registry: https://github.com/itsmeow/ColoredChests/blob/master/src/main/java/its_meow/coloredchests/BlockRegistry.java

    Block itself: https://github.com/itsmeow/ColoredChests/blob/master/src/main/java/its_meow/coloredchests/chest/BlockColoredChest.java

    I can tell it's something to do with the way I'm doing the registration, but I really do not have the time to redo this. I know there's millions of better ways I could do it, but I'm looking for the easy solution.

    Is there something that can fix the way I'm doing it? If there's not one, perhaps an easier/equivically difficult way to create the blocks with SEPERATE IDs! Because of the way they're considered seperate blocks, I don't have to check if the colors match inside the block class with other chests, only if they are the same block.

  11. 25 minutes ago, V0idWa1k3r said:

    Please define moved. Do you mean changes slots? In the player's inventory only or in any container? If you want any container then the best you can do is subscribe to a tick event, iterate all players, look at their open containers(will be the inventory if the player isn't looking at the GUI at the moment), iterate the stacks in that container and check their slot index against the one on the previous tick. If it changed the item was moved.

    Keep in mind that it is pretty much impossible to detect slot changes of the item if it happens without the player present, such as a hopper inserting/extracting an item.

     

    ItemTossEvent

     

    Check the current slot of your item each tick, compare it to the slot on the previous tick. If the slot changed and was the held one then it's not being held anymore.

    Is there a way that doesn't involve checking every tick?

  12. I'm making a land claiming mod, and when using the claim tool it checks for overlaps. I got all the overlapping code down and it works fine, but the server thread returns that the block overlaps a claim even if there are NO CLAIMS in the world, and the main thread returns the proper result.

    See the line commented where it prints "overlaps". The server is completely off for no apparent reason.

    @Override
    	public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
    			EnumFacing facing, float hitX, float hitY, float hitZ) {
    		ItemStack stack = player.getHeldItem(hand);
    		NBTTagCompound data = stack.getTagCompound();
    		if(data == null) {
    			NBTTagCompound newTag = new NBTTagCompound();
    			data = newTag;
    			stack.setTagCompound(newTag);
    		}
    		boolean isInClaim = ClaimManager.getManager().isBlockInAnyClaim(pos, worldIn);
    		System.out.println("Overlaps: " + isInClaim); // THIS IS THE LINE WHERE THE SERVER THREAD IS WRONG
    		if(!isInClaim) {
    			int[] posArray = {pos.getX(), pos.getZ()};
    			if(data.hasKey("Corner1")) {
    				if(!worldIn.isRemote)
    					player.sendMessage(new TextComponentString("Added corner 2 at " + posArray[0] + ", " + posArray[1]));
    				int[] corner1 = data.getIntArray("Corner1");
    				int[] corner2 = posArray;
    				BlockPos c1 = new BlockPos(corner1[0], 0, corner1[1]);
    				BlockPos c2 = new BlockPos(corner2[0], 0, corner2[1]);
    				/* Not needed due to ClaimArea constructor
    					if(c1.subtract(c2).getX() < 0 && c1.subtract(c2).getY() < 0) {
    						BlockPos c = c1; // Swap values to make c1 the proper corner
    						c1 = c2;
    						c2 = c;
    					}*/
    				BlockPos sideL = c2.subtract(c1); // Subtract to get side lengths
    				// Claim corners are automatically corrected to proper values by constructor
    				ClaimArea newClaim;
    				newClaim = new ClaimArea(player.dimension, c1.getX(), c1.getZ(), sideL.getX(), sideL.getZ(), player);
    				boolean didClaim = ClaimManager.getManager().addClaim(newClaim); // Add claim
    				if(!worldIn.isRemote)
    					player.sendMessage(new TextComponentString(didClaim ? "Claim added successfully!" : "This claim overlaps another claim!"));
    				// Remove data so a new claim can be made.
    				data.removeTag("Corner1");
    				return didClaim ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
    			} else {
    				data.setIntArray("Corner1", posArray);
    				if(!worldIn.isRemote)
    					player.sendMessage(new TextComponentString("Added corner 1 at " + posArray[0] + ", " + posArray[1]));
    			}
    			return EnumActionResult.SUCCESS;
    		} else {
    			if(!worldIn.isRemote) {
    				data.removeTag("Corner1");
    				player.sendMessage(new TextComponentString("You cannot set a corner inside an existing claim!"));
    			}
    		}
    		return EnumActionResult.FAIL;
    	}

    I know this is not nearly enough code to represent the problem, so here is my source

    I'm not sure how I should be doing the checking to insure that the server does all the work, and the client recieves such, but also having it work properly on SP.

    This error shows up on SP, I haven't tested on an actual server.

  13. Alright so some of my mobs just straight up aren't spawning:

    Bear (all 3, although kermode is rare)

    Deer (Don't know why, 13 weight is high for creatures)

    Feral Wolves

    Fox

    Tarantula (Went to desert at night)

    Hirschgeist (1% spawnrate, not worried abt it)

     

     

    Mob registry:

    https://github.com/itsmeow/betteranimalsplus/blob/master/src/main/java/its_meow/betteranimalsplus/init/MobRegistry.java

     

    Any ideas?

    I'll be busy for the rest of the day so I'll check back tonight

     

×
×
  • Create New...

Important Information

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