-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
218 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/its_meow/betteranimalsplus/common/entity/projectile/EntityPheasantEgg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package its_meow.betteranimalsplus.common.entity.projectile; | ||
|
||
import its_meow.betteranimalsplus.init.ModEntities; | ||
import its_meow.betteranimalsplus.init.ModItems; | ||
import net.minecraft.entity.EntityClassification; | ||
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.EntityRayTraceResult; | ||
import net.minecraft.util.math.RayTraceResult; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import net.minecraftforge.fml.network.NetworkHooks; | ||
|
||
public class EntityPheasantEgg extends ProjectileItemEntity { | ||
public static EntityType<EntityPheasantEgg> PHEASANT_EGG_TYPE = ModEntities.<EntityPheasantEgg>createEntityType(EntityPheasantEgg.class, EntityPheasantEgg::new, "pheasant_egg", EntityClassification.MISC, 64, 1, true, 0.25F, 0.25F); | ||
|
||
public EntityPheasantEgg(World p_i50154_2_) { | ||
super(PHEASANT_EGG_TYPE, p_i50154_2_); | ||
} | ||
|
||
public EntityPheasantEgg(EntityType<? extends EntityPheasantEgg> p_i50154_1_, World p_i50154_2_) { | ||
super(p_i50154_1_, p_i50154_2_); | ||
} | ||
|
||
public EntityPheasantEgg(World worldIn, LivingEntity throwerIn) { | ||
super(PHEASANT_EGG_TYPE, throwerIn, worldIn); | ||
} | ||
|
||
public EntityPheasantEgg(World worldIn, double x, double y, double z) { | ||
super(PHEASANT_EGG_TYPE, x, y, z, worldIn); | ||
} | ||
|
||
@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); | ||
} | ||
} | ||
|
||
} | ||
|
||
protected void onImpact(RayTraceResult result) { | ||
if(result.getType() == RayTraceResult.Type.ENTITY) { | ||
((EntityRayTraceResult) result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); | ||
} | ||
|
||
if(!this.world.isRemote) { | ||
/*if(this.rand.nextInt(8) == 0) { | ||
int i = 1; | ||
if(this.rand.nextInt(32) == 0) { | ||
i = 4; | ||
} | ||
for(int j = 0; j < i; ++j) { | ||
ChickenEntity chickenentity = EntityType.CHICKEN.create(this.world); | ||
chickenentity.setGrowingAge(-24000); | ||
chickenentity.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); | ||
this.world.addEntity(chickenentity); | ||
// TODO: redo entity types so less annoying | ||
} | ||
}*/ | ||
|
||
this.world.setEntityState(this, (byte) 3); | ||
this.remove(); | ||
} | ||
|
||
} | ||
|
||
protected Item func_213885_i() { | ||
return ModItems.PHEASANT_EGG; | ||
} | ||
|
||
@Override | ||
public IPacket<?> createSpawnPacket() { | ||
return NetworkHooks.getEntitySpawningPacket(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/its_meow/betteranimalsplus/common/item/ItemThrowableCustomEgg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package its_meow.betteranimalsplus.common.item; | ||
|
||
import java.util.function.Function; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.projectile.ProjectileItemEntity; | ||
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 ItemThrowableCustomEgg extends ItemNamedSimple { | ||
|
||
private Function<PlayerEntity, ProjectileItemEntity> eggSupplier; | ||
|
||
public ItemThrowableCustomEgg(String name, Function<PlayerEntity, ProjectileItemEntity> egg) { | ||
super(name, new Item.Properties().maxStackSize(16)); | ||
this.eggSupplier = egg; | ||
} | ||
|
||
@Override | ||
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { | ||
ItemStack itemstack = playerIn.getHeldItem(handIn); | ||
|
||
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) { | ||
ProjectileItemEntity ent = eggSupplier.apply(playerIn); | ||
ent.func_213884_b(itemstack); | ||
ent.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); | ||
worldIn.addEntity(ent); | ||
} | ||
|
||
playerIn.addStat(Stats.ITEM_USED.get(this)); | ||
return new ActionResult<>(ActionResultType.SUCCESS, itemstack); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.