Jump to content

hiotewdew

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by hiotewdew

  1. 5 hours ago, jabelar said:

    Firstly you're not using the proper way to register entities for 1.12.2. You should be using the registration event with the entry builder technique. The entry builder has addSpawn() method that can directly take an array of biomes.

     

    I have an example here: https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/init/ModEntities.java

    Thank you. I did know that they were old I wasn't really sure of the event I should be using. I have a question. Does the EntityEntry set have to be immutable? I converted my init function into a function that adds all the entity entries for all of my mobs to the set (non-final hashset) that is called before the registry set loop. Will that work? Also, for the resource location in the EntryBuilder, the number after is supposed to be modEntities++ (different number for each mob), right?

  2. So my users have been experiencing a bug while using personal modpacks with my mod. For some reason, my animals spawn exceptionally fast (50+ per 4 chunks).

    But only sometimes. I have tested this with both my users trying to recreate a world seed with only BOP or traverse and remove all their other mods, and the bug seems to go away.

    I compared the modlists of 4 users experiencing the bug and found they share:

    - Biomes O Plenty/Traverse (either)

    - LLibrary

    - DynamicSurroundings

    - Bibliocraft

     

    I had one user remove DynamicSurroundings and nothing changed. Have not tested Bibliocraft, but there's no reason why it would mess with mob spawning.

     

    This is my mob registry.

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

    I register as EnumCreatureType.MONSTER because if I set them to creature they don't seem to spawn.
    Any ideas? (Ignore the BiomeType code, it's messy, but essentially you put a set of biome sets and it has to convert to an array with all of them)

     

    Users mostly discover high spawns of the Deer and the Lammergeier. I have tried setting getMaxSpawnedInChunk but it doesn't seem to do anything.

  3. 10 minutes ago, Animefan8888 said:

    You also need to override TileEntity#getUpdateTag and TileEntity#handleUpdateTag

    Yeah, I just figured out it was the syncing that was the issue.

    That seems to have fixed it. Thanks! I read somewhere that those two were only nessecary for stuff related to capabilities.

  4. I'm aware at least 50000 threads exist with this exact topic. And trust me, I have read them. But my tile entity just refuses to save/sync data.

    Here's my code.

    package its_meow.betteranimalsplus.block;
    
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.play.server.SPacketUpdateTileEntity;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.math.AxisAlignedBB;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    
    public class TileEntityHandOfFate extends TileEntity {
    	
    	private boolean onFire = false;
    	
    	
    	public TileEntityHandOfFate() {
    	}
    	
    	
    	public void setOnFire(boolean b) {
    		this.onFire = b;
    		this.markDirty();
    	}
    	
    	public boolean isOnFire() {
    		return onFire;
    	}
    	
    	
    	@Override
    	public void readFromNBT(NBTTagCompound compound) {
    		super.readFromNBT(compound);
    		this.onFire = compound.getBoolean("OnFire");
    	}
    
    
    
    	@Override
    	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    		super.writeToNBT(compound);
    		compound.setBoolean("OnFire", this.onFire);
    		return compound;
    	}
    
    	@Override
    	public SPacketUpdateTileEntity getUpdatePacket() {
    		NBTTagCompound tag = new NBTTagCompound();
    		this.writeToNBT(tag);
    		return new SPacketUpdateTileEntity(pos, 1, tag);
    	}
    
    
    	@Override
    	public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
    		readFromNBT(packet.getNbtCompound());
    		world.scheduleUpdate(this.pos, this.blockType, 100);
    	}
    	
    	
    	
    	
    	
    	@Override
    	@SideOnly(Side.CLIENT)
    	public AxisAlignedBB getRenderBoundingBox() {
    		return new AxisAlignedBB(getPos().add(-2, -4, -2), getPos().add(2, 4, 2));
    	}
    	
    }

     

    Yes, the tile entity is registered and exists. It has a TESR that renders fire (the render method uses the isOnFire() method and creates fire particles).

    When I exit the world and reload it (not even leave game) the fire disappears.

    Nothing external to this touches the NBT.

  5. I have an ItemBlock connected that's tied to a block and I want it to be wearable as a helmet (it's a mob skull) and I have the block fully working but when I put it on as a helmet it just uses the JSON model for the Item (a flat texture) instead of the armor model that I define in the ItemBlock class.

    //In the itemblock class:
    @Override
    	public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) {
    		return armorType == EntityEquipmentSlot.HEAD;
    	}
    
    	@Override
    	public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
    	{
    		return Ref.MOD_ID + ":textures/entites/hirschgeist.png";
    	}
    
    	@Override 	
    	@SideOnly(Side.CLIENT)
    	public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot,
    			ModelBiped defaultModel) {
    		return ClientProxy.helmetModel;
    	}
    
    //Client Proxy
    public static final ModelHirschgeistSkullArmorPiece helmetModel = new ModelHirschgeistSkullArmorPiece(0.0625F);
    
    //Block registry events
    
    		/**
    		 * Register this mod's {@link Block}s.
    		 *
    		 * @param event The event
    		 */
    		@SubscribeEvent
    		public static void registerBlocks(final RegistryEvent.Register<Block> event) {
    			final IForgeRegistry<Block> registry = event.getRegistry();
    
    			final Block[] blocks = {
    					trillium,
    					hirschgeistskull,
    			};
    
    			registry.registerAll(blocks);
    
    			GameRegistry.registerTileEntity(TileEntityTrillium.class, new ResourceLocation(Ref.MOD_ID + ":" + trillium.getRegistryName()));
    			GameRegistry.registerTileEntity(TileEntityHirschgeistSkull.class, Ref.MOD_ID + ":" + hirschgeistskull.getRegistryName());
    		}
    
    
    		/**
    		 * Register this mod's {@link ItemBlock}s.
    		 *
    		 * @param event The event
    		 */
    		@SubscribeEvent
    		public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
    			final ItemBlock[] items = {
    					new ItemBlock(trillium),
    					hirschgeistskull.getItemBlock(),
    			};
    
    			final IForgeRegistry<Item> registry = event.getRegistry();
    
    			for (final ItemBlock item : items) {
    				final Block block = item.getBlock();
    				final ResourceLocation registryName = Preconditions.checkNotNull(block.getRegistryName(), "Block %s has null registry name", block);
    				registry.register(item.setRegistryName(registryName));
    				ITEM_BLOCKS.add(item);
    			}
    		}

     

    How should I be registering the model?

    The Block is a TE with a TESR and that's registered, but I'm not sure how I should register my model.

    If I use ModelLoader.setCustomModelResourceLocation it's just the item texture on my head, not the java model. I put a print statement in getArmorModel and it doesn't seem like it's running.

    By the way, getItemBlock(); returns a new instance of my ItemBlock class.

  6. So I have an advanced rendering problem here.

    I understand that in order to add transparency you call GlStateManager.enableAlpha() and use GlStateManager(1,1,1,alpha) to change transparency.

     

    However, I have a ghost deer with bones inside that I want to be opaque. How would I go about making only some of these transparent while they are still children of each other? Even better: is there a way I can keep the skeleton and the outer ghost layer seperate but have the rotations match (keep them attached without having their rendering attached?)

    Here's what I want it to look like. I also seem to have this bug only the front ribs are visibile. The rest seemed to have disappeared as well as the hip area/leg attachment bones.

     

     v05DRCk.png

     

    On the side, if anyone knows how I can keep a particle at a specific position (relative to the entity's heading)/attached to piece, I also need to know how to do that without using translates and some trig.

    I'm not expecting for every part of this to be answered, as it is definitely an advanced question. I'm almost certain I'll have to figure out the invisible bones on my own, but if anyone has anything that could help with any of the above problems it would be great! Thanks!

  7. 3 minutes ago, Animefan8888 said:

    Entity Grabber


     

    
    public void update() {
    
        if (isRiding()) {
    
            getRidingEntity().setVelocity(/** Apply correct velocity from AI. **/)
    
        } else {
    
            // Normal code.
    
        }
    
    }

     

    Sorry, this won't work for me. However, I found a solution. Instead of riding the attacked entity, it sets the attacked to ride IT and then overrides the updatePassenger method and sets the position of the attacked to below it.

    @Override
    	public void updatePassenger(Entity passenger)
        {
            if (this.isPassenger(passenger))
            {
                float f1 = (float)((this.isDead ? 0.009999999776482582D : this.getMountedYOffset()) + passenger.getYOffset());
              
                passenger.setPosition(this.posX, this.posY - passenger.height - 0.05, this.posZ);
                this.applyOrientationToEntity(passenger);
            }
        }

     

  8. For the life of me I cannot understand HOW MapSavedData works. I know it's NBT but it's not traditional in any way whatsoever. I am trying to store many String values (or if possible custom Enums) into NBT with different keys. normally, I would call compound.setString("mykey", "data") but MapSavedData does not do this. Instead I am left with MapStorage.getWorldData() and some need-to-be implemented readFromNBT and writeFromNBT. It has something to do with MapStorage.getOrLoadData(); and MapStorage.setData(); which I think writes the class into the world? Do the classes only store ONE value? I want a compound that saves into the map.

     

    I feel very stupid, but I've searched all I can and read the documentation and STILL I cannot understand.

  9. I'm creating a mod that has ore chunks remember where they were mined at. This works fine when a player is the one mining, but I plan to add mining vehicles with storage. I'm currently using onUpdate to store the chunk location it was mined at in NBT, but onUpdate only executes when the item is held by a player. If I make the item and it goes directly into a container, it will not store where it was created.

     

    Is there a method in the Item class I can somehow use to store data into the ItemStack NBT when it is created? onCreated is for the item instance.

     

    @Override
    	public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    		BlockPos playerPos = entityIn.getPosition();
    		Chunk creationChunk = worldIn.getChunkFromBlockCoords(playerPos);
    		if(stack.getTagCompound() == null) {
    			stack.setTagCompound(new NBTTagCompound());
    		}
    		NBTTagCompound tagcompound = stack.getTagCompound();
    		int[] chunk = tagcompound.getIntArray("chunk");
    		if(chunk.length == 0) {
    			int[] array = { creationChunk.x, creationChunk.z };
    			tagcompound.setIntArray("chunk", array);
    			stack.setTagCompound(tagcompound);
    		}	
    		super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
    	}

     

  10. Also, I would heavily suggest embedding an InitModel function within your block classes.

    @SideOnly(Side.CLIENT)
    	public void initModel() {
    		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    	}

    That way when you run onRegsiterModels, you can just call

    Items.STARRECORD.initModel();

     

     

    Also, blockstates aren't used for items! Only models are nessecary. Don't worry about a blockstate json.

  11. @SideOnly(Side.CLIENT)
    	@SubscribeEvent
    	public static void onRegisterModels(ModelRegistryEvent event) {	
    		ModelLoader.setCustomModelResourceLocation(Items.STARRECORD, 0, new ModelResourceLocation("starrecord", "inventory"));
    		System.out.println("record registry name is = " + Items.STARRECORD.getRegistryName());
    		System.out.println("record unlocalized name is = " + Items.STARRECORD.getUnlocalizedName());
    }

    This needs to be new ModelResourceLocation("record.starrecord", "inventory").

×
×
  • Create New...

Important Information

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