Skip to content

Commit

Permalink
added config for durability options
Browse files Browse the repository at this point in the history
  • Loading branch information
Furgl committed Sep 2, 2017
1 parent 061b4ca commit b8c7f94
Show file tree
Hide file tree
Showing 25 changed files with 145 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelAnaBullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityAnaBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderAnaBullet extends Render<EntityAnaBullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityAnaBullet entity) {

@Override
public void doRender(EntityAnaBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelSoldier76Bullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityBastionBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderBastionBullet extends Render<EntityBastionBullet> {

Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityBastionBullet entity) {

@Override
public void doRender(EntityBastionBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.util.ResourceLocation;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityGenjiShuriken;
import twopiradians.minewatch.common.entity.ModEntities;
import twopiradians.minewatch.common.item.ModItems;

public class RenderGenjiShuriken extends Render<EntityGenjiShuriken>
Expand All @@ -31,6 +32,9 @@ protected ResourceLocation getEntityTexture(EntityGenjiShuriken entity) {

@Override
public void doRender(EntityGenjiShuriken entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y+.05f, (float)z);
GlStateManager.enableRescaleNormal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.util.ResourceLocation;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityMWThrowable;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderInvisible extends Render<EntityMWThrowable> {

Expand All @@ -18,5 +19,8 @@ protected ResourceLocation getEntityTexture(EntityMWThrowable entity) {
}

@Override
public void doRender(EntityMWThrowable entity, double x, double y, double z, float entityYaw, float partialTicks) {}
public void doRender(EntityMWThrowable entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelMcCreeBullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityMcCreeBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderMcCreeBullet extends Render<EntityMcCreeBullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityMcCreeBullet entity) {

@Override
public void doRender(EntityMcCreeBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.util.ResourceLocation;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityMeiIcicle;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderMeiIcicle extends RenderOBJModel<EntityMeiIcicle> {

Expand All @@ -24,6 +25,9 @@ protected ResourceLocation getEntityModel() {

@Override
protected void preRender(EntityMeiIcicle entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.translate(0, 0.06d, 0.5d);
GlStateManager.scale(2, 2, 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelReaperBullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityReaperBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderReaperBullet extends Render<EntityReaperBullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityReaperBullet entity) {

@Override
public void doRender(EntityReaperBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelSoldier76Bullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntitySoldier76Bullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderSoldier76Bullet extends Render<EntitySoldier76Bullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntitySoldier76Bullet entity) {

@Override
public void doRender(EntitySoldier76Bullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelSoldier76Bullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntitySoldier76HelixRocket;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderSoldier76HelixRocket extends Render<EntitySoldier76HelixRocket>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntitySoldier76HelixRocket entity) {

@Override
public void doRender(EntitySoldier76HelixRocket entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelTracerBullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityTracerBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderTracerBullet extends Render<EntityTracerBullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityTracerBullet entity) {

@Override
public void doRender(EntityTracerBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import twopiradians.minewatch.client.model.ModelAnaBullet;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityWidowmakerBullet;
import twopiradians.minewatch.common.entity.ModEntities;

public class RenderWidowmakerBullet extends Render<EntityWidowmakerBullet>
{
Expand All @@ -23,6 +24,9 @@ protected ResourceLocation getEntityTexture(EntityWidowmakerBullet entity) {

@Override
public void doRender(EntityWidowmakerBullet entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.ticksExisted == 0 && entity.getPersistentID().equals(ModEntities.spawningEntityUUID))
entity.updateFromPacket();

GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.scale(0.1F, 0.1F, 0.1F);
Expand Down
45 changes: 41 additions & 4 deletions src/main/java/twopiradians/minewatch/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ public class Config {

public static final String CATEGORY_HERO_TEXTURES = "config.heroTextures";

private static final String[] DURABILITY_OPTIONS = new String[] {"Normally", "When not wearing full set", "Never"};

public static Configuration config;
public static boolean useObjModels;
public static int tokenDropRate;
public static boolean allowGunWarnings;
public static boolean customCrosshairs;
public static double guiScale;
public static int durabilityOptionArmors;
public static int durabilityOptionWeapons;

public static void preInit(final File file) {
config = new Configuration(file);
Expand All @@ -33,22 +37,34 @@ public static void syncConfig() {
Property use3DModelsprop = config.get(Configuration.CATEGORY_GENERAL, "Use 3D Item Models", true, "Should the Minewatch weapons use 3D models?");
use3DModelsprop.setRequiresMcRestart(true);
useObjModels = use3DModelsprop.getBoolean();

Property allowGunWarningsProp = config.get(Configuration.CATEGORY_GENERAL, "Restrict weapon usage", true, "Should weapons only work like in Overwatch: only in the mainhand (with offhand weapons in the offhand). This also prevents weapons from different heroes from being mixed and matched.");
allowGunWarnings = allowGunWarningsProp.getBoolean();

Property customCrosshairsProp = config.get(Configuration.CATEGORY_GENERAL, "Custom Crosshairs", true, "Should weapons change your crosshair.");
customCrosshairs = customCrosshairsProp.getBoolean();

Property tokenDropRateProp = config.get(Configuration.CATEGORY_GENERAL, "Token Drop Rate", 100, "Average number of mobs to kill for one token.", 1, 10000);
tokenDropRate = tokenDropRateProp.getInt();

Property damageScaleProp = config.get(Configuration.CATEGORY_GENERAL, "Damage Scale", 1d, "1 is the recommended scale for vanilla. A higher scale means weapons do more damage and a lower scale means they do less.", 0, 100);
ItemMWWeapon.damageScale = (float) (0.1d * damageScaleProp.getDouble());

Property guiScaleProp = config.get(Configuration.CATEGORY_GENERAL, "Gui Scale", 1d, "Scale for the hero and weapon GUI/overlays.", 0, 2);
Config.guiScale = guiScaleProp.getDouble();

Property durabilityArmorsProp = config.get(Configuration.CATEGORY_GENERAL, "Armors use durability", DURABILITY_OPTIONS[0], "Choose when armors should use durability.", DURABILITY_OPTIONS);
for (int i=0; i<DURABILITY_OPTIONS.length; ++i)
if (durabilityArmorsProp.getString().equals(DURABILITY_OPTIONS[i]))
Config.durabilityOptionArmors = i;

Property durabilityWeaponsProp = config.get(Configuration.CATEGORY_GENERAL, "Weapons use durability", DURABILITY_OPTIONS[1], "Choose when weapons should use durability.", DURABILITY_OPTIONS);
for (int i=0; i<DURABILITY_OPTIONS.length; ++i)
if (durabilityWeaponsProp.getString().equals(DURABILITY_OPTIONS[i]))
Config.durabilityOptionWeapons = i;

Config.updateDurability();

for (EnumHero hero : EnumHero.values()) {
Property heroTextureProp = config.get(Config.CATEGORY_HERO_TEXTURES, hero.name+" Texture", hero.textureCredits[0], "Textures for "+hero.name+"'s armor", hero.textureCredits);
for (int i=0; i<hero.textureCredits.length; ++i)
Expand All @@ -66,4 +82,25 @@ public void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event)
config.save();
}
}

/**Update armor/weapon durabilities according to config options*/
public static void updateDurability() {
/*// update durabilities
for (EnumHero hero : EnumHero.values()) {
for (ItemMWArmor item : new ItemMWArmor[] {hero.helmet, hero.chestplate, hero.leggings, hero.boots}) {
if (item != null) {
if (Config.durabilityOptionArmors == 0 || Config.durabilityOptionArmors == 1)
item.setMaxDamage(item.getArmorMaterial().getDurability(item.armorType));
else if (Config.durabilityOptionArmors == 2)
item.setMaxDamage(0);
}
}
if (hero.weapon != null) {
if (Config.durabilityOptionWeapons == 0 || Config.durabilityOptionWeapons == 1)
hero.weapon.setMaxDamage(100);
else if (Config.durabilityOptionWeapons == 2)
hero.weapon.setMaxDamage(0);
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public boolean isImmuneToExplosions() {
return true;
}

@Override
public void onUpdate() {
if (this.ticksExisted == 1 && this.getPersistentID().equals(ModEntities.spawningEntityUUID)) {
SPacketSyncSpawningEntity packet = ModEntities.spawningEntityPacket;
public void updateFromPacket() {
SPacketSyncSpawningEntity packet = ModEntities.spawningEntityPacket;
if (packet != null) {
this.rotationPitch = packet.pitch;
this.prevRotationPitch = packet.pitch;
this.rotationYaw = packet.yaw;
Expand All @@ -51,7 +50,14 @@ public void onUpdate() {
this.prevPosX = packet.posX;
this.prevPosY = packet.posY;
this.prevPosZ = packet.posZ;
ModEntities.spawningEntityUUID = null;
}
}

@Override
public void onUpdate() {
if (this.ticksExisted == 1 && this.getPersistentID().equals(ModEntities.spawningEntityUUID))
this.updateFromPacket();

float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static void preInit () {

genji_shuriken_single = registerItem(new ItemGenjiShuriken(), "genji_shuriken_single", false, true);
((ItemGenjiShuriken)genji_shuriken_single).hero = EnumHero.GENJI;

Config.updateDurability();
}

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 @@ -28,6 +28,7 @@
import twopiradians.minewatch.client.key.Keys.KeyBind;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.command.CommandDev;
import twopiradians.minewatch.common.config.Config;
import twopiradians.minewatch.common.hero.Ability;
import twopiradians.minewatch.common.hero.EnumHero;
import twopiradians.minewatch.packet.SPacketSyncAbilityUses;
Expand Down Expand Up @@ -146,6 +147,11 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int slot, bool
((EntityPlayer)entity).inventory.setInventorySlotContents(slot, ItemStack.EMPTY);
return;
}

// set damage to full if option set to never use durability
if (Config.durabilityOptionArmors == 2 && stack.getItemDamage() != 0)
stack.setItemDamage(0);

super.onUpdate(stack, world, entity, slot, isSelected);
}

Expand Down Expand Up @@ -186,6 +192,11 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
player.posZ+(player.chasingPosZ-player.posZ)*i/numParticles,
0, 0, 0, 0x5EDCE5, 0x007acc, 1, 7, 1);
}

// set damage to full if wearing full set and option set to not use durability while wearing full set
if (Config.durabilityOptionArmors == 1 && stack.getItemDamage() != 0 &&
SetManager.playersWearingSets.get(player.getPersistentID()) == hero)
stack.setItemDamage(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.minecraftforge.fml.relauncher.SideOnly;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityAnaBullet;
import twopiradians.minewatch.common.item.armor.ItemMWArmor;
import twopiradians.minewatch.common.sound.ModSoundEvents;

public class ItemAnaRifle extends ItemMWWeapon {
Expand Down Expand Up @@ -72,7 +71,7 @@ public void onItemLeftClick(ItemStack stack, World world, EntityPlayer player, E
this.subtractFromCurrentAmmo(player, 1, hand);
if (!player.getCooldownTracker().hasCooldown(this))
player.getCooldownTracker().setCooldown(this, 20);
if (world.rand.nextInt(25) == 0 && !(ItemMWArmor.SetManager.playersWearingSets.get(player.getPersistentID()) == hero))
if (world.rand.nextInt(10) == 0)
player.getHeldItem(hand).damageItem(1, player);
}
player.stopActiveHand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityBastionBullet;
import twopiradians.minewatch.common.entity.EntityMWThrowable;
import twopiradians.minewatch.common.item.armor.ItemMWArmor;
import twopiradians.minewatch.common.sound.ModSoundEvents;

public class ItemBastionGun extends ItemMWWeapon {
Expand Down Expand Up @@ -39,7 +38,7 @@ public void onItemLeftClick(ItemStack stack, World world, EntityPlayer player, E
world.rand.nextFloat()/3+0.8f);

this.subtractFromCurrentAmmo(player, 1);
if (world.rand.nextInt(25) == 0 && ItemMWArmor.SetManager.playersWearingSets.get(player.getPersistentID()) != hero)
if (world.rand.nextInt(25) == 0)
player.getHeldItem(hand).damageItem(1, player);
}
else {
Expand Down
Loading

0 comments on commit b8c7f94

Please sign in to comment.