Jump to content

MineModder2000

Members
  • Posts

    298
  • Joined

  • Last visited

Everything posted by MineModder2000

  1. OMG I got it working, but the instanceof check is not unnecessary, it already will be that. I just check for the correct type then add a goal.
  2. While I work on that, I need more understanding of this : "MobEntity#goalSelector is public. You can adjust it to your heart's content in EntityJoinWorldEvent." But how do I access that inside of the event?
  3. Oh sorry. I assume you mean Eclipse debugger, I'm not launching from Eclipse as I can't get that to work.
  4. I have confirmed the event is being called.
  5. Whoops I put the wrong code in my paste, I was testing something with that isSpawner check. As far as the setEntityType, that's just me playing around with things to try and get something to work. I've tried this, no check, just setting every instance Result to Allowed : @SubscribeEvent public void checkSpawn(CheckSpawn event) { event.setResult(Result.ALLOW); } Nopers....
  6. Tried this.... @SubscribeEvent public void checkSpawn(CheckSpawn event) { if (event.isSpawner()) { event.getSpawner().setEntityType(EntityType.ZOMBIE_PIGMAN); event.setResult(Result.ALLOW); } } Nopers....
  7. Hey hey, don't be rude. I read it before, always do, so don't assume things. I see what it says about the Result, but Result isn't in the class itself so I am confused. The RightClickBlock class has this for example : public void setUseBlock(Result triggerBlock) { this.useBlock = triggerBlock; } CheckSpawn doesn't have any of that, no setters at all......
  8. Chert_Entity Chert_Renderer Chert (Item) @Mod
  9. Okay got the spawn code : @SubscribeEvent public void potentialSpawns(PotentialSpawns event) { event.getList().add(new SpawnListEntry(EntityType.ZOMBIE_PIGMAN, 10, 3, 5)); } It doesn't work with that alone. I'm looking through CheckSpawn, not seeing any "can spawn" type method. I did try this : @SubscribeEvent public void checkSpawn(CheckSpawn event) { if (event.getEntity().getType() == EntityType.ZOMBIE_PIGMAN) { event.getSpawner().getSpawnerEntity().forceSpawn = true; } } But yeah it didn't work...
  10. ? This can't be what I have to do. I can make new mobs and spawn them in but vanilla mobs require me to do this?
  11. @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } I didn't know what to do exactly in there, it's what I meant to ask but I had a brain fart. I've seen this NetWorkHooks technique, somebody showed me there code that had this, but it doesn't work for me....
  12. package mymod.thrown; import lists.ItemList; import mymod.My_Mod; 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.network.IPacket; 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_Mod.Chert_Entity, throwerIn, 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 || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.DARK_OAK_LEAVES|| this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.ACACIA_LEAVES || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.BIRCH_LEAVES || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SPRUCE_LEAVES || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.JUNGLE_LEAVES || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.VINE || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_GRASS || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SEAGRASS || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_SEAGRASS || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.FERN || this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.LARGE_FERN || 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 ItemList.chert; } @Override public IPacket<?> createSpawnPacket() { return new SSpawnChertPacket(this); } } package mymod.thrown; import java.io.IOException; import java.util.UUID; import net.minecraft.client.network.play.IClientPlayNetHandler; import net.minecraft.entity.EntityType; import net.minecraft.network.IPacket; import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class SSpawnChertPacket implements IPacket<IClientPlayNetHandler> { private int entityId; private UUID uniqueId; private double x; private double y; private double z; private int speedX; private int speedY; private int speedZ; private int pitch; private int yaw; private EntityType<?> type; private int data; public SSpawnChertPacket(int p_i50777_1_, UUID p_i50777_2_, double p_i50777_3_, double p_i50777_5_, double p_i50777_7_, float p_i50777_9_, float p_i50777_10_, EntityType<?> p_i50777_11_, int p_i50777_12_, Vec3d p_i50777_13_) { this.entityId = p_i50777_1_; this.uniqueId = p_i50777_2_; this.x = p_i50777_3_; this.y = p_i50777_5_; this.z = p_i50777_7_; this.pitch = MathHelper.floor(p_i50777_9_ * 256.0F / 360.0F); this.yaw = MathHelper.floor(p_i50777_10_ * 256.0F / 360.0F); this.type = p_i50777_11_; this.data = p_i50777_12_; this.speedX = (int)(MathHelper.clamp(p_i50777_13_.x, -3.9D, 3.9D) * 8000.0D); this.speedY = (int)(MathHelper.clamp(p_i50777_13_.y, -3.9D, 3.9D) * 8000.0D); this.speedZ = (int)(MathHelper.clamp(p_i50777_13_.z, -3.9D, 3.9D) * 8000.0D); } public SSpawnChertPacket(Chert_Entity p_i50778_1_) { this(p_i50778_1_, 0); } public SSpawnChertPacket(Chert_Entity entityIn, int typeIn) { this(entityIn.getEntityId(), entityIn.getUniqueID(), entityIn.posX, entityIn.posY, entityIn.posZ, entityIn.rotationPitch, entityIn.rotationYaw, entityIn.getType(), typeIn, entityIn.getMotion()); } public SSpawnChertPacket(Chert_Entity p_i50779_1_, EntityType<Chert_Entity> p_i50779_2_, int p_i50779_3_, BlockPos p_i50779_4_) { this(p_i50779_1_.getEntityId(), p_i50779_1_.getUniqueID(), (double)p_i50779_4_.getX(), (double)p_i50779_4_.getY(), (double)p_i50779_4_.getZ(), p_i50779_1_.rotationPitch, p_i50779_1_.rotationYaw, p_i50779_2_, p_i50779_3_, p_i50779_1_.getMotion()); } /** * Reads the raw packet data from the data stream. */ @SuppressWarnings("deprecation") public void readPacketData(PacketBuffer buf) throws IOException { this.entityId = buf.readVarInt(); this.uniqueId = buf.readUniqueId(); this.type = Registry.ENTITY_TYPE.getByValue(buf.readVarInt()); this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); this.pitch = buf.readByte(); this.yaw = buf.readByte(); this.data = buf.readInt(); this.speedX = buf.readShort(); this.speedY = buf.readShort(); this.speedZ = buf.readShort(); } /** * Writes the raw packet data to the data stream. */ @SuppressWarnings("deprecation") public void writePacketData(PacketBuffer buf) throws IOException { buf.writeVarInt(this.entityId); buf.writeUniqueId(this.uniqueId); buf.writeVarInt(Registry.ENTITY_TYPE.getId(this.type)); buf.writeDouble(this.x); buf.writeDouble(this.y); buf.writeDouble(this.z); buf.writeByte(this.pitch); buf.writeByte(this.yaw); buf.writeInt(this.data); buf.writeShort(this.speedX); buf.writeShort(this.speedY); buf.writeShort(this.speedZ); } public void processPacket(IClientPlayNetHandler handler) { //handler.handleSpawnGlobalEntity(spear); } @OnlyIn(Dist.CLIENT) public int getEntityID() { return this.entityId; } @OnlyIn(Dist.CLIENT) public UUID getUniqueId() { return this.uniqueId; } @OnlyIn(Dist.CLIENT) public double getX() { return this.x; } @OnlyIn(Dist.CLIENT) public double getY() { return this.y; } @OnlyIn(Dist.CLIENT) public double getZ() { return this.z; } @OnlyIn(Dist.CLIENT) public double func_218693_g() { return (double)this.speedX / 8000.0D; } @OnlyIn(Dist.CLIENT) public double func_218695_h() { return (double)this.speedY / 8000.0D; } @OnlyIn(Dist.CLIENT) public double func_218692_i() { return (double)this.speedZ / 8000.0D; } @OnlyIn(Dist.CLIENT) public int getPitch() { return this.pitch; } @OnlyIn(Dist.CLIENT) public int getYaw() { return this.yaw; } @OnlyIn(Dist.CLIENT) public EntityType<?> getType() { return this.type; } @OnlyIn(Dist.CLIENT) public int getData() { return this.data; } } Still ain't chucking.
  13. Oh whoops I was looking into Entity instead of MobEntity. Keyword in addSpawn is PROTECTED, can't access. CheckSpawn class is static, but it's methods are not, so I can't access those either.
  14. Are you on a different version than 1.14.4? I'm not seeing any of these methods. Biome has addFeature, addCarver, and addStructure, but not addSpawn. I don't see any CheckSpawn or goalSelector in those other classes / events either.
  15. Okay now it's time to modify existing / vanilla mobs. I need to : Spawn mobs in the over-world that otherwise don't spawn there (nether mobs for example). Alter mob AI Spawn night mobs during the day, and have them not set on fire when exposed to sun rays.
  16. Kumbaya my lord, Kumbaya
  17. @SubscribeEvent public void rightClickBlock(RightClickBlock event) { if (event.getPlayer().getBlockState().getBlock() == Blocks.CRAFTING_TABLE) { event.setCanceled(true); } } Can't figure it out, this didn't work either....
  18. Update : Updating forge fixed the problem of the event not firing at all. But now I am trying to work the logic to disable right clicking on crafting tables. @SubscribeEvent public void rightClickBlock(RightClickBlock event) { if (event.getUseBlock().name().contains("crafting")) { event.setCanceled(true); } } Tried that and other variants with the string method, ain't working.
  19. Blaming you still ? Now how bouts we fix the rendering entity issue
  20. Oh dear oh my this is silly, and I blame thou. I copied it without even thinking, you edited it in your own post but I was somehow blind to it. I changed it to "==" now it works....
  21. Hmmm..... if (playerIn.ticksExisted - itemstack.getTag().getInt("tick_last") >= 16) { It can only be the itemstack.getTag. It works if I don't have the if check on : itemstack.setTag(new CompoundNBT()); So i guess that means getTag() isn't null to begin with, and thus the tag never gets initialized....
  22. Ain't a dang thang as getTagCompound method.....
  23. Already tried such (with various sub methods), but I get a java error. It doesn't like If I call getTag() before setTag() apparently...
  24. Actually I am confused on this part. i have this : public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); itemstack.setTag(new CompoundNBT()); if (playerIn.ticksExisted - itemstack.getTag().getInt("tick_last") >= 16) { itemstack.getTag().putInt("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)); if (!worldIn.isRemote) { Chert_Entity chert_entity = new Chert_Entity(worldIn, playerIn); chert_entity.func_213884_b(itemstack); chert_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F); worldIn.addEntity(chert_entity); } playerIn.addStat(Stats.ITEM_USED.get(this)); return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else return new ActionResult<>(ActionResultType.PASS, itemstack); } It works but I need the set tag to only happen once. I don't see any way to do that since I can't use external static variables, nor have variables stored in the class (to do one time boolean check run).
×
×
  • Create New...

Important Information

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