Merge branch 'master' into 1.10

This commit is contained in:
Tschipp 2017-08-15 14:35:52 +02:00
commit d5ff19cdc2
6 changed files with 130 additions and 67 deletions

View File

@ -1,21 +1,17 @@
package tschipp.carryon; package tschipp.carryon;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.event.RegistryEvent; import org.apache.logging.log4j.LogManager;
import net.minecraftforge.fluids.FluidRegistry; import org.apache.logging.log4j.Logger;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLConstructionEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import tschipp.carryon.common.CommonProxy; import tschipp.carryon.common.CommonProxy;
@EventBusSubscriber @EventBusSubscriber
@ -30,9 +26,10 @@ public class CarryOn {
public static CarryOn instance; public static CarryOn instance;
public static final String MODID = "carryon"; public static final String MODID = "carryon";
public static final String VERSION = "1.1"; public static final String VERSION = "1.1.1";
public static final String NAME = "Carry On"; public static final String NAME = "Carry On";
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/bf7fb60d5e59f73eee65b271d5c01585e26a0352/update.json"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/bf7fb60d5e59f73eee65b271d5c01585e26a0352/update.json";
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
//public static SimpleNetworkWrapper network; //public static SimpleNetworkWrapper network;

View File

@ -224,7 +224,9 @@ public class RenderEvents
GlStateManager.scale(1, 1, 1); GlStateManager.scale(1, 1, 1);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} else { }
else
{
modelPlayer.bipedLeftArm.isHidden = false; modelPlayer.bipedLeftArm.isHidden = false;
modelPlayer.bipedRightArm.isHidden = false; modelPlayer.bipedRightArm.isHidden = false;
} }
@ -246,14 +248,19 @@ public class RenderEvents
ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID()); ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID());
ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48);
ModelRenderer fakeRightArm = new ModelRenderer(model, 40, 16);
if (stack != null && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) if (stack != null && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
{ {
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
model.bipedBody.childModels.clear();
model.bipedLeftArm.isHidden = true; model.bipedLeftArm.isHidden = true;
model.bipedRightArm.isHidden = true; model.bipedRightArm.isHidden = true;
Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc); Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc);
float rotation = -player.renderYawOffset; float rotation = -player.renderYawOffset;
ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48);
if (aplayer.getSkinType().equals("default")) if (aplayer.getSkinType().equals("default"))
{ {
fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F); fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F);
@ -263,7 +270,6 @@ public class RenderEvents
fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F); fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F);
} }
ModelRenderer fakeRightArm = new ModelRenderer(model, 40, 16);
if (aplayer.getSkinType().equals("default")) if (aplayer.getSkinType().equals("default"))
{ {
fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F); fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F);
@ -273,8 +279,16 @@ public class RenderEvents
fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F); fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F);
} }
fakeRightArm.rotateAngleX = -.9F; if (!player.isSneaking())
fakeLeftArm.rotateAngleX = -.9F; {
fakeRightArm.rotateAngleX = -.9F;
fakeLeftArm.rotateAngleX = -.9F;
}
else
{
fakeRightArm.rotateAngleX = -1.4F;
fakeLeftArm.rotateAngleX = -1.4F;
}
model.bipedBody.addChild(fakeLeftArm); model.bipedBody.addChild(fakeLeftArm);
model.bipedBody.addChild(fakeRightArm); model.bipedBody.addChild(fakeRightArm);

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Level;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -22,6 +23,7 @@ import net.minecraftforge.fml.common.registry.IForgeRegistryEntry;
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl; import net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig; import tschipp.carryon.common.config.CarryOnConfig;
import tschipp.carryon.common.helper.InvalidConfigException; import tschipp.carryon.common.helper.InvalidConfigException;
import tschipp.carryon.common.helper.StringParser; import tschipp.carryon.common.helper.StringParser;
@ -40,13 +42,15 @@ public class ModelOverridesHandler
for (int i = 0; i < overrides.length; i++) for (int i = 0; i < overrides.length; i++)
{ {
boolean errored = false;
Object toOverrideObject; Object toOverrideObject;
Object overrideObject; Object overrideObject;
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
String currentline = overrides[i]; String currentline = overrides[i];
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->")) if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
throw new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline); new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
String[] sa = currentline.split("->"); String[] sa = currentline.split("->");
String toOverride = ""; String toOverride = "";
@ -58,13 +62,17 @@ public class ModelOverridesHandler
} }
catch (ArrayIndexOutOfBoundsException e) catch (ArrayIndexOutOfBoundsException e)
{ {
throw new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline); errored = true;
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
} }
if (toOverride.contains("{")) if (toOverride.contains("{"))
{ {
if (!toOverride.contains("}")) if (!toOverride.contains("}"))
throw new InvalidConfigException("Missing } at line " + i + " : " + currentline); {
errored = true;
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
}
String nbt = toOverride.substring(toOverride.indexOf("{")); String nbt = toOverride.substring(toOverride.indexOf("{"));
toOverride = toOverride.replace(nbt, ""); toOverride = toOverride.replace(nbt, "");
@ -74,12 +82,16 @@ public class ModelOverridesHandler
} }
catch (NBTException e) catch (NBTException e)
{ {
throw new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()); errored = true;
new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()).printException();
} }
} }
else if (toOverride.contains("}")) else if (toOverride.contains("}"))
throw new InvalidConfigException("Missing { at line " + i + " : " + currentline); {
errored = true;
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
}
String modidToOverride = "minecraft"; String modidToOverride = "minecraft";
String modidOverride = "minecraft"; String modidOverride = "minecraft";
@ -98,24 +110,31 @@ public class ModelOverridesHandler
else else
toOverrideObject = StringParser.getBlockState(toOverride); toOverrideObject = StringParser.getBlockState(toOverride);
overrideObject = StringParser.getItem(override); if (toOverrideObject != null)
if (Block.getBlockFromItem((Item) overrideObject) != null) {
overrideObject = StringParser.getItemStack(override); overrideObject = StringParser.getItem(override);
else
overrideObject = StringParser.getBlockState(override);
NBTTagCompound keyComp = new NBTTagCompound(); if (Block.getBlockFromItem((Item) overrideObject) != Blocks.AIR)
keyComp.setTag("nbttag", tag); overrideObject = StringParser.getItemStack(override);
if (toOverrideObject instanceof Block) else
{ overrideObject = StringParser.getBlockState(override);
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
if (overrideObject != null)
{
NBTTagCompound keyComp = new NBTTagCompound();
keyComp.setTag("nbttag", tag);
if (toOverrideObject instanceof Block)
{
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
}
else
{
keyComp.setInteger("stateid", Block.getStateId((IBlockState) toOverrideObject));
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
}
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
}
} }
else
{
keyComp.setInteger("stateid", Block.getStateId((IBlockState) toOverrideObject));
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
}
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
} }
} }
} }

View File

@ -1,6 +1,8 @@
package tschipp.carryon.common.helper; package tschipp.carryon.common.helper;
public class InvalidConfigException extends RuntimeException import tschipp.carryon.CarryOn;
public class InvalidConfigException extends Exception
{ {
public InvalidConfigException(String cause) public InvalidConfigException(String cause)
@ -8,4 +10,22 @@ public class InvalidConfigException extends RuntimeException
super(cause); super(cause);
} }
public void printException()
{
CarryOn.LOGGER.error(this.getMessage());
for (int i = 0; i < this.getStackTrace().length; i++)
{
StackTraceElement element = this.getStackTrace()[i];
CarryOn.LOGGER.error(element.toString());
if(i >= 10)
{
CarryOn.LOGGER.error((this.getStackTrace().length - 10) + " more...");
break;
}
}
CarryOn.LOGGER.info("");
}
} }

View File

@ -2,6 +2,8 @@ package tschipp.carryon.common.helper;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.apache.logging.log4j.Level;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -9,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import tschipp.carryon.CarryOn;
public class StringParser public class StringParser
{ {
@ -17,15 +20,15 @@ public class StringParser
public static Block getBlock(String string) public static Block getBlock(String string)
{ {
NBTTagCompound tag = getTagCompound(string); NBTTagCompound tag = getTagCompound(string);
if(tag != null) if (tag != null)
string = string.replace(tag.toString(), ""); string = string.replace(tag.toString(), "");
if (string.contains(";")) if (string.contains(";"))
string = string.replace(string.substring(string.indexOf(";")), ""); string = string.replace(string.substring(string.indexOf(";")), "");
Block block = Block.getBlockFromName(string); Block block = Block.getBlockFromName(string);
if(block == null) if (block == null)
throw new InvalidConfigException("Block Parsing Error. Invalid Name: " + string); new InvalidConfigException("Block Parsing Error. Invalid Name: " + string).printException();
return block; return block;
} }
@ -33,10 +36,9 @@ public class StringParser
public static int getMeta(String string) public static int getMeta(String string)
{ {
NBTTagCompound tag = getTagCompound(string); NBTTagCompound tag = getTagCompound(string);
if(tag != null) if (tag != null)
string = string.replace(tag.toString(), ""); string = string.replace(tag.toString(), "");
if (string.contains(";")) if (string.contains(";"))
{ {
int meta = 0; int meta = 0;
@ -46,7 +48,7 @@ public class StringParser
} }
catch (Exception e) catch (Exception e)
{ {
throw new InvalidConfigException("Meta Parsing Error at: " + string + " : " + e.getMessage()); new InvalidConfigException("Meta Parsing Error at: " + string + " : " + e.getMessage()).printException();
} }
return meta; return meta;
@ -54,32 +56,39 @@ public class StringParser
return 0; return 0;
} }
@Nullable
public static IBlockState getBlockState(String string) public static IBlockState getBlockState(String string)
{ {
NBTTagCompound tag = getTagCompound(string); NBTTagCompound tag = getTagCompound(string);
if(tag != null) if (tag != null)
string = string.replace(tag.toString(), ""); string = string.replace(tag.toString(), "");
int meta = getMeta(string); int meta = getMeta(string);
if(meta == 0) if (meta == 0)
return getBlock(string).getDefaultState(); {
Block block = getBlock(string);
if(block != null)
return block.getDefaultState();
}
try try
{ {
return getBlock(string).getStateFromMeta(meta); return getBlock(string).getStateFromMeta(meta);
} }
catch (Exception e) catch (Exception e)
{ {
throw new InvalidConfigException("Blockstate parsing Exception at: " + string + " : " + e.getMessage()); new InvalidConfigException("Blockstate parsing Exception at: " + string + " : " + e.getMessage()).printException();
return null;
} }
} }
@Nullable
public static Item getItem(String string) public static Item getItem(String string)
{ {
NBTTagCompound tag = getTagCompound(string); NBTTagCompound tag = getTagCompound(string);
if(tag != null) if (tag != null)
string = string.replace(tag.toString(), ""); string = string.replace(tag.toString(), "");
if(string.contains(";")) if (string.contains(";"))
string = string.replace(string.substring(string.indexOf(";")), ""); string = string.replace(string.substring(string.indexOf(";")), "");
return Item.getByNameOrId(string); return Item.getByNameOrId(string);
@ -87,9 +96,14 @@ public class StringParser
public static ItemStack getItemStack(String string) public static ItemStack getItemStack(String string)
{ {
ItemStack stack = new ItemStack(getItem(string), 1, getMeta(string)); Item item = getItem(string);
if(item == null)
return ItemStack.EMPTY;
ItemStack stack = new ItemStack(item, 1, getMeta(string));
NBTTagCompound tag = getTagCompound(string); NBTTagCompound tag = getTagCompound(string);
if(tag != null) if (tag != null)
stack.setTagCompound(tag); stack.setTagCompound(tag);
return stack; return stack;
@ -102,7 +116,7 @@ public class StringParser
if (string.contains("{")) if (string.contains("{"))
{ {
if (!string.contains("}")) if (!string.contains("}"))
throw new InvalidConfigException("Missing } at : " + string); new InvalidConfigException("Missing } at : " + string).printException();
String nbt = string.substring(string.indexOf("{")); String nbt = string.substring(string.indexOf("{"));
string = string.replace(nbt, ""); string = string.replace(nbt, "");
@ -112,16 +126,15 @@ public class StringParser
} }
catch (NBTException e) catch (NBTException e)
{ {
throw new InvalidConfigException("Error while parsing NBT: " + e.getMessage()); new InvalidConfigException("Error while parsing NBT: " + e.getMessage()).printException();
return null;
} }
} }
else if (string.contains("}")) else if (string.contains("}"))
throw new InvalidConfigException("Missing { at : " + string); new InvalidConfigException("Missing { at : " + string).printException();
return tag; return tag;
} }
} }

View File

@ -2,7 +2,7 @@
{ {
"modid" : "carryon", "modid" : "carryon",
"name" : "Carry On", "name" : "Carry On",
"version" : "1.1", "mcversion" : "1.10.2", "version" : "1.1.1", "mcversion" : "1.10.2",
"url" : "", "url" : "",
"credits" : "Tschipp, Purplicious_Cow, cy4n", "credits" : "Tschipp, Purplicious_Cow, cy4n",
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"], "authorList" : ["Tschipp, Purplicious_Cow, cy4n"],