Skip to content

Commit

Permalink
Added Soldier
Browse files Browse the repository at this point in the history
  • Loading branch information
2piradians committed Jul 13, 2017
1 parent 78fc389 commit 0de4261
Show file tree
Hide file tree
Showing 38 changed files with 39,322 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.11.2-2.1"
version = "1.11.2-2.2"
group = "twopiradians.minewatch" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Minewatch"

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/twopiradians/minewatch/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import twopiradians.minewatch.client.render.entity.RenderGenjiShuriken;
import twopiradians.minewatch.client.render.entity.RenderMcCreeBullet;
import twopiradians.minewatch.client.render.entity.RenderReaperBullet;
import twopiradians.minewatch.client.render.entity.RenderSoldierBullet;
import twopiradians.minewatch.client.render.entity.RenderTracerBullet;
import twopiradians.minewatch.common.CommonProxy;
import twopiradians.minewatch.common.Minewatch;
Expand All @@ -36,6 +37,7 @@
import twopiradians.minewatch.common.entity.EntityHanzoArrow;
import twopiradians.minewatch.common.entity.EntityMcCreeBullet;
import twopiradians.minewatch.common.entity.EntityReaperBullet;
import twopiradians.minewatch.common.entity.EntitySoldierBullet;
import twopiradians.minewatch.common.entity.EntityTracerBullet;
import twopiradians.minewatch.common.item.ModItems;

Expand Down Expand Up @@ -106,6 +108,7 @@ private void registerEntityRenders() {
RenderingRegistry.registerEntityRenderingHandler(EntityGenjiShuriken.class, RenderGenjiShuriken::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTracerBullet.class, RenderTracerBullet::new);
RenderingRegistry.registerEntityRenderingHandler(EntityMcCreeBullet.class, RenderMcCreeBullet::new);
RenderingRegistry.registerEntityRenderingHandler(EntitySoldierBullet.class, RenderSoldierBullet::new);
}

@Override
Expand Down
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);
}
}
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();
}
}
7 changes: 7 additions & 0 deletions src/main/java/twopiradians/minewatch/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,12 @@ private void registerCraftingRecipes() {
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.mccree_leggings), new ItemStack(ModItems.mccree_token), new ItemStack(Items.IRON_LEGGINGS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.mccree_boots), new ItemStack(ModItems.mccree_token), new ItemStack(Items.IRON_BOOTS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.mccree_gun), new ItemStack(ModItems.mccree_token));

//Soldier
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.soldier_helmet), new ItemStack(ModItems.soldier_token), new ItemStack(Items.IRON_HELMET, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.soldier_chestplate), new ItemStack(ModItems.soldier_token), new ItemStack(Items.IRON_CHESTPLATE, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.soldier_leggings), new ItemStack(ModItems.soldier_token), new ItemStack(Items.IRON_LEGGINGS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.soldier_boots), new ItemStack(ModItems.soldier_token), new ItemStack(Items.IRON_BOOTS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.soldier_gun), new ItemStack(ModItems.soldier_token));
}
}
2 changes: 1 addition & 1 deletion src/main/java/twopiradians/minewatch/common/Minewatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Minewatch
{
public static final String MODNAME = "Minewatch";
public static final String MODID = "minewatch";
public static final String VERSION = "2.1";
public static final String VERSION = "2.2";
@Mod.Instance(MODID)
public static Minewatch instance;
public static MinewatchTab tab = new MinewatchTab("tabMinewatch");
Expand Down
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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public static void registerEntities() {
EntityRegistry.registerModEntity(new ResourceLocation(Minewatch.MODID, "genji_shuriken"), EntityGenjiShuriken.class, "genji_shuriken", id++, Minewatch.instance, 32, 1, true);
EntityRegistry.registerModEntity(new ResourceLocation(Minewatch.MODID, "tracer_bullet"), EntityTracerBullet.class, "tracer_bullet", id++, Minewatch.instance, 16, 1, true);
EntityRegistry.registerModEntity(new ResourceLocation(Minewatch.MODID, "mccree_bullet"), EntityMcCreeBullet.class, "mccree_bullet", id++, Minewatch.instance, 16, 1, true);
EntityRegistry.registerModEntity(new ResourceLocation(Minewatch.MODID, "soldier_bullet"), EntitySoldierBullet.class, "soldier_bullet", id++, Minewatch.instance, 16, 1, true);
}
}
19 changes: 18 additions & 1 deletion src/main/java/twopiradians/minewatch/common/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
import twopiradians.minewatch.common.item.armor.ItemMcCreeArmor;
import twopiradians.minewatch.common.item.armor.ItemReaperArmor;
import twopiradians.minewatch.common.item.armor.ItemReinhardtArmor;
import twopiradians.minewatch.common.item.armor.ItemSoldierArmor;
import twopiradians.minewatch.common.item.armor.ItemTracerArmor;
import twopiradians.minewatch.common.item.weapon.ItemAnaRifle;
import twopiradians.minewatch.common.item.weapon.ItemGenjiShuriken;
import twopiradians.minewatch.common.item.weapon.ItemHanzoBow;
import twopiradians.minewatch.common.item.weapon.ItemMcCreeGun;
import twopiradians.minewatch.common.item.weapon.ItemReaperShotgun;
import twopiradians.minewatch.common.item.weapon.ItemReinhardtHammer;
import twopiradians.minewatch.common.item.weapon.ItemSoldierGun;
import twopiradians.minewatch.common.item.weapon.ItemTracerPistol;

public class ModItems {
Expand Down Expand Up @@ -72,7 +74,7 @@ public class ModItems {
public static Item genji_shuriken_single; // used for projectile
public static Item genji_token;

public static ArmorMaterial tracer = EnumHelper.addArmorMaterial("tracer", "minewatch:tracer", 20, new int[] {2,3,3,2}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0);
public static ArmorMaterial tracer = EnumHelper.addArmorMaterial("tracer", "minewatch:tracer", 20, new int[] {2,2,2,2}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0);
public static Item tracer_helmet;
public static Item tracer_chestplate;
public static Item tracer_leggings;
Expand All @@ -87,6 +89,14 @@ public class ModItems {
public static Item mccree_boots;
public static Item mccree_gun;
public static Item mccree_token;

public static ArmorMaterial soldier = EnumHelper.addArmorMaterial("soldier", "minewatch:soldier", 20, new int[] {2,3,3,2}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0);
public static Item soldier_helmet;
public static Item soldier_chestplate;
public static Item soldier_leggings;
public static Item soldier_boots;
public static Item soldier_gun;
public static Item soldier_token;

public static void preInit () {
reaper_helmet = registerItem(new ItemReaperArmor(reaper, 0, EntityEquipmentSlot.HEAD), "reaper_helmet", true, false);
Expand Down Expand Up @@ -138,6 +148,13 @@ public static void preInit () {
mccree_boots = registerItem(new ItemMcCreeArmor(mccree, 0, EntityEquipmentSlot.FEET), "mccree_boots", true, false);
mccree_gun = registerItem(new ItemMcCreeGun(), "mccree_gun", true, true);
mccree_token = registerItem(new ModTokens.ItemMcCreeToken(), "mccree_token", true, false);

soldier_helmet = registerItem(new ItemSoldierArmor(soldier, 0, EntityEquipmentSlot.HEAD), "soldier_helmet", true, false);
soldier_chestplate = registerItem(new ItemSoldierArmor(soldier, 0, EntityEquipmentSlot.CHEST), "soldier_chestplate", true, false);
soldier_leggings = registerItem(new ItemSoldierArmor(soldier, 0, EntityEquipmentSlot.LEGS), "soldier_leggings", true, false);
soldier_boots = registerItem(new ItemSoldierArmor(soldier, 0, EntityEquipmentSlot.FEET), "soldier_boots", true, false);
soldier_gun = registerItem(new ItemSoldierGun(), "soldier_gun", true, true);
soldier_token = registerItem(new ModTokens.ItemMcCreeToken(), "soldier_token", true, false);
}

private static Item registerItem(Item item, String unlocalizedName, boolean addToTab, boolean usesObjModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public static class ItemGenjiToken extends ModTokens {}
public static class ItemTracerToken extends ModTokens {}

public static class ItemMcCreeToken extends ModTokens {}

public static class ItemSoldierToken extends ModTokens {}
}
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);
}
}
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ModSoundEvents {
public static SoundEvent genjiShuriken;
public static SoundEvent tracerPistol;
public static SoundEvent mccreeGun;
public static SoundEvent soldierGun;

public static void preInit() {
reaperShotgun = registerSound("reaper_shotguns");
Expand All @@ -23,7 +24,7 @@ public static void preInit() {
genjiShuriken = registerSound("genji_shuriken");
tracerPistol = registerSound("tracer_pistol");
mccreeGun = registerSound("mccree_gun");

soldierGun = registerSound("soldier_gun");
}

private static SoundEvent registerSound(String soundName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"scale": [ 0.4, 0.4, 0.4 ]
},
"gui": {
"rotation": [ { "x": 13 }, { "y": 205 }, { "z": 0 } ],
"translation": [ -0.2, 0.25, 0 ],
"scale": [ 0.75, 0.75, 0.75 ]
"rotation": [ { "x": -167 }, { "y": -90 }, { "z": -180 } ],
"translation": [ 0.1, 0.2, 0.0 ],
"scale": [ 0.4, 0.4, 0.4 ]
},
"firstperson_righthand": {
"rotation": [ { "x": 0 }, { "y": 180 }, { "z": 0 } ],
Expand Down
Loading

0 comments on commit 0de4261

Please sign in to comment.