Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
* Added automatic date replacement in Resources.java by gradle build
Browse files Browse the repository at this point in the history
* Fixed client crashing when firing weapons and tag compound is missing
* Replaced some NBT tag setting on stack with new shortcut method "setTagInfo"
  • Loading branch information
simeonradivoev committed Aug 5, 2016
1 parent 2fd1136 commit 2ecaf5f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ if (System.getenv('TRAVIS_BUILD_NUMBER') != null) {
version += "-build-" + System.getenv('TRAVIS_BUILD_NUMBER')
}

def getDate() {
def date = new Date()
def formattedDate = date.format('dd.MM.yyyy')
return formattedDate
}

group= "${config.mo_group}"
archivesBaseName = "${config.mo_base_name}"

Expand All @@ -54,6 +60,7 @@ minecraft {

replaceIn "Reference.java"
replace "@VERSION@", config.mod_version
replace "@DATE@", getDate()
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/matteroverdrive/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Reference
public static final String MOD_ID = "mo";
public static final String MOD_NAME = "Matter Overdrive";
public static final String VERSION = "@VERSION@";
public static final String VERSION_DATE = "07.04.2016";
public static final String VERSION_DATE = "@DATE@";
public static final String GUI_FACTORY_CLASS = "matteroverdrive.gui.GuiConfigFactory";
public static final String DEPEDNENCIES = "required-after:shadowmc@[3.4.5-SNAPSHOT,);required-after:Tesla@[1.2.0.38,);after:Waila;after:theoneprobe;";
public static final String CLIENT_PROXY_CLASS = "matteroverdrive.proxy.ClientProxy";
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/matteroverdrive/items/DataPad.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.*;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
Expand Down Expand Up @@ -288,32 +286,27 @@ public void addToScanWhitelist(ItemStack itemStack, Block block)
//region Setters
public void setOrdering(ItemStack stack, int order)
{
TagCompountCheck(stack);
stack.getTagCompound().setInteger("Ordering", order);
stack.setTagInfo("Ordering", new NBTTagInt(order));
}

public void setOpenGuide(ItemStack stack, int guideID)
{
TagCompountCheck(stack);
stack.getTagCompound().setInteger("guideID", guideID);
stack.setTagInfo("guideID", new NBTTagInt(guideID));
}

public void setOpenPage(ItemStack stack, int page)
{
TagCompountCheck(stack);
stack.getTagCompound().setInteger("page", page);
stack.setTagInfo("page", new NBTTagInt(page));
}

public void setCategory(ItemStack stack, String category)
{
TagCompountCheck(stack);
stack.getTagCompound().setString("Category", category);
stack.setTagInfo("Category", new NBTTagString(category));
}

public void setSelectedActiveQuest(ItemStack itemStack, int quest)
{
TagCompountCheck(itemStack);
itemStack.getTagCompound().setShort("SelectedActiveQuest", (short)quest);
itemStack.setTagInfo("SelectedActiveQuest", new NBTTagShort((short)quest));
}
//endregion

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/matteroverdrive/items/weapon/EnergyWeapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.MathHelper;
Expand Down Expand Up @@ -649,10 +650,7 @@ public void addHeat(ItemStack itemStack, int amount)

public void setHeat(ItemStack item, float amount)
{
if (item.hasTagCompound())
{
item.getTagCompound().setFloat("heat", Math.min(amount, getMaxHeat(item) + 1));
}
item.setTagInfo("heat", new NBTTagFloat(Math.min(amount, getMaxHeat(item) + 1)));
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/matteroverdrive/items/weapon/PhaserRifle.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
Expand Down Expand Up @@ -190,8 +192,7 @@ public void onShooterClientUpdate(ItemStack itemStack, World world, EntityPlayer
{
if (canFire(itemStack, world, entityPlayer))
{
itemStack.getTagCompound().setLong("LastShot", world.getTotalWorldTime());

itemStack.setTagInfo("LastShot", new NBTTagLong(world.getTotalWorldTime()));
Vec3d dir = entityPlayer.getLook(1);
Vec3d pos = getFirePosition(entityPlayer, dir, isWeaponZoomed(entityPlayer, itemStack));
WeaponShot shot = createClientShot(itemStack, entityPlayer, isWeaponZoomed(entityPlayer, itemStack));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
Expand Down Expand Up @@ -320,7 +321,7 @@ public void onShooterClientUpdate(ItemStack itemStack, World world, EntityPlayer
{
if (canFire(itemStack, world, entityPlayer))
{
itemStack.getTagCompound().setLong("LastShot", world.getTotalWorldTime());
itemStack.setTagInfo("LastShot", new NBTTagLong(world.getTotalWorldTime()));
Vec3d dir = entityPlayer.getLook(1);
Vec3d pos = getFirePosition(entityPlayer, dir, Mouse.isButtonDown(1));
WeaponShot shot = createShot(itemStack, entityPlayer, Mouse.isButtonDown(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public ItemStack addAttributeToPart(ItemStack part, AttributeModifier attribute)
attributeList.appendTag(attributeTag);


part.getTagCompound().setTag("CustomAttributes", attributeList);
part.setTagInfo("CustomAttributes", attributeList);
return part;
}

Expand Down

0 comments on commit 2ecaf5f

Please sign in to comment.