Skip to content

Commit

Permalink
added genji
Browse files Browse the repository at this point in the history
  • Loading branch information
2piradians committed May 18, 2017
1 parent d7d5a0d commit 15daaf6
Show file tree
Hide file tree
Showing 38 changed files with 365 additions and 33 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 nessasary things for Forge to be setup.


version = "1.10.2-1.0"
version = "1.10.2-1.1"
group = "twopiradians.minewatch" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Minewatch"

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/twopiradians/minewatch/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import twopiradians.minewatch.client.key.KeyToggleMode;
import twopiradians.minewatch.client.particle.ParticleHealthPlus;
import twopiradians.minewatch.client.render.entity.RenderAnaBullet;
import twopiradians.minewatch.client.render.entity.RenderGenjiShuriken;
import twopiradians.minewatch.client.render.entity.RenderReaperBullet;
import twopiradians.minewatch.common.CommonProxy;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityAnaBullet;
import twopiradians.minewatch.common.entity.EntityGenjiShuriken;
import twopiradians.minewatch.common.entity.EntityHanzoArrow;
import twopiradians.minewatch.common.entity.EntityReaperBullet;
import twopiradians.minewatch.common.item.ModItems;
Expand All @@ -46,24 +48,25 @@ public void init(FMLInitializationEvent event) {
public void postInit(FMLPostInitializationEvent event) {
super.postInit(event);
}

private void registerEntityRenders() {
RenderingRegistry.registerEntityRenderingHandler(EntityReaperBullet.class, RenderReaperBullet::new);
RenderingRegistry.registerEntityRenderingHandler(EntityHanzoArrow.class, RenderTippedArrow::new);
RenderingRegistry.registerEntityRenderingHandler(EntityAnaBullet.class, RenderAnaBullet::new);
RenderingRegistry.registerEntityRenderingHandler(EntityGenjiShuriken.class, RenderGenjiShuriken::new);
}

@Override
protected void registerEventListeners() {
super.registerEventListeners();
MinecraftForge.EVENT_BUS.register(this);
}

@SubscribeEvent
public void stitcherEventPre(TextureStitchEvent.Pre event) {
event.getMap().registerSprite(ParticleHealthPlus.TEXTURE);
}

@Override
public void spawnParticlesHealthPlus(World worldIn, double x, double y, double z, double motionX, double motionY, double motionZ, float scale) {
ParticleHealthPlus particle = new ParticleHealthPlus(worldIn, x, y, z, motionX, motionY, motionZ, scale);
Expand Down
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();
}
}
11 changes: 9 additions & 2 deletions src/main/java/twopiradians/minewatch/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void registerEventListeners() {
MinecraftForge.EVENT_BUS.register(new ModTokens());
MinecraftForge.EVENT_BUS.register(new ModWeapon());
}

private void registerCraftingRecipes() {
RecipeSorter.register("Matching Damage Recipe", ShapelessMatchingDamageRecipe.class, Category.SHAPELESS, "");

Expand All @@ -57,7 +57,7 @@ private void registerCraftingRecipes() {
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.ana_leggings), new ItemStack(ModItems.ana_token), new ItemStack(Items.IRON_LEGGINGS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.ana_boots), new ItemStack(ModItems.ana_token), new ItemStack(Items.IRON_BOOTS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.ana_rifle), new ItemStack(ModItems.ana_token));

//Hanzo
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.hanzo_helmet), new ItemStack(ModItems.hanzo_token), new ItemStack(Items.IRON_HELMET, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.hanzo_chestplate), new ItemStack(ModItems.hanzo_token), new ItemStack(Items.IRON_CHESTPLATE, 1, OreDictionary.WILDCARD_VALUE)));
Expand All @@ -78,5 +78,12 @@ private void registerCraftingRecipes() {
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.reinhardt_leggings), new ItemStack(ModItems.reinhardt_token), new ItemStack(Items.IRON_LEGGINGS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.reinhardt_boots), new ItemStack(ModItems.reinhardt_token), new ItemStack(Items.IRON_BOOTS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.reinhardt_hammer), new ItemStack(ModItems.reinhardt_token));

//Genji
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.genji_helmet), new ItemStack(ModItems.genji_token), new ItemStack(Items.IRON_HELMET, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.genji_chestplate), new ItemStack(ModItems.genji_token), new ItemStack(Items.IRON_CHESTPLATE, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.genji_leggings), new ItemStack(ModItems.genji_token), new ItemStack(Items.IRON_LEGGINGS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapelessMatchingDamageRecipe(new ItemStack(ModItems.genji_boots), new ItemStack(ModItems.genji_token), new ItemStack(Items.IRON_BOOTS, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.genji_shuriken), new ItemStack(ModItems.genji_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 @@ -16,7 +16,7 @@ public class Minewatch
{
public static final String MODNAME = "Minewatch";
public static final String MODID = "minewatch";
public static final String VERSION = "1.0";
public static final String VERSION = "1.1";
@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
@@ -1,5 +1,8 @@
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;
Expand Down Expand Up @@ -30,7 +33,7 @@ public EntityAnaBullet(World worldIn, EntityLivingBase throwerIn, boolean heal)
super(worldIn, throwerIn);
this.setNoGravity(true);
this.setSize(0.1f, 0.1f);
this.setPosition(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight() - 0.1D, throwerIn.posZ);
this.setPosition(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ);
this.heal = heal;
}

Expand Down Expand Up @@ -66,7 +69,7 @@ public void onUpdate() {

@Override
protected void onImpact(RayTraceResult result) {
if (result.entityHit instanceof EntityLivingBase && result.entityHit != this.getThrower()) {
if (result.entityHit instanceof EntityLivingBase && this.getThrower() != null && result.entityHit != this.getThrower()) {
if (this.heal) {
((EntityLivingBase)result.entityHit).heal(75/ModWeapon.DAMAGE_SCALE);
((WorldServer)result.entityHit.worldObj).spawnParticle(EnumParticleTypes.HEART,
Expand All @@ -78,7 +81,7 @@ protected void onImpact(RayTraceResult result) {
}
else {
if (this.getThrower() instanceof EntityPlayer)
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) this.getThrower()), 60F/ModWeapon.DAMAGE_SCALE);
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) this.getThrower()), 60F/ModWeapon.DAMAGE_SCALE);
else
if (this.getThrower() instanceof EntityPlayer)
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 60F/ModWeapon.DAMAGE_SCALE);
Expand All @@ -88,7 +91,11 @@ protected void onImpact(RayTraceResult result) {
}
this.setDead();
}
else if (result.typeOfHit == RayTraceResult.Type.BLOCK)
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();
}
}
}
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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;
Expand Down Expand Up @@ -29,7 +32,7 @@ public EntityReaperBullet(World worldIn, EntityLivingBase throwerIn) {
double velY = - Math.sin(throwerIn.rotationPitch*Math.PI/180) + (Math.random() - 0.5d)*0.2d;
double velZ = Math.cos(throwerIn.rotationPitch*Math.PI/180) * Math.sin(throwerIn.rotationYawHead*Math.PI/180 + Math.PI/2) + (Math.random() - 0.5d)*0.2d;
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 + 1.5d - Math.sin(throwerIn.rotationPitch*Math.PI/180);
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);
this.setPosition(x, y, z);
this.setRotation(0, 0);
Expand Down Expand Up @@ -62,7 +65,7 @@ public void onUpdate() {
protected void onImpact(RayTraceResult result) {
if (result.entityHit != null && result.entityHit == this.getThrower())
return;
else if (result.entityHit instanceof EntityLivingBase) {
else if (result.entityHit instanceof EntityLivingBase && this.getThrower() != null) {
float damage = 7 - (7 - 2) * (this.ticksExisted / LIFETIME);
if (this.getThrower() instanceof EntityPlayer)
((EntityLivingBase)result.entityHit).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) this.getThrower()), damage/ModWeapon.DAMAGE_SCALE);
Expand All @@ -71,7 +74,11 @@ else if (result.entityHit instanceof EntityLivingBase) {
((EntityLivingBase)result.entityHit).hurtResistantTime = 0;
this.setDead();
}
else if (result.typeOfHit == RayTraceResult.Type.BLOCK)
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();
}
}
}
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);
}
}
17 changes: 17 additions & 0 deletions src/main/java/twopiradians/minewatch/common/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import net.minecraftforge.fml.common.registry.GameRegistry;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.item.armor.ItemAnaArmor;
import twopiradians.minewatch.common.item.armor.ItemGenjiArmor;
import twopiradians.minewatch.common.item.armor.ItemHanzoArmor;
import twopiradians.minewatch.common.item.armor.ItemReaperArmor;
import twopiradians.minewatch.common.item.armor.ItemReinhardtArmor;
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.ItemReaperShotgun;
import twopiradians.minewatch.common.item.weapon.ItemReinhardtHammer;
Expand Down Expand Up @@ -57,6 +59,14 @@ public class ModItems
public static Item ana_rifle;
public static Item ana_token;

public static ArmorMaterial genji = EnumHelper.addArmorMaterial("genji", "minewatch:genji", 20, new int[] {2,3,3,2}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0);
public static Item genji_helmet;
public static Item genji_chestplate;
public static Item genji_leggings;
public static Item genji_boots;
public static Item genji_shuriken;
public static Item genji_token;

public static void preInit () {
reaper_helmet = registerItem(new ItemReaperArmor(reaper, 0, EntityEquipmentSlot.HEAD), "reaper_helmet");
reaper_chestplate = registerItem(new ItemReaperArmor(reaper, 0, EntityEquipmentSlot.CHEST), "reaper_chestplate");
Expand Down Expand Up @@ -85,6 +95,13 @@ public static void preInit () {
ana_boots = registerItem(new ItemAnaArmor(ana, 0, EntityEquipmentSlot.FEET), "ana_boots");
ana_rifle = registerItem(new ItemAnaRifle(), "ana_rifle");
ana_token = registerItem(new ModTokens.ItemAnaToken(), "ana_token");

genji_helmet = registerItem(new ItemGenjiArmor(genji, 0, EntityEquipmentSlot.HEAD), "genji_helmet");
genji_chestplate = registerItem(new ItemGenjiArmor(genji, 0, EntityEquipmentSlot.CHEST), "genji_chestplate");
genji_leggings = registerItem(new ItemGenjiArmor(genji, 0, EntityEquipmentSlot.LEGS), "genji_leggings");
genji_boots = registerItem(new ItemGenjiArmor(genji, 0, EntityEquipmentSlot.FEET), "genji_boots");
genji_shuriken = registerItem(new ItemGenjiShuriken(), "genji_shuriken");
genji_token = registerItem(new ModTokens.ItemGenjiToken(), "genji_token");
}

private static Item registerItem(Item item, String unlocalizedName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ModTokens extends Item
public void onEvent(LivingDropsEvent event) {
if (!event.getEntityLiving().worldObj.isRemote && event.getEntityLiving() instanceof EntityLiving
&& event.getEntityLiving().getEntityWorld().rand.nextDouble() < 0.01d * (1+event.getLootingLevel())) {
int i = event.getEntityLiving().worldObj.rand.nextInt(4);
int i = event.getEntityLiving().worldObj.rand.nextInt(ModItems.tokens.size());
ItemStack stack = new ItemStack(ModItems.tokens.get(i));
EntityItem drop = new EntityItem(event.getEntityLiving().worldObj, event.getEntityLiving().posX,
event.getEntityLiving().posY, event.getEntityLiving().posZ, stack);
Expand All @@ -28,4 +28,6 @@ public static class ItemReinhardtToken extends ModTokens {}
public static class ItemAnaToken extends ModTokens {}

public static class ItemHanzoToken extends ModTokens {}

public static class ItemGenjiToken extends ModTokens {}
}
Loading

0 comments on commit 15daaf6

Please sign in to comment.