-
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
78fc389
commit 0de4261
Showing
38 changed files
with
39,322 additions
and
10 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
24 changes: 24 additions & 0 deletions
24
src/main/java/twopiradians/minewatch/client/model/ModelSoldierBullet.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,24 @@ | ||
package twopiradians.minewatch.client.model; | ||
|
||
import net.minecraft.client.model.ModelBase; | ||
import net.minecraft.client.model.ModelRenderer; | ||
import net.minecraft.entity.Entity; | ||
|
||
public class ModelSoldierBullet extends ModelBase { | ||
|
||
public ModelRenderer bullet; | ||
|
||
public ModelSoldierBullet() { | ||
this.textureWidth = 16; | ||
this.textureHeight = 16; | ||
|
||
this.bullet = new ModelRenderer(this); | ||
this.bullet.addBox(-0.5f, 0.5f, -1.5f, 1, 1, 3); | ||
this.bullet.setRotationPoint(0f, 0f, 0f); | ||
} | ||
|
||
@Override | ||
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { | ||
this.bullet.render(scale); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/twopiradians/minewatch/client/render/entity/RenderSoldierBullet.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,35 @@ | ||
package twopiradians.minewatch.client.render.entity; | ||
|
||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.entity.Render; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.util.ResourceLocation; | ||
import twopiradians.minewatch.client.model.ModelSoldierBullet; | ||
import twopiradians.minewatch.common.Minewatch; | ||
import twopiradians.minewatch.common.entity.EntitySoldierBullet; | ||
|
||
public class RenderSoldierBullet extends Render<EntitySoldierBullet> | ||
{ | ||
private final ModelSoldierBullet SOLDIER_BULLET_MODEL = new ModelSoldierBullet(); | ||
|
||
public RenderSoldierBullet(RenderManager renderManager) { | ||
super(renderManager); | ||
} | ||
|
||
@Override | ||
protected ResourceLocation getEntityTexture(EntitySoldierBullet entity) { | ||
return new ResourceLocation(Minewatch.MODID, "textures/entity/Soldier_bullet.png"); | ||
} | ||
|
||
@Override | ||
public void doRender(EntitySoldierBullet entity, double x, double y, double z, float entityYaw, float partialTicks) { | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate((float)x, (float)y, (float)z); | ||
GlStateManager.scale(0.1F, 0.1F, 0.1F); | ||
GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks, 0.0F, 1.0F, 0.0F); | ||
GlStateManager.rotate(-entity.rotationPitch, 1.0F, 0.0F, 0.0F); | ||
this.bindEntityTexture(entity); | ||
this.SOLDIER_BULLET_MODEL.render(entity, 0, 0, 0, 0, entity.rotationPitch, 0.5f); | ||
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
93 changes: 93 additions & 0 deletions
93
src/main/java/twopiradians/minewatch/common/entity/EntitySoldierBullet.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,93 @@ | ||
package twopiradians.minewatch.common.entity; | ||
|
||
import java.util.Arrays; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.projectile.EntityThrowable; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraft.util.EnumHand; | ||
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 EntitySoldierBullet extends EntityThrowable | ||
{ | ||
private static final int LIFETIME = 5; | ||
|
||
public EntitySoldierBullet(World worldIn) { | ||
super(worldIn); | ||
this.setNoGravity(true); | ||
this.setSize(0.1f, 0.1f); | ||
} | ||
|
||
//Client doesn't read here | ||
public EntitySoldierBullet(World worldIn, EntityLivingBase throwerIn, EnumHand hand) { | ||
super(worldIn, throwerIn); | ||
this.setNoGravity(true); | ||
this.setSize(0.1f, 0.1f); | ||
double velX = Math.cos(throwerIn.rotationPitch*Math.PI/180) * Math.cos(throwerIn.rotationYawHead*Math.PI/180 + Math.PI/2) + (Math.random() - 0.5d)*0.02d; | ||
double velY = - Math.sin(throwerIn.rotationPitch*Math.PI/180) + (Math.random() - 0.5d)*0.05d; | ||
double velZ = Math.cos(throwerIn.rotationPitch*Math.PI/180) * Math.sin(throwerIn.rotationYawHead*Math.PI/180 + Math.PI/2) + (Math.random() - 0.5d)*0.02d; | ||
double x = throwerIn.posX + Math.cos(throwerIn.rotationPitch*Math.PI/180)*Math.cos(throwerIn.rotationYawHead*Math.PI/180 + Math.PI/2); | ||
double y = throwerIn.posY + throwerIn.getEyeHeight() - Math.sin(throwerIn.rotationPitch*Math.PI/180); | ||
double z = throwerIn.posZ + Math.cos(throwerIn.rotationPitch*Math.PI/180)*Math.sin(throwerIn.rotationYawHead*Math.PI/180 + Math.PI/2); | ||
if (hand == EnumHand.MAIN_HAND) { | ||
x -= Math.cos(throwerIn.rotationYawHead*Math.PI/180)/2; | ||
y -= 0.25d - Math.sin(throwerIn.rotationPitch*Math.PI/180)/2; | ||
z -= Math.sin(throwerIn.rotationYawHead*Math.PI/180)/3; | ||
} | ||
else { | ||
x += Math.cos(throwerIn.rotationYawHead*Math.PI/180)/2; | ||
y -= 0.25d - Math.sin(throwerIn.rotationPitch*Math.PI/180)/2; | ||
z += Math.sin(throwerIn.rotationYawHead*Math.PI/180)/3; | ||
} | ||
this.setPosition(x, y, z); | ||
this.setRotation(0, 0); | ||
double speed = 5.0d; | ||
double speedNormalize = Math.sqrt(velX*velX + velY*velY + velZ*velZ); | ||
velX *= speed/speedNormalize; | ||
velY *= speed/speedNormalize; | ||
velZ *= speed/speedNormalize; | ||
this.motionX = velX; | ||
this.motionY = velY; | ||
this.motionZ = velZ; | ||
} | ||
|
||
@Override | ||
public void onUpdate() { | ||
float f = MathHelper.sqrt(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 != null && result.entityHit == this.getThrower()) | ||
return; | ||
else if (result.entityHit instanceof EntityLivingBase && this.getThrower() != null) { | ||
float damage = 19 - (19 - 5.7f) * (this.ticksExisted / LIFETIME); | ||
if (this.getThrower() instanceof EntityPlayer) | ||
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) this.getThrower()), damage/ModWeapon.DAMAGE_SCALE); | ||
else | ||
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage/ModWeapon.DAMAGE_SCALE); | ||
((EntityLivingBase)result.entityHit).hurtResistantTime = 0; | ||
this.setDead(); | ||
} | ||
else if (result.typeOfHit == RayTraceResult.Type.BLOCK) { | ||
Block block = this.world.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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/twopiradians/minewatch/common/item/armor/ItemSoldierArmor.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,10 @@ | ||
package twopiradians.minewatch.common.item.armor; | ||
|
||
import net.minecraft.inventory.EntityEquipmentSlot; | ||
|
||
public class ItemSoldierArmor extends ModArmor | ||
{ | ||
public ItemSoldierArmor(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) { | ||
super(materialIn, renderIndexIn, equipmentSlotIn); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/twopiradians/minewatch/common/item/weapon/ItemSoldierGun.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,64 @@ | ||
package twopiradians.minewatch.common.item.weapon; | ||
|
||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import twopiradians.minewatch.common.entity.EntitySoldierBullet; | ||
import twopiradians.minewatch.common.item.ModItems; | ||
import twopiradians.minewatch.common.item.armor.ModArmor; | ||
import twopiradians.minewatch.common.sound.ModSoundEvents; | ||
|
||
public class ItemSoldierGun extends ModWeapon | ||
{ | ||
public ItemSoldierGun() { | ||
super(); | ||
this.setMaxDamage(100); | ||
this.hasOffhand = false; | ||
this.material = ModItems.soldier; | ||
this.cooldown = 30; | ||
MinecraftForge.EVENT_BUS.register(this); | ||
} | ||
|
||
@Override | ||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { | ||
playerIn.setActiveHand(hand); | ||
return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand)); | ||
} | ||
|
||
@Override | ||
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) { | ||
if (!player.world.isRemote && player instanceof EntityPlayer) { | ||
if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() != Items.AIR && player.getHeldItemMainhand().getItem() instanceof ItemSoldierGun | ||
&& player.ticksExisted % 2 == 0) { | ||
player.world.spawnEntity(new EntitySoldierBullet(player.world, player, EnumHand.MAIN_HAND)); | ||
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSoundEvents.soldierGun, SoundCategory.PLAYERS, 1.0f, player.world.rand.nextFloat()/20+0.95f); | ||
if (count == 50 && !ModArmor.isSet((EntityPlayer)player, ModItems.tracer)) | ||
player.getHeldItemMainhand().damageItem(1, player); | ||
} | ||
else if (player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() != Items.AIR && player.getHeldItemOffhand().getItem() instanceof ItemSoldierGun | ||
&& player.ticksExisted % 2 == 0) { | ||
player.world.spawnEntity(new EntitySoldierBullet(player.world, player, EnumHand.OFF_HAND)); | ||
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSoundEvents.soldierGun, SoundCategory.PLAYERS, 1.0f, player.world.rand.nextFloat()/20+0.95f); | ||
if (count == 50 && !ModArmor.isSet((EntityPlayer)player, ModItems.tracer)) | ||
player.getHeldItemOffhand().damageItem(1, player); | ||
} | ||
|
||
if (count <= 1) | ||
doCooldown((EntityPlayer)player, player.getActiveHand()); | ||
} | ||
|
||
} | ||
|
||
/** How long it takes to use or consume an item*/ | ||
@Override | ||
public int getMaxItemUseDuration(ItemStack stack) { | ||
return 50; | ||
} | ||
} |
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.