-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
d7d5a0d
commit 15daaf6
Showing
38 changed files
with
365 additions
and
33 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
46 changes: 46 additions & 0 deletions
46
src/main/java/twopiradians/minewatch/client/render/entity/RenderGenjiShuriken.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,46 @@ | ||
package twopiradians.minewatch.client.render.entity; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.RenderItem; | ||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; | ||
import net.minecraft.client.renderer.entity.Render; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import twopiradians.minewatch.common.Minewatch; | ||
import twopiradians.minewatch.common.entity.EntityGenjiShuriken; | ||
import twopiradians.minewatch.common.item.ModItems; | ||
|
||
public class RenderGenjiShuriken extends Render<EntityGenjiShuriken> | ||
{ | ||
private final RenderItem itemRenderer; | ||
|
||
public RenderGenjiShuriken(RenderManager renderManager) { | ||
super(renderManager); | ||
this.itemRenderer = Minecraft.getMinecraft().getRenderItem(); | ||
} | ||
|
||
public ItemStack getStackToRender(EntityGenjiShuriken entityIn) { | ||
return new ItemStack(ModItems.genji_shuriken); | ||
} | ||
|
||
protected ResourceLocation getEntityTexture(EntityGenjiShuriken entity) { | ||
return new ResourceLocation(Minewatch.MODID, "textures/entity/genji_shuriken.png"); | ||
} | ||
|
||
@Override | ||
public void doRender(EntityGenjiShuriken entity, double x, double y, double z, float entityYaw, float partialTicks) { | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate((float)x, (float)y+.05f, (float)z); | ||
GlStateManager.enableRescaleNormal(); | ||
GlStateManager.scale(0.5d, 0.5d, 0.5d); | ||
GlStateManager.rotate(entity.ticksExisted*60, 0.0F, 1.0F, 0.0F); | ||
GlStateManager.rotate(90, 1, 0, 0); | ||
|
||
this.itemRenderer.renderItem(this.getStackToRender(entity), ItemCameraTransforms.TransformType.GROUND); | ||
|
||
GlStateManager.disableRescaleNormal(); | ||
GlStateManager.popMatrix(); | ||
} | ||
} |
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
87 changes: 87 additions & 0 deletions
87
src/main/java/twopiradians/minewatch/common/entity/EntityGenjiShuriken.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,87 @@ | ||
package twopiradians.minewatch.common.entity; | ||
|
||
import java.util.Arrays; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.projectile.EntityThrowable; | ||
import net.minecraft.init.SoundEvents; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.RayTraceResult; | ||
import net.minecraft.world.World; | ||
import twopiradians.minewatch.common.item.weapon.ModWeapon; | ||
|
||
public class EntityGenjiShuriken extends EntityThrowable | ||
{ | ||
private static final int LIFETIME = 40; | ||
|
||
public EntityGenjiShuriken(World worldIn) { | ||
super(worldIn); | ||
this.setNoGravity(true); | ||
this.setSize(0.1f, 0.1f); | ||
} | ||
|
||
//Client doesn't read here | ||
public EntityGenjiShuriken(World worldIn, EntityLivingBase throwerIn) { | ||
super(worldIn, throwerIn); | ||
this.setNoGravity(true); | ||
this.setSize(0.1f, 0.1f); | ||
this.setPosition(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ); | ||
} | ||
|
||
/**Copied from EntityArrow*/ | ||
public void setAim(Entity shooter, float pitch, float yaw, float velocity, float inaccuracy) { | ||
float f = -MathHelper.sin(yaw * (float)Math.PI/180) * MathHelper.cos(pitch * (float)Math.PI/180); | ||
float f1 = -MathHelper.sin(pitch * (float)Math.PI/180); | ||
float f2 = MathHelper.cos(yaw * (float)Math.PI/180) * MathHelper.cos(pitch * (float)Math.PI/180); | ||
this.setThrowableHeading((double)f, (double)f1, (double)f2, velocity, inaccuracy); | ||
this.motionX += shooter.motionX; | ||
this.motionZ += shooter.motionZ; | ||
this.prevRotationPitch = pitch; | ||
this.prevRotationYaw = yaw; | ||
this.setRotation(yaw, pitch); | ||
|
||
if (!shooter.onGround) { | ||
this.motionY += shooter.motionY; | ||
} | ||
} | ||
|
||
@Override | ||
public void onUpdate() { | ||
float f = MathHelper.sqrt_float((float) (this.motionX * this.motionX + this.motionZ * this.motionZ)); | ||
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI)); | ||
this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); | ||
this.prevRotationYaw = this.rotationYaw; | ||
this.prevRotationPitch = this.rotationPitch; | ||
super.onUpdate(); | ||
|
||
if (this.ticksExisted > LIFETIME) | ||
this.setDead(); | ||
} | ||
|
||
@Override | ||
protected void onImpact(RayTraceResult result) { | ||
if (result.entityHit instanceof EntityLivingBase && this.getThrower() != null && result.entityHit != this.getThrower()) { | ||
if (this.getThrower() instanceof EntityPlayer) | ||
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) this.getThrower()), 28F/ModWeapon.DAMAGE_SCALE); | ||
else | ||
if (this.getThrower() instanceof EntityPlayer) | ||
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 28F/ModWeapon.DAMAGE_SCALE); | ||
if (this.getThrower() != null) | ||
result.entityHit.worldObj.playSound(null, this.getThrower().posX, this.getThrower().posY, this.getThrower().posZ, | ||
SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.3f, result.entityHit.worldObj.rand.nextFloat()/2+0.75f); | ||
((EntityLivingBase)result.entityHit).hurtResistantTime = 0; | ||
this.setDead(); | ||
} | ||
else if (result.typeOfHit == RayTraceResult.Type.BLOCK) { | ||
Block block = this.worldObj.getBlockState(result.getBlockPos()).getBlock(); | ||
|
||
if (!Arrays.asList(ModEntities.ENTITY_PASSES_THROUGH).contains(block)) | ||
this.setDead(); | ||
} | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/twopiradians/minewatch/common/entity/ModEntities.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 |
---|---|---|
@@ -1,14 +1,22 @@ | ||
package twopiradians.minewatch.common.entity; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraftforge.fml.common.registry.EntityRegistry; | ||
import twopiradians.minewatch.common.Minewatch; | ||
|
||
public class ModEntities | ||
{ | ||
public static final Block[] ENTITY_PASSES_THROUGH = | ||
{Blocks.TALLGRASS, Blocks.VINE, Blocks.RED_FLOWER, Blocks.YELLOW_FLOWER, Blocks.BROWN_MUSHROOM, | ||
Blocks.RED_MUSHROOM, Blocks.REEDS, Blocks.DOUBLE_PLANT, Blocks.DEADBUSH, Blocks.WHEAT, | ||
Blocks.WATERLILY, Blocks.CARROTS, Blocks.POTATOES, Blocks.SNOW_LAYER}; | ||
|
||
public static void registerEntities() { | ||
int id = 0; | ||
EntityRegistry.registerModEntity(EntityReaperBullet.class, "reaper_pellet", id++, Minewatch.instance, 16, 1, true); | ||
EntityRegistry.registerModEntity(EntityHanzoArrow.class, "hanzo_arrow", id++, Minewatch.instance, 16, 1, true); | ||
EntityRegistry.registerModEntity(EntityAnaBullet.class, "ana_bullet", id++, Minewatch.instance, 32, 1, true); | ||
EntityRegistry.registerModEntity(EntityGenjiShuriken.class, "genji_shuriken", id++, Minewatch.instance, 32, 1, true); | ||
} | ||
} |
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.