Merge branch 'master' into 1.10
This commit is contained in:
commit
d5ff19cdc2
|
|
@ -1,21 +1,17 @@
|
|||
package tschipp.carryon;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
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.FMLPostInitializationEvent;
|
||||
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;
|
||||
|
||||
@EventBusSubscriber
|
||||
|
|
@ -30,10 +26,11 @@ public class CarryOn {
|
|||
public static CarryOn instance;
|
||||
|
||||
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 UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/bf7fb60d5e59f73eee65b271d5c01585e26a0352/update.json";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||
|
||||
//public static SimpleNetworkWrapper network;
|
||||
|
||||
@EventHandler
|
||||
|
|
|
|||
|
|
@ -224,7 +224,9 @@ public class RenderEvents
|
|||
GlStateManager.scale(1, 1, 1);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
modelPlayer.bipedLeftArm.isHidden = false;
|
||||
modelPlayer.bipedRightArm.isHidden = false;
|
||||
}
|
||||
|
|
@ -246,14 +248,19 @@ public class RenderEvents
|
|||
|
||||
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 (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
model.bipedBody.childModels.clear();
|
||||
|
||||
model.bipedLeftArm.isHidden = true;
|
||||
model.bipedRightArm.isHidden = true;
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc);
|
||||
float rotation = -player.renderYawOffset;
|
||||
ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48);
|
||||
if (aplayer.getSkinType().equals("default"))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
ModelRenderer fakeRightArm = new ModelRenderer(model, 40, 16);
|
||||
if (aplayer.getSkinType().equals("default"))
|
||||
{
|
||||
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.rotateAngleX = -.9F;
|
||||
fakeLeftArm.rotateAngleX = -.9F;
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -.9F;
|
||||
fakeLeftArm.rotateAngleX = -.9F;
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -1.4F;
|
||||
fakeLeftArm.rotateAngleX = -1.4F;
|
||||
}
|
||||
model.bipedBody.addChild(fakeLeftArm);
|
||||
model.bipedBody.addChild(fakeRightArm);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||
import tschipp.carryon.common.helper.StringParser;
|
||||
|
|
@ -40,13 +42,15 @@ public class ModelOverridesHandler
|
|||
|
||||
for (int i = 0; i < overrides.length; i++)
|
||||
{
|
||||
boolean errored = false;
|
||||
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
String currentline = overrides[i];
|
||||
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 toOverride = "";
|
||||
|
|
@ -58,13 +62,17 @@ public class ModelOverridesHandler
|
|||
}
|
||||
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("}"))
|
||||
throw new InvalidConfigException("Missing } at line " + i + " : " + currentline);
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String nbt = toOverride.substring(toOverride.indexOf("{"));
|
||||
toOverride = toOverride.replace(nbt, "");
|
||||
|
|
@ -74,12 +82,16 @@ public class ModelOverridesHandler
|
|||
}
|
||||
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("}"))
|
||||
throw new InvalidConfigException("Missing { at line " + i + " : " + currentline);
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String modidToOverride = "minecraft";
|
||||
String modidOverride = "minecraft";
|
||||
|
|
@ -98,24 +110,31 @@ public class ModelOverridesHandler
|
|||
else
|
||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||
|
||||
overrideObject = StringParser.getItem(override);
|
||||
if (Block.getBlockFromItem((Item) overrideObject) != null)
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
else
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
if (toOverrideObject != null)
|
||||
{
|
||||
overrideObject = StringParser.getItem(override);
|
||||
|
||||
NBTTagCompound keyComp = new NBTTagCompound();
|
||||
keyComp.setTag("nbttag", tag);
|
||||
if (toOverrideObject instanceof Block)
|
||||
{
|
||||
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
|
||||
if (Block.getBlockFromItem((Item) overrideObject) != Blocks.AIR)
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
else
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,31 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
public class InvalidConfigException extends RuntimeException
|
||||
import tschipp.carryon.CarryOn;
|
||||
|
||||
public class InvalidConfigException extends Exception
|
||||
{
|
||||
|
||||
public InvalidConfigException(String 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("");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package tschipp.carryon.common.helper;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
@ -9,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tschipp.carryon.CarryOn;
|
||||
|
||||
public class StringParser
|
||||
{
|
||||
|
|
@ -17,15 +20,15 @@ public class StringParser
|
|||
public static Block getBlock(String string)
|
||||
{
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if(tag != null)
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
|
||||
if (string.contains(";"))
|
||||
string = string.replace(string.substring(string.indexOf(";")), "");
|
||||
|
||||
Block block = Block.getBlockFromName(string);
|
||||
if(block == null)
|
||||
throw new InvalidConfigException("Block Parsing Error. Invalid Name: " + string);
|
||||
if (block == null)
|
||||
new InvalidConfigException("Block Parsing Error. Invalid Name: " + string).printException();
|
||||
|
||||
return block;
|
||||
}
|
||||
|
|
@ -33,10 +36,9 @@ public class StringParser
|
|||
public static int getMeta(String string)
|
||||
{
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if(tag != null)
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
|
||||
|
||||
if (string.contains(";"))
|
||||
{
|
||||
int meta = 0;
|
||||
|
|
@ -46,7 +48,7 @@ public class StringParser
|
|||
}
|
||||
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;
|
||||
|
|
@ -54,47 +56,59 @@ public class StringParser
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IBlockState getBlockState(String string)
|
||||
{
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if(tag != null)
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
|
||||
int meta = getMeta(string);
|
||||
if(meta == 0)
|
||||
return getBlock(string).getDefaultState();
|
||||
if (meta == 0)
|
||||
{
|
||||
Block block = getBlock(string);
|
||||
if(block != null)
|
||||
return block.getDefaultState();
|
||||
}
|
||||
try
|
||||
{
|
||||
return getBlock(string).getStateFromMeta(meta);
|
||||
}
|
||||
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)
|
||||
{
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if(tag != null)
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
||||
if(string.contains(";"))
|
||||
|
||||
if (string.contains(";"))
|
||||
string = string.replace(string.substring(string.indexOf(";")), "");
|
||||
|
||||
|
||||
return Item.getByNameOrId(string);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(String string)
|
||||
{
|
||||
ItemStack stack = new ItemStack(getItem(string), 1, getMeta(string));
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if(tag != null)
|
||||
stack.setTagCompound(tag);
|
||||
Item item = getItem(string);
|
||||
|
||||
if(item == null)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1, getMeta(string));
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static NBTTagCompound getTagCompound(String string)
|
||||
{
|
||||
|
|
@ -102,7 +116,7 @@ public class StringParser
|
|||
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 = string.replace(nbt, "");
|
||||
|
|
@ -112,16 +126,15 @@ public class StringParser
|
|||
}
|
||||
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("}"))
|
||||
throw new InvalidConfigException("Missing { at : " + string);
|
||||
|
||||
|
||||
new InvalidConfigException("Missing { at : " + string).printException();
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"modid" : "carryon",
|
||||
"name" : "Carry On",
|
||||
"version" : "1.1", "mcversion" : "1.10.2",
|
||||
"version" : "1.1.1", "mcversion" : "1.10.2",
|
||||
"url" : "",
|
||||
"credits" : "Tschipp, Purplicious_Cow, cy4n",
|
||||
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user