Jump to content

MineModder2000

Members
  • Posts

    298
  • Joined

  • Last visited

Everything posted by MineModder2000

  1. I didn't register a renderer for the entity, because it was working without one (except for the egg issue). Actually I am not seeing any EggRenderer, I don't think it needs one... Yes for the item. Good question, I just fixed the redundancy. Yeah I saw that initially but when I change it every toss was an egg, instead of just the last one. @SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) { LOGGER.debug("Hello from Register Entities"); event.getRegistry().registerAll( Chert_Entity = register("chert", EntityType.Builder.<Chert_Entity>create(Chert_Entity::new, EntityClassification.MISC).size(0.25F, 0.25F)) //EntityType.Builder.<Chert_Entity>create(Chert_Entity::new, EntityClassification.MISC).build("chert").setRegistryName("mymod", "chert") ); } @SuppressWarnings("deprecation") private static <T extends Entity> EntityType<T> register(String key, EntityType.Builder<T> builder) { return Registry.register(Registry.ENTITY_TYPE, key, builder.build(key)); } That's ^ in my main mode file, and yes I have "public static EntityType<Chert_Entity> Chert_Entity" above. I'm not what to do next, it's still not showing up. I don't see a renderer for the egg...
  2. Hmm, but why only the last one. How was it actually rendering my entity without that? So I did this now (I renamed things) : package mymod; import mymod.thrown.Chert_Entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.registry.Registry; public class My_Entity { public static final EntityType<Chert_Entity> Chert_Entity = register("chert", EntityType.Builder.<Chert_Entity>create(Chert_Entity::new, EntityClassification.MISC).size(0.25F, 0.25F)); @SuppressWarnings("deprecation") private static <T extends Entity> EntityType<T> register(String key, EntityType.Builder<T> builder) { return Registry.register(Registry.ENTITY_TYPE, key, builder.build(key)); } } package mymod.thrown; import mymod.My_Entity; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.ProjectileItemEntity; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class Chert_Entity extends ProjectileItemEntity { // Copies EggEntity private float damage = 2.5F; public Chert_Entity(EntityType<? extends Chert_Entity> p_i50154_1_, World p_i50154_2_) { super(p_i50154_1_, p_i50154_2_); } public Chert_Entity(World worldIn, LivingEntity throwerIn) { super(My_Entity.Chert_Entity, throwerIn, worldIn); } public Chert_Entity(World worldIn, double x, double y, double z) { super(My_Entity.Chert_Entity, x, y, z, worldIn); } /** * Handler for {@link World#setEntityState} */ @OnlyIn(Dist.CLIENT) public void handleStatusUpdate(byte id) { if (id == 3) { for(int i = 0; i < 8; ++i) { this.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, this.getItem()), this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D); } } } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.OAK_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.DARK_OAK_LEAVES|| result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.ACACIA_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.BIRCH_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SPRUCE_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.JUNGLE_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.VINE || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_GRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SEAGRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_SEAGRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.FERN || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.LARGE_FERN || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SUGAR_CANE) { System.out.println("no"); } else { if (result.getType() == RayTraceResult.Type.ENTITY) { ((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); } this.world.setEntityState(this, (byte)3); this.remove(); } } protected Item func_213885_i() { return Items.EGG; } } My_Entity is initialized in my main mod file. It all works fine, except no entity / texture is thrown....... And yes I have a model and texture file named chert.json. These were previously named throw_stone and worked when I had EntityType.EGG in the code, which I still don't understand.
  3. Okay I did it a different way, which seems to work. But I still have the problem of the last projectile thrown being an egg....
  4. I want to know how to make blocks / objects that are crafted in the world, rather than in the grid. I am talking about the way nether portals and iron golems are crafted in the world by placing blocks. Also doing things like converting blocks with right clicks such as stripping logs with axes.
  5. Need help with this again. So my throwable entity works fine, some of the time, but I have it coded so that it can only thrown at certain intervals and not at the rapid pace that eggs and snowballs can be thrown at. However it still does the item chucking animation rapidly, which looks odd. I discovered that this was the result of the return type, which had to have a PASS rather than SUCCESS parameter whenever the item wasn't be thrown. But my code doesn't work all the time, and occasionally I can't throw the item anymore. Also the last item thrown from the stack is still an egg, instead of my custom entity / texture. package mymod.thrown; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; public class Throw_Stone extends Item { // Copies EggItem private int tick_last, delay; public Throw_Stone(Item.Properties builder) { super(builder); delay = 16; } /** * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see * {@link #onItemUse}. */ public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.ticksExisted - tick_last >= delay) { tick_last = playerIn.ticksExisted; if (!playerIn.abilities.isCreativeMode) { itemstack.shrink(1); } worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); Throw_Stone_Entity throw_stone_entity = new Throw_Stone_Entity(worldIn, playerIn); throw_stone_entity.func_213884_b(itemstack); throw_stone_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F); worldIn.addEntity(throw_stone_entity); playerIn.addStat(Stats.ITEM_USED.get(this)); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else return new ActionResult<>(ActionResultType.PASS, itemstack); } } package mymod.thrown; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.ProjectileItemEntity; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class Throw_Stone_Entity extends ProjectileItemEntity { // Copies EggEntity private float damage = 2.5F; public Throw_Stone_Entity(EntityType<? extends Throw_Stone_Entity> p_i50154_1_, World p_i50154_2_) { super(p_i50154_1_, p_i50154_2_); } public Throw_Stone_Entity(World worldIn, LivingEntity throwerIn) { super(EntityType.EGG, throwerIn, worldIn); } public Throw_Stone_Entity(World worldIn, double x, double y, double z) { super(EntityType.EGG, x, y, z, worldIn); } /** * Handler for {@link World#setEntityState} */ @OnlyIn(Dist.CLIENT) public void handleStatusUpdate(byte id) { if (id == 3) { for(int i = 0; i < 8; ++i) { this.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, this.getItem()), this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D); } } } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.OAK_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.DARK_OAK_LEAVES|| result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.ACACIA_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.BIRCH_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SPRUCE_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.JUNGLE_LEAVES || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.VINE || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_GRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SEAGRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_SEAGRASS || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.FERN || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.LARGE_FERN || result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SUGAR_CANE) { System.out.println("no"); } else { if (result.getType() == RayTraceResult.Type.ENTITY) { ((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); } this.world.setEntityState(this, (byte)3); this.remove(); } } protected Item func_213885_i() { return Items.EGG; } }
  6. Thanks guys, I will consider if this is what I want to do, else I will do the json overriding technique instead.
  7. Not seeing any methods beyond this that allow for specific entry removal..... event.getTable().getPool("main")
  8. I tried this, with and without the "item" before "leather", to no avail. @SubscribeEvent public void lootTableLoadEvent(LootTableLoadEvent event) { if (event.getName().getPath().equals("entities/horse")) { event.getTable().removePool("item/leather"); } }
  9. The below code isn't cancelling the loot. if (event.getName().getNamespace().equals("entities/iron_golem")) { event.setCanceled(true); }
  10. You don't get it, my mod isn't going to have any iron ingots and some other things from vanilla, if somebody wanted such they wouldn't play my mod. Why would I remove a loot item from vanilla only to have it appear in other mods? I am getting rid of it for a reason. You are helpful but you really don't have to be snide / snarky, I thought you meant this procedure wouldn't work in general, hence my test. I forgot about using the method instead of == operator, I am used to comparing object types in my mod. Well anyways this didn't work as iron golems still drop iron ingots : @SubscribeEvent public void lootTableLoadEvent(LootTableLoadEvent event) { if (event.getName().getNamespace().equals("iron_ingot")) { event.setCanceled(true); } } Assuming this applies to entities.....
  11. This is false, I just did it without the if statement check and it worked. I found a village in creative mode and all the chests were empty. Why in the world would this severely affect other mods?
  12. I see. I found the loot tables, and there are a lot. I think I would rather just prevent the spawning of the ones that are game breaking when it comes to the balance of my mod. Would this would work as I have it : @SubscribeEvent public void lootTableLoadEvent(LootTableLoadEvent event) { if (event.getName().getNamespace() == "iron_ingot") { event.setCanceled(true); } }
  13. I want certain things not to spawn, as they don't fit with my mod. I may add my own later, but for now I want to remove some.
  14. How to modify what loot spawns in chests? I see there is LootTableLoadEvent, but I want to change chest loots specifically.
  15. I am having a java error with this, I am asking on java forums as I am not familiar with lambas and some other advanced concepts. I will report back here later.
  16. Thanks, looking back you actually told me this before, but I didn't understand events. Now I do and it's super easy ?
  17. Back to removing vanilla mobs / creatures. I need to remove specific mobs, such as cows, sheep, pigs, chickens, and all the enemy mobs (zombie, skeleton, etc.) so I can replace them with my own (that I still have to make).
  18. Ah I got it now, i figured out the correct logic and it works as intended. Actually it is, Block.Grass, Block.Tall_Grass, etc. are the vegetation blocks that I need to be ignored, and now they are. Thanks for bearing with me.
  19. Actually with this code as the check alone : (result.getType() == RayTraceResult.Type.ENTITY) That line causes the throwable to break against anything, dirt, sand, leaves, grass, flowers, etc. I want it to pass through grass and leaves.
  20. Oh boy, this is a face palm for me ?. I had it written differently last night, and it wasn't working so I tried to test that line alone to see what would happen, forgetting the different types / casting. Chalk it up to late night brain fog. I have this now : if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS) { System.out.println("no"); } else if (result.getType() == RayTraceResult.Type.ENTITY) { ((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); this.world.setEntityState(this, (byte)3); this.remove(); } But it's going through all blocks, not just grass.
  21. Ah I see. Well I am trying this just as a test but getting console error : if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS) { ((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); this.world.setEntityState(this, (byte)3); this.remove(); } It's too much to even post.
  22. Yes I am familiar with this method and have already explored this, but could not figure out any way to check for such. RayTraceResult.Type.BLOCK The block variable here is not the same as the Block class, so it doesn't have "is passable" and related methods, and cannot be compared to grass blocks and such. Sorry I should've mentioned all this in the OP.
  23. I created my own throwable entity by copying (not extending) the EggItem and EggEntity classes. All works great, however the item breaks when hitting grass (as eggs do) when I want it to go through (like arrows and tridents do). Anyone have any idea how to make this happen? It just needs to ignore grasses...
  24. I got the pack to work, I think this is a better idea since it'll be a choice and not forced upon users. Thanks for helping.
  25. I did read it obviously, just not carefully enough though. I got to detect now, the screenshot was a mistake, wrong link, I have the correct one up.
×
×
  • Create New...

Important Information

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