Merge branch 'master' into 1.10
This commit is contained in:
commit
a4fcb39cb6
0
carryon-scripts
Normal file
0
carryon-scripts
Normal file
|
|
@ -1,9 +1,13 @@
|
|||
package tschipp.carryon;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
|
|
@ -16,6 +20,7 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
|||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import tschipp.carryon.common.CommonProxy;
|
||||
import tschipp.carryon.common.command.CommandCarryOn;
|
||||
import tschipp.carryon.common.command.CommandCarryOnReload;
|
||||
|
||||
@EventBusSubscriber
|
||||
@Mod(modid = CarryOn.MODID, name = CarryOn.NAME, version = CarryOn.VERSION, guiFactory = "tschipp.carryon.client.gui.GuiFactoryCarryOn", updateJSON = CarryOn.UPDATE_JSON)
|
||||
|
|
@ -29,21 +34,22 @@ public class CarryOn {
|
|||
public static CarryOn instance;
|
||||
|
||||
public static final String MODID = "carryon";
|
||||
public static final String VERSION = "1.5.1";
|
||||
public static final String VERSION = "1.6";
|
||||
public static final String NAME = "Carry On";
|
||||
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
|
||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||
|
||||
public static File CONFIGURATION_FILE;
|
||||
|
||||
public static SimpleNetworkWrapper network;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
public void preInit(FMLPreInitializationEvent event){
|
||||
CarryOn.proxy.preInit(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
CarryOn.proxy.init(event);
|
||||
CarryOn.proxy.init(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
@ -55,6 +61,17 @@ public class CarryOn {
|
|||
public void serverLoad(FMLServerStartingEvent event)
|
||||
{
|
||||
event.registerServerCommand(new CommandCarryOn());
|
||||
event.registerServerCommand(new CommandCarryOnReload());
|
||||
|
||||
}
|
||||
|
||||
public static File getMcDir()
|
||||
{
|
||||
if (FMLCommonHandler.instance().getMinecraftServerInstance() != null && FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer())
|
||||
{
|
||||
return new File(".");
|
||||
}
|
||||
return Minecraft.getMinecraft().mcDataDir;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package tschipp.carryon.client.event;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
|
|
@ -15,10 +14,14 @@ import net.minecraft.client.renderer.RenderHelper;
|
|||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
|
|
@ -29,12 +32,13 @@ import net.minecraftforge.fml.common.gameevent.InputEvent;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class RenderEntityEvents
|
||||
{
|
||||
|
||||
/*
|
||||
* Prevents the Player from scrolling
|
||||
*/
|
||||
|
|
@ -42,16 +46,17 @@ public class RenderEntityEvents
|
|||
@SubscribeEvent
|
||||
public void onScroll(MouseEvent event) throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0)
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0 || Minecraft.getMinecraft().gameSettings.keyBindPickBlock.isPressed())
|
||||
{
|
||||
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItemMainhand();
|
||||
if (stack != null && stack.getItem() == RegistrationHandler.itemEntity)
|
||||
{
|
||||
if (ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -106,13 +111,14 @@ public class RenderEntityEvents
|
|||
field.set(keyBind, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int current = player.inventory.currentItem;
|
||||
|
||||
if (player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInteger("carrySlot") != current : false)
|
||||
{
|
||||
player.inventory.currentItem = player.getEntityData().getInteger("carrySlot");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -132,13 +138,13 @@ public class RenderEntityEvents
|
|||
|
||||
if (stack != null ? stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack) : false)
|
||||
{
|
||||
BlockPos pos = player.getPosition();
|
||||
Entity entity = ItemEntity.getEntity(stack, world);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialticks;
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
||||
|
||||
entity.setPosition(d0, d1, d2);
|
||||
entity.rotationYaw = 0.0f;
|
||||
|
|
@ -147,8 +153,6 @@ public class RenderEntityEvents
|
|||
|
||||
float height = entity.height;
|
||||
float width = entity.width;
|
||||
float multiplier = height * width;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(.8, .8, .8);
|
||||
GlStateManager.rotate(180, 0, 1, 0);
|
||||
|
|
@ -159,13 +163,43 @@ public class RenderEntityEvents
|
|||
{
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
String entityname = carryOverride.getRenderNameEntity();
|
||||
if (entityname != null)
|
||||
{
|
||||
Entity newEntity = EntityList.createEntityByName(entityname, world);
|
||||
if (newEntity != null)
|
||||
{
|
||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.readFromNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.setPosition(d0, d1, d2);
|
||||
entity.rotationYaw = 0.0f;
|
||||
entity.prevRotationYaw = 0.0f;
|
||||
entity.setRotationYawHead(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
|
||||
}
|
||||
|
||||
this.renderEntityStatic(entity);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
}
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
|
|
@ -176,11 +210,75 @@ public class RenderEntityEvents
|
|||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void renderEntityStatic(Entity entity)
|
||||
{
|
||||
if (entity.ticksExisted == 0)
|
||||
{
|
||||
entity.lastTickPosX = entity.posX;
|
||||
entity.lastTickPosY = entity.posY;
|
||||
entity.lastTickPosZ = entity.posZ;
|
||||
}
|
||||
|
||||
float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw);
|
||||
int i = this.getBrightnessForRender(entity, Minecraft.getMinecraft().thePlayer);
|
||||
|
||||
if (entity.isBurning())
|
||||
{
|
||||
i = 15728880;
|
||||
}
|
||||
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.setLightmapDisabled(false);
|
||||
|
||||
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, f, 0.0F, true);
|
||||
this.setLightmapDisabled(true);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int getBrightnessForRender(Entity entity, EntityPlayer player)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(player.posX), 0, MathHelper.floor_double(player.posZ));
|
||||
|
||||
if (entity.worldObj.isBlockLoaded(blockpos$mutableblockpos))
|
||||
{
|
||||
blockpos$mutableblockpos.setY(MathHelper.floor_double(player.posY + entity.getEyeHeight()));
|
||||
return entity.worldObj.getCombinedLight(blockpos$mutableblockpos, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void setLightmapDisabled(boolean disabled)
|
||||
{
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
|
||||
if (disabled)
|
||||
{
|
||||
GlStateManager.disableTexture2D();
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -199,20 +297,17 @@ public class RenderEntityEvents
|
|||
if (stack != null ? stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack) : false)
|
||||
{
|
||||
Entity entity = ItemEntity.getEntity(stack, world);
|
||||
|
||||
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
||||
|
||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialticks;
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
||||
|
||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * (double) partialticks;
|
||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * (double) partialticks;
|
||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * (double) partialticks;
|
||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks;
|
||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks;
|
||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks;
|
||||
|
||||
double xOffset = d0 - c0;
|
||||
double yOffset = d1 - c1;
|
||||
|
|
@ -231,21 +326,52 @@ public class RenderEntityEvents
|
|||
GlStateManager.translate(xOffset, yOffset, zOffset);
|
||||
GlStateManager.scale((10 - multiplier) * 0.08, (10 - multiplier) * 0.08, (10 - multiplier) * 0.08);
|
||||
GlStateManager.rotate(rotation, 0, 1f, 0);
|
||||
GlStateManager.translate(0.0, (height / 2) + -(height / 2) + 1, (width - 0.1) < 0.7 ? (width - 0.1) + (0.7 - (width - 0.1)) : (width - 0.1));
|
||||
GlStateManager.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
GlStateManager.translate(0, -0.3, 0);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
String entityname = carryOverride.getRenderNameEntity();
|
||||
if (entityname != null)
|
||||
{
|
||||
Entity newEntity = EntityList.createEntityByName(entityname, world);
|
||||
if (newEntity != null)
|
||||
{
|
||||
NBTTagCompound nbttag = carryOverride.getRenderNBT();
|
||||
if (nbttag != null)
|
||||
newEntity.readFromNBT(nbttag);
|
||||
entity = newEntity;
|
||||
entity.setPosition(d0, d1, d2);
|
||||
entity.rotationYaw = 0.0f;
|
||||
entity.prevRotationYaw = 0.0f;
|
||||
entity.setRotationYawHead(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package tschipp.carryon.client.event;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
|
@ -13,14 +12,15 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
|||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -28,6 +28,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
|
|
@ -44,12 +45,21 @@ import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
|||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
import tschipp.carryon.common.helper.StringParser;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
|
||||
public class RenderEvents
|
||||
{
|
||||
private static boolean initModels;
|
||||
private ModelRenderer fakeLeftArm;
|
||||
private ModelRenderer fakeRightArm;
|
||||
private ModelRenderer fakeLeftArmwear;
|
||||
private ModelRenderer fakeRightArmwear;
|
||||
|
||||
/*
|
||||
* Prevents the Player from scrolling
|
||||
|
|
@ -58,16 +68,17 @@ public class RenderEvents
|
|||
@SubscribeEvent
|
||||
public void onScroll(MouseEvent event)
|
||||
{
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0)
|
||||
if (event.getDwheel() > 0 || event.getDwheel() < 0 || Minecraft.getMinecraft().gameSettings.keyBindPickBlock.isPressed())
|
||||
{
|
||||
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItemMainhand();
|
||||
if (stack != null && stack.getItem() == RegistrationHandler.itemTile)
|
||||
{
|
||||
if (ItemTile.hasTileData(stack))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -75,9 +86,9 @@ public class RenderEvents
|
|||
public void onPlayerTick(PlayerTickEvent event) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
EntityPlayer player = event.player;
|
||||
|
||||
if (player != null && event.side == Side.CLIENT)
|
||||
{
|
||||
|
||||
boolean keyPressed = CarryOnKeybinds.carryKey.isKeyDown();
|
||||
boolean playerKeyPressed = CarryOnKeybinds.isKeyPressed(player);
|
||||
|
||||
|
|
@ -91,8 +102,6 @@ public class RenderEvents
|
|||
CarryOnKeybinds.setKeyPressed(player, false);
|
||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,16 +157,14 @@ public class RenderEvents
|
|||
field.set(keyBind, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int current = player.inventory.currentItem;
|
||||
|
||||
if(player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInteger("carrySlot") != current : false)
|
||||
|
||||
if (player.getEntityData().hasKey("carrySlot") ? player.getEntityData().getInteger("carrySlot") != current : false)
|
||||
{
|
||||
player.inventory.currentItem = player.getEntityData().getInteger("carrySlot");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -176,7 +183,6 @@ public class RenderEvents
|
|||
if (stack != null ? stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) : false)
|
||||
{
|
||||
Block block = ItemTile.getBlock(stack);
|
||||
BlockPos pos = player.getPosition();
|
||||
NBTTagCompound tag = ItemTile.getTileData(stack);
|
||||
IBlockState state = ItemTile.getBlockState(stack);
|
||||
ItemStack tileStack = ItemTile.getItemStack(stack);
|
||||
|
|
@ -191,29 +197,73 @@ public class RenderEvents
|
|||
GlStateManager.rotate(-8, 1f, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.rotate(8, 1f, 0, 0);
|
||||
}
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileStack == null ? stack : tileStack, world, player);
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileStack, world, player);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||
if (b != null)
|
||||
{
|
||||
ItemStack s = new ItemStack(b, 1, carryOverride.getRenderMeta());
|
||||
s.setTagCompound(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(s, world, player);
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rotation[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rotation[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rotation[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
|
||||
}
|
||||
|
||||
int i = this.getBrightnessForRender(Minecraft.getMinecraft().thePlayer);
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.setLightmapDisabled(false);
|
||||
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||
{
|
||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
||||
|
||||
if (override instanceof ItemStack)
|
||||
{
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack == null ? stack : tileStack, model);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileStack == null ? stack : tileStack, model);
|
||||
}
|
||||
|
||||
this.setLightmapDisabled(true);
|
||||
|
||||
if (perspective == 0)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (perspective == 0)
|
||||
event.setCanceled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -226,10 +276,45 @@ public class RenderEvents
|
|||
ModelPlayer modelPlayer = renderPlayer.getMainModel();
|
||||
modelPlayer.bipedLeftArm.isHidden = false;
|
||||
modelPlayer.bipedRightArm.isHidden = false;
|
||||
modelPlayer.bipedLeftArmwear.isHidden = false;
|
||||
modelPlayer.bipedRightArmwear.isHidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int getBrightnessForRender(EntityPlayer player)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(player.posX), 0, MathHelper.floor_double(player.posZ));
|
||||
|
||||
if (player.worldObj.isBlockLoaded(blockpos$mutableblockpos))
|
||||
{
|
||||
blockpos$mutableblockpos.setY(MathHelper.floor_double(player.posY + player.getEyeHeight()));
|
||||
return player.worldObj.getCombinedLight(blockpos$mutableblockpos, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void setLightmapDisabled(boolean disabled)
|
||||
{
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
|
||||
if (disabled)
|
||||
{
|
||||
GlStateManager.disableTexture2D();
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders the Block in Third Person
|
||||
*/
|
||||
|
|
@ -248,19 +333,17 @@ public class RenderEvents
|
|||
Block block = ItemTile.getBlock(stack);
|
||||
IBlockState state = ItemTile.getBlockState(stack);
|
||||
NBTTagCompound tag = ItemTile.getTileData(stack);
|
||||
|
||||
ItemStack tileItem = ItemTile.getItemStack(stack);
|
||||
|
||||
float rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
||||
int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView;
|
||||
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialticks;
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
||||
|
||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * (double) partialticks;
|
||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * (double) partialticks;
|
||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * (double) partialticks;
|
||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks;
|
||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks;
|
||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks;
|
||||
|
||||
double xOffset = d0 - c0;
|
||||
double yOffset = d1 - c1;
|
||||
|
|
@ -282,26 +365,54 @@ public class RenderEvents
|
|||
}
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
GlStateManager.translate(0, -0.3, 0);
|
||||
}
|
||||
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileItem, world, player);
|
||||
|
||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||
if (carryOverride != null)
|
||||
{
|
||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
||||
double[] scale = ScriptParseHelper.getScale(carryOverride.getRenderScale());
|
||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||
if (b != null)
|
||||
{
|
||||
ItemStack s = new ItemStack(b, 1, carryOverride.getRenderMeta());
|
||||
s.setTagCompound(carryOverride.getRenderNBT());
|
||||
model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(s, world, player);
|
||||
}
|
||||
|
||||
GlStateManager.translate(translation[0], translation[1], translation[2]);
|
||||
GlStateManager.rotate((float) rot[0], 1, 0, 0);
|
||||
GlStateManager.rotate((float) rot[1], 0, 1, 0);
|
||||
GlStateManager.rotate((float) rot[2], 0, 0, 1);
|
||||
GlStateManager.scale(scale[0], scale[1], scale[2]);
|
||||
|
||||
}
|
||||
|
||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileItem == null ? stack : tileItem, world, player);
|
||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||
{
|
||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
||||
|
||||
if (override instanceof ItemStack)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem((ItemStack) override, model);
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem == null ? stack : tileItem, model);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(tileItem == null ? stack : tileItem, model);
|
||||
}
|
||||
GlStateManager.scale(1, 1, 1);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -311,10 +422,8 @@ public class RenderEvents
|
|||
@SubscribeEvent
|
||||
public void onPlayerRenderPre(RenderPlayerEvent.Pre event)
|
||||
{
|
||||
|
||||
if (!Loader.isModLoaded("mobends") && CarryOnConfig.settings.renderArms)
|
||||
{
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
|
|
@ -323,102 +432,332 @@ public class RenderEvents
|
|||
|
||||
ResourceLocation skinLoc = DefaultPlayerSkin.getDefaultSkin(player.getPersistentID());
|
||||
|
||||
ModelRenderer fakeLeftArm = new ModelRenderer(model, 32, 48);
|
||||
ModelRenderer fakeRightArm = new ModelRenderer(model, 40, 16);
|
||||
|
||||
player.setArrowCountInEntity(0); //TODO Temporary Fix
|
||||
|
||||
if (!initModels)
|
||||
{
|
||||
this.fakeRightArm = new ModelRenderer(model, 40, 16);
|
||||
this.fakeLeftArm = new ModelRenderer(model, 32, 48);
|
||||
this.fakeLeftArmwear = new ModelRenderer(model, 48, 48);
|
||||
this.fakeRightArmwear = new ModelRenderer(model, 40, 32);
|
||||
initModels = true;
|
||||
}
|
||||
|
||||
player.setArrowCountInEntity(0); // TODO Temporary Fix
|
||||
|
||||
if (stack != null ? ((stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))) : false)
|
||||
{
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
{
|
||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
|
||||
float rotX = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
float rotY = model.bipedBody.childModels.get(k).rotateAngleY;
|
||||
float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ;
|
||||
|
||||
if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
{
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
{
|
||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
|
||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
|
||||
model.bipedLeftArm.isHidden = true;
|
||||
model.bipedRightArm.isHidden = true;
|
||||
|
||||
model.bipedLeftArmwear.isHidden = true;
|
||||
model.bipedRightArmwear.isHidden = true;
|
||||
this.fakeLeftArm.isHidden = false;
|
||||
this.fakeLeftArmwear.isHidden = false;
|
||||
this.fakeRightArm.isHidden = false;
|
||||
this.fakeRightArmwear.isHidden = false;
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(skinLoc);
|
||||
float rotation = -player.renderYawOffset;
|
||||
|
||||
if (aplayer.getSkinType().equals("default"))
|
||||
{
|
||||
fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F);
|
||||
// left arm
|
||||
this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F);
|
||||
this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 4, 12, 4, .08F + 0.25F);
|
||||
|
||||
// right arm
|
||||
this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F);
|
||||
this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F + 0.25F);
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F);
|
||||
// left arm
|
||||
this.fakeLeftArm.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F);
|
||||
this.fakeLeftArmwear.addBox(model.bipedLeftArm.offsetX + 4.2F, model.bipedLeftArm.offsetY, model.bipedLeftArm.offsetZ, 3, 12, 4, .08F + 0.25F);
|
||||
|
||||
// right arm
|
||||
this.fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F);
|
||||
this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F + 0.25F);
|
||||
}
|
||||
|
||||
if (aplayer.getSkinType().equals("default"))
|
||||
CarryOnOverride override = ScriptChecker.getOverride(player);
|
||||
if (override != null)
|
||||
{
|
||||
fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.9F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 4, 12, 4, .08F);
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeRightArm.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F);
|
||||
}
|
||||
double[] rotLeft = null;
|
||||
double[] rotRight = null;
|
||||
if (override.getRenderRotationLeftArm() != null)
|
||||
rotLeft = ScriptParseHelper.getXYZArray(override.getRenderRotationLeftArm());
|
||||
if (override.getRenderRotationRightArm() != null)
|
||||
rotRight = ScriptParseHelper.getXYZArray(override.getRenderRotationRightArm());
|
||||
|
||||
if (item == RegistrationHandler.itemTile)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
boolean renderRight = override.isRenderRightArm();
|
||||
boolean renderLeft = override.isRenderLeftArm();
|
||||
|
||||
if (!renderRight)
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -.9001F;
|
||||
fakeLeftArm.rotateAngleX = -.9001F;
|
||||
this.fakeRightArm.isHidden = true;
|
||||
this.fakeRightArmwear.isHidden = true;
|
||||
model.bipedRightArm.isHidden = false;
|
||||
model.bipedRightArmwear.isHidden = false;
|
||||
}
|
||||
|
||||
|
||||
if (!renderLeft)
|
||||
{
|
||||
this.fakeLeftArm.isHidden = true;
|
||||
this.fakeLeftArmwear.isHidden = true;
|
||||
model.bipedLeftArm.isHidden = false;
|
||||
model.bipedLeftArmwear.isHidden = false;
|
||||
}
|
||||
|
||||
|
||||
if (rotLeft != null)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = (float) rotLeft[0];
|
||||
this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = (float) rotLeft[0] - 0.5f;
|
||||
this.fakeLeftArmwear.rotateAngleX = (float) rotLeft[0] - 0.5f;
|
||||
}
|
||||
|
||||
this.fakeLeftArmwear.rotateAngleY = (float) rotLeft[1];
|
||||
this.fakeLeftArmwear.rotateAngleZ = (float) rotLeft[2];
|
||||
this.fakeLeftArm.rotateAngleY = (float) rotLeft[1];
|
||||
this.fakeLeftArm.rotateAngleZ = (float) rotLeft[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -1.4001F;
|
||||
fakeLeftArm.rotateAngleX = -1.4001F;
|
||||
if (item == RegistrationHandler.itemTile)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = -.9001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -.9001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = -1.4001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.4001F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = -1.2001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.2001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeLeftArm.rotateAngleX = -1.7001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.7001F;
|
||||
}
|
||||
|
||||
this.fakeLeftArm.rotateAngleY = 0.15f;
|
||||
this.fakeLeftArmwear.rotateAngleY = 0.15f;
|
||||
}
|
||||
}
|
||||
|
||||
if (rotRight != null)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = (float) rotRight[0];
|
||||
this.fakeRightArmwear.rotateAngleX = (float) rotRight[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = (float) rotRight[0] - 0.5f;
|
||||
this.fakeRightArmwear.rotateAngleX = (float) rotRight[0] - 0.5f;
|
||||
}
|
||||
|
||||
this.fakeRightArmwear.rotateAngleY = (float) rotRight[1];
|
||||
this.fakeRightArmwear.rotateAngleZ = (float) rotRight[2];
|
||||
this.fakeRightArm.rotateAngleY = (float) rotRight[1];
|
||||
this.fakeRightArm.rotateAngleZ = (float) rotRight[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item == RegistrationHandler.itemTile)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -.9001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -.9001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.4001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.4001F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.2001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.2001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.7001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.7001F;
|
||||
}
|
||||
|
||||
this.fakeRightArm.rotateAngleY = -0.15f;
|
||||
this.fakeRightArmwear.rotateAngleY = -0.15f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
if (item == RegistrationHandler.itemTile)
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -1.2001F;
|
||||
fakeLeftArm.rotateAngleX = -1.2001F;
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -.9001F;
|
||||
this.fakeLeftArm.rotateAngleX = -.9001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -.9001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -.9001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.4001F;
|
||||
this.fakeLeftArm.rotateAngleX = -1.4001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.4001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.4001F;
|
||||
}
|
||||
|
||||
this.fakeRightArm.rotateAngleY = 0f;
|
||||
this.fakeLeftArm.rotateAngleY = 0f;
|
||||
this.fakeLeftArmwear.rotateAngleY = 0f;
|
||||
this.fakeRightArmwear.rotateAngleY = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeRightArm.rotateAngleX = -1.7001F;
|
||||
fakeLeftArm.rotateAngleX = -1.7001F;
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.2001F;
|
||||
this.fakeLeftArm.rotateAngleX = -1.2001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.2001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.2001F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fakeRightArm.rotateAngleX = -1.7001F;
|
||||
this.fakeLeftArm.rotateAngleX = -1.7001F;
|
||||
this.fakeLeftArmwear.rotateAngleX = -1.7001F;
|
||||
this.fakeRightArmwear.rotateAngleX = -1.7001F;
|
||||
}
|
||||
|
||||
this.fakeRightArm.rotateAngleY = -0.15f;
|
||||
this.fakeLeftArm.rotateAngleY = 0.15f;
|
||||
this.fakeLeftArmwear.rotateAngleY = 0.15f;
|
||||
this.fakeRightArmwear.rotateAngleY = -0.15f;
|
||||
}
|
||||
|
||||
fakeRightArm.rotateAngleY = -0.15f;
|
||||
fakeLeftArm.rotateAngleY = 0.15f;
|
||||
|
||||
this.fakeRightArm.rotateAngleZ = 0F;
|
||||
this.fakeLeftArm.rotateAngleZ = 0F;
|
||||
this.fakeLeftArmwear.rotateAngleZ = 0F;
|
||||
this.fakeRightArmwear.rotateAngleZ = 0F;
|
||||
}
|
||||
model.bipedBody.addChild(fakeLeftArm);
|
||||
model.bipedBody.addChild(fakeRightArm);
|
||||
|
||||
model.bipedBody.addChild(this.fakeLeftArm);
|
||||
model.bipedBody.addChild(this.fakeRightArm);
|
||||
|
||||
if (player.isWearing(EnumPlayerModelParts.LEFT_SLEEVE))
|
||||
{
|
||||
model.bipedBody.addChild(this.fakeLeftArmwear);
|
||||
}
|
||||
if (player.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE))
|
||||
{
|
||||
model.bipedBody.addChild(this.fakeRightArmwear);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.bipedLeftArm.isHidden = false;
|
||||
model.bipedRightArm.isHidden = false;
|
||||
model.bipedLeftArmwear.isHidden = false;
|
||||
model.bipedRightArmwear.isHidden = false;
|
||||
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
{
|
||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
double[] rotRight1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
|
||||
float rotX = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
float rotY = model.bipedBody.childModels.get(k).rotateAngleY;
|
||||
float rotZ = model.bipedBody.childModels.get(k).rotateAngleZ;
|
||||
|
||||
if (rotLeft1[0] == rotX || rotLeft1[1] == rotY || rotRight1[2] == rotZ || rotRight1[0] == rotX || rotRight1[1] == rotY || rotRight1[2] == rotZ || rotX == rotLeft1[0] - 0.5f || rotX == rotRight1[0] - 0.5f)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.bipedBody.childModels != null && !model.bipedBody.childModels.isEmpty())
|
||||
{
|
||||
for (int k = 0; k < model.bipedBody.childModels.size(); k++)
|
||||
{
|
||||
float chkRot = model.bipedBody.childModels.get(k).rotateAngleX;
|
||||
|
||||
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
|
||||
{
|
||||
model.bipedBody.childModels.remove(k);
|
||||
k = k - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -428,9 +767,10 @@ public class RenderEvents
|
|||
{
|
||||
model.bipedLeftArm.isHidden = false;
|
||||
model.bipedRightArm.isHidden = false;
|
||||
model.bipedLeftArmwear.isHidden = false;
|
||||
model.bipedRightArmwear.isHidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isChest(Block block)
|
||||
|
|
@ -464,5 +804,4 @@ public class RenderEvents
|
|||
event.setRenderItem(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
package tschipp.carryon.common;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
|
|
@ -8,6 +14,7 @@ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
import tschipp.carryon.network.client.CarrySlotPacketHandler;
|
||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||
|
|
@ -19,6 +26,8 @@ public class CommonProxy
|
|||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
ScriptReader.preInit(event);
|
||||
|
||||
CarryOn.network = NetworkRegistry.INSTANCE.newSimpleChannel("CarryOn");
|
||||
|
||||
CarryOn.network.registerMessage(SyncKeybindPacketHandler.class, SyncKeybindPacket.class, 0, Side.SERVER);
|
||||
|
|
@ -31,6 +40,14 @@ public class CommonProxy
|
|||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptReader.parseScripts();
|
||||
}
|
||||
catch (JsonIOException | JsonSyntaxException | FileNotFoundException | NBTException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
RegistrationHandler.regOverrideList();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import tschipp.carryon.common.handler.ModelOverridesHandler;
|
|||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
|
||||
public class CommandCarryOn extends CommandBase implements ICommand
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
package tschipp.carryon.common.command;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.scripting.ScriptReader;
|
||||
|
||||
public class CommandCarryOnReload extends CommandBase
|
||||
{
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
|
||||
if (CarryOnConfig.settings.useScripts)
|
||||
{
|
||||
ScriptReader.reloadScripts();
|
||||
sender.sendMessage(new TextComponentString("Successfully reloaded scripts!"));
|
||||
}
|
||||
else
|
||||
sender.sendMessage(new TextComponentString("To use custom Carry On scripts, enable them in the config!"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
|
||||
{
|
||||
return sender.canUseCommand(this.getRequiredPermissionLevel(), this.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, "reload");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.<String>emptyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "reloadscripts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return "/reloadscripts";
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,9 @@ public class Configs {
|
|||
|
||||
@Comment("Use Whitelist instead of Blacklist for Entities")
|
||||
public boolean useWhitelistEntities=false;
|
||||
|
||||
@Comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will save you some performance")
|
||||
public boolean useScripts=false;
|
||||
}
|
||||
|
||||
public static class WhiteList
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
|||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
|
||||
public class ItemEntityEvents
|
||||
|
|
@ -97,7 +99,13 @@ public class ItemEntityEvents
|
|||
handler.extractItem(i, 64, false);
|
||||
}
|
||||
}
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem), (EntityPlayerMP) player);
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
||||
int overrideHash = 0;
|
||||
if(override != null)
|
||||
overrideHash = override.hashCode();
|
||||
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, overrideHash), (EntityPlayerMP) player);
|
||||
entity.setDead();
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
event.setCanceled(true);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import tschipp.carryon.common.handler.ListHandler;
|
|||
import tschipp.carryon.common.handler.PickupHandler;
|
||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||
|
||||
public class ItemEvents
|
||||
|
|
@ -114,10 +116,14 @@ public class ItemEvents
|
|||
IBlockState statee = world.getBlockState(pos);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).writeToNBT(tag) : new NBTTagCompound();
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(state, world, pos, tag);
|
||||
int overrideHash = 0;
|
||||
if(override != null)
|
||||
overrideHash = override.hashCode();
|
||||
|
||||
try
|
||||
{
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem), (EntityPlayerMP) player);
|
||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, overrideHash), (EntityPlayerMP) player);
|
||||
world.removeTileEntity(pos);
|
||||
world.setBlockToAir(pos);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,23 @@ public class ListHandler
|
|||
|
||||
public static boolean isForbidden(Block block)
|
||||
{
|
||||
return FORBIDDEN_TILES.contains(block.getRegistryName().toString());
|
||||
String name = block.getRegistryName().toString();
|
||||
if (FORBIDDEN_TILES.contains(name))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
boolean contains = false;
|
||||
for (String s : FORBIDDEN_TILES)
|
||||
{
|
||||
if (s.contains("*"))
|
||||
{
|
||||
if(name.contains(s.replace("*", "")))
|
||||
contains = true;
|
||||
}
|
||||
}
|
||||
|
||||
return contains;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isForbidden(Entity entity)
|
||||
|
|
@ -32,7 +48,8 @@ public class ListHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean isAllowed(Entity entity){
|
||||
public static boolean isAllowed(Entity entity)
|
||||
{
|
||||
if (EntityList.getEntityString(entity) != null)
|
||||
{
|
||||
String name = EntityList.getEntityString(entity).toString();
|
||||
|
|
@ -41,12 +58,28 @@ public class ListHandler
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAllowed(Block block)
|
||||
{
|
||||
return ALLOWED_TILES.contains(block.getRegistryName().toString());
|
||||
String name = block.getRegistryName().toString();
|
||||
if (ALLOWED_TILES.contains(name))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
boolean contains = false;
|
||||
for (String s : ALLOWED_TILES)
|
||||
{
|
||||
if (s.contains("*"))
|
||||
{
|
||||
if(name.contains(s.replace("*", "")))
|
||||
contains = true;
|
||||
}
|
||||
}
|
||||
return contains;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void initForbiddenTiles()
|
||||
{
|
||||
String[] forbidden = CarryOnConfig.blacklist.forbiddenTiles;
|
||||
|
|
@ -54,17 +87,6 @@ public class ListHandler
|
|||
|
||||
for (int i = 0; i < forbidden.length; i++)
|
||||
{
|
||||
if (forbidden[i].contains("*"))
|
||||
{
|
||||
String modid = forbidden[i].replace("*", "");
|
||||
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
|
||||
{
|
||||
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
|
||||
{
|
||||
FORBIDDEN_TILES.add(Block.REGISTRY.getKeys().toArray()[k].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_TILES.add(forbidden[i]);
|
||||
}
|
||||
|
||||
|
|
@ -86,11 +108,12 @@ public class ListHandler
|
|||
}
|
||||
FORBIDDEN_ENTITIES.add(forbiddenEntity[i]);
|
||||
}
|
||||
|
||||
String [] allowedEntities=CarryOnConfig.whitelist.allowedEntities;
|
||||
ALLOWED_ENTITIES=new ArrayList<String>();
|
||||
for(int i=0;i<allowedEntities.length;i++){
|
||||
if(allowedEntities[i].contains("*"))
|
||||
|
||||
String[] allowedEntities = CarryOnConfig.whitelist.allowedEntities;
|
||||
ALLOWED_ENTITIES = new ArrayList<String>();
|
||||
for (int i = 0; i < allowedEntities.length; i++)
|
||||
{
|
||||
if (allowedEntities[i].contains("*"))
|
||||
{
|
||||
String modid=allowedEntities[i].replace("*", "");
|
||||
for (int k = 0; k < EntityList.getEntityNameList().size(); k++)
|
||||
|
|
@ -103,23 +126,11 @@ public class ListHandler
|
|||
}
|
||||
ALLOWED_ENTITIES.add(allowedEntities[i]);
|
||||
}
|
||||
|
||||
|
||||
String[] allowedBlocks = CarryOnConfig.whitelist.allowedBlocks;
|
||||
ALLOWED_TILES = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < allowedBlocks.length; i++)
|
||||
{
|
||||
if (allowedBlocks[i].contains("*"))
|
||||
{
|
||||
String modid = allowedBlocks[i].replace("*", "");
|
||||
for (int k = 0; k < Block.REGISTRY.getKeys().size(); k++)
|
||||
{
|
||||
if (Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid))
|
||||
{
|
||||
ALLOWED_TILES.add(Block.REGISTRY.getKeys().toArray()[k].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_TILES.add(allowedBlocks[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import net.minecraft.entity.EnumCreatureType;
|
|||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
|
@ -21,6 +22,8 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.common.Loader;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class PickupHandler
|
||||
{
|
||||
|
|
@ -32,34 +35,46 @@ public class PickupHandler
|
|||
|
||||
player.closeScreen();
|
||||
|
||||
if (CarryOnConfig.settings.useWhitelistBlocks)
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (tile != null)
|
||||
tile.writeToNBT(tag);
|
||||
|
||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
||||
if (override != null)
|
||||
{
|
||||
if (!ListHandler.isAllowed(world.getBlockState(pos).getBlock()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleFTBUtils((EntityPlayerMP) player, world, pos, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
|
||||
if (CarryOnConfig.settings.useWhitelistBlocks)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
if (!ItemTile.isLocked(pos, world))
|
||||
if (!ListHandler.isAllowed(world.getBlockState(pos).getBlock()))
|
||||
{
|
||||
if (CarryOnConfig.settings.pickupAllBlocks ? true : tile != null)
|
||||
{
|
||||
return true && handleFTBUtils((EntityPlayerMP) player, world, pos, state);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((block.getBlockHardness(state, world, pos) != -1 || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
if (!ItemTile.isLocked(pos, world))
|
||||
{
|
||||
if (CarryOnConfig.settings.pickupAllBlocks ? true : tile != null)
|
||||
{
|
||||
return true && handleFTBUtils((EntityPlayerMP) player, world, pos, state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,49 +89,21 @@ public class PickupHandler
|
|||
if (toPickUp instanceof EntityPlayer)
|
||||
return false;
|
||||
|
||||
// check for allow babies to be picked up
|
||||
if (toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies)
|
||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||
if (override != null)
|
||||
{
|
||||
EntityAgeable living = (EntityAgeable) toPickUp;
|
||||
if (living.getGrowingAge() < 0 || living.isChild())
|
||||
{
|
||||
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
if (toPickUp instanceof EntityTameable)
|
||||
{
|
||||
EntityTameable tame = (EntityTameable) toPickUp;
|
||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CarryOnConfig.settings.useWhitelistEntities)
|
||||
{
|
||||
if (!ListHandler.isAllowed(toPickUp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (ScriptChecker.fulfillsConditions(override, player));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ListHandler.isForbidden(toPickUp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
{
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
// check for allow babies to be picked up
|
||||
if (toPickUp instanceof EntityAgeable && CarryOnConfig.settings.allowBabies)
|
||||
{
|
||||
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
||||
EntityAgeable living = (EntityAgeable) toPickUp;
|
||||
if (living.getGrowingAge() < 0 || living.isChild())
|
||||
{
|
||||
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
|
|
@ -132,6 +119,43 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (CarryOnConfig.settings.useWhitelistEntities)
|
||||
{
|
||||
if (!ListHandler.isAllowed(toPickUp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ListHandler.isForbidden(toPickUp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
{
|
||||
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
|
||||
{
|
||||
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
|
||||
{
|
||||
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
|
||||
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
|
||||
{
|
||||
if (toPickUp instanceof EntityTameable)
|
||||
{
|
||||
EntityTameable tame = (EntityTameable) toPickUp;
|
||||
if (tame.getOwnerId() != null && tame.getOwnerId() != player.getUUID(player.getGameProfile()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,312 @@
|
|||
package tschipp.carryon.common.helper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ScriptParseHelper
|
||||
{
|
||||
|
||||
public static boolean matches(double number, String cond)
|
||||
{
|
||||
if (cond == null)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
if (cond.contains("<="))
|
||||
{
|
||||
return number <= Double.parseDouble(cond.replace("<=", ""));
|
||||
}
|
||||
if (cond.contains(">="))
|
||||
{
|
||||
return number >= Double.parseDouble(cond.replace(">=", ""));
|
||||
}
|
||||
if (cond.contains("<"))
|
||||
{
|
||||
return number < Double.parseDouble(cond.replace("<", ""));
|
||||
}
|
||||
if (cond.contains(">"))
|
||||
{
|
||||
return number > Double.parseDouble(cond.replace(">", ""));
|
||||
}
|
||||
if (cond.contains("="))
|
||||
{
|
||||
return number == Double.parseDouble(cond.replace("=", ""));
|
||||
}
|
||||
else
|
||||
return number == Double.parseDouble(cond);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
new InvalidConfigException(e.getMessage()).printException();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(Block block, String cond)
|
||||
{
|
||||
if (cond == null)
|
||||
return true;
|
||||
|
||||
Block toCheck = StringParser.getBlock(cond);
|
||||
if (toCheck != null)
|
||||
return block == toCheck;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(NBTTagCompound toCheck, NBTTagCompound toMatch)
|
||||
{
|
||||
if (toCheck == null || toMatch == null)
|
||||
return true;
|
||||
|
||||
boolean matching = true;
|
||||
for (String key : toMatch.getKeySet())
|
||||
{
|
||||
NBTBase tag = toMatch.getTag(key);
|
||||
key = key.replace("\"", "");
|
||||
NBTBase tagToCheck = toCheck.getTag(key);
|
||||
if (!tag.equals(tagToCheck))
|
||||
matching = false;
|
||||
}
|
||||
|
||||
return matching;
|
||||
}
|
||||
|
||||
public static double[] getXYZArray(String s)
|
||||
{
|
||||
double[] d = new double[3];
|
||||
d[0] = getValueFromString(s, "x");
|
||||
d[1] = getValueFromString(s, "y");
|
||||
d[2] = getValueFromString(s, "z");
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
public static double[] getScale(String s)
|
||||
{
|
||||
double[] d = new double[3];
|
||||
d[0] = getScaleValueFromString(s, "x");
|
||||
d[1] = getScaleValueFromString(s, "y");
|
||||
d[2] = getScaleValueFromString(s, "z");
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public static double getScaleValueFromString(String toGetFrom, String key)
|
||||
{
|
||||
if(toGetFrom == null)
|
||||
return 1;
|
||||
|
||||
String[] s = toGetFrom.split(",");
|
||||
for (String string : s)
|
||||
{
|
||||
if (string.contains(key) && string.contains("="))
|
||||
{
|
||||
double numb = 1;
|
||||
string = string.replace(key + "=", "");
|
||||
|
||||
try
|
||||
{
|
||||
numb = Double.parseDouble(string);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
return numb;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static Achievement getAchievementFromString(String s)
|
||||
{
|
||||
if (s == null)
|
||||
return null;
|
||||
|
||||
for (Achievement a : AchievementList.ACHIEVEMENTS)
|
||||
{
|
||||
if (a.statId.equals(s))
|
||||
return a;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean matchesScore(EntityPlayer player, String cond)
|
||||
{
|
||||
if (cond == null)
|
||||
return true;
|
||||
|
||||
Scoreboard score = player.getWorldScoreboard();
|
||||
String numb;
|
||||
String scorename;
|
||||
int iE = cond.indexOf("=");
|
||||
int iG = cond.indexOf(">");
|
||||
int iL = cond.indexOf("<");
|
||||
|
||||
if (iG == -1 ? true : iE < iG && iL == -1 ? true : iE < iL && iE != -1)
|
||||
numb = cond.substring(iE);
|
||||
else if (iE == -1 ? true : iG < iE && iL == -1 ? true : iG < iL && iG != -1)
|
||||
numb = cond.substring(iG);
|
||||
else
|
||||
numb = cond.substring(iL);
|
||||
|
||||
scorename = cond.replace(numb, "");
|
||||
Map<ScoreObjective, Score> o = score.getObjectivesForEntity(player.getGameProfile().getName());
|
||||
if (o != null)
|
||||
{
|
||||
Score sc = o.get(score.getObjective(scorename));
|
||||
if (sc != null)
|
||||
{
|
||||
int points = sc.getScorePoints();
|
||||
|
||||
return matches(points, numb);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(BlockPos pos, String cond)
|
||||
{
|
||||
if (cond == null)
|
||||
return true;
|
||||
|
||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"), getValueFromString(cond, "dz"));
|
||||
BlockPos expanded = blockpos.add(expand);
|
||||
|
||||
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
||||
boolean y = (pos.getY() >= blockpos.getY() && pos.getY() <= expanded.getY()) || blockpos.getY() == 0;
|
||||
boolean z = (pos.getZ() >= blockpos.getZ() && pos.getZ() <= expanded.getZ()) || blockpos.getZ() == 0;
|
||||
|
||||
return x && y && z;
|
||||
}
|
||||
|
||||
public static double getValueFromString(String toGetFrom, String key)
|
||||
{
|
||||
if(toGetFrom == null)
|
||||
return 0;
|
||||
|
||||
String[] s = toGetFrom.split(",");
|
||||
for (String string : s)
|
||||
{
|
||||
if (string.contains(key) && string.contains("="))
|
||||
{
|
||||
double numb = 0;
|
||||
string = string.replace(key + "=", "");
|
||||
|
||||
try
|
||||
{
|
||||
numb = Double.parseDouble(string);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
return numb;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean matches(Material material, String cond)
|
||||
{
|
||||
if (cond == null)
|
||||
return true;
|
||||
|
||||
switch (cond)
|
||||
{
|
||||
case "air":
|
||||
return material == Material.AIR;
|
||||
case "anvil":
|
||||
return material == Material.ANVIL;
|
||||
case "barrier":
|
||||
return material == Material.BARRIER;
|
||||
case "cactus":
|
||||
return material == Material.CACTUS;
|
||||
case "cake":
|
||||
return material == Material.CAKE;
|
||||
case "carpet":
|
||||
return material == Material.CARPET;
|
||||
case "circuits":
|
||||
return material == Material.CIRCUITS;
|
||||
case "clay":
|
||||
return material == Material.CLAY;
|
||||
case "cloth":
|
||||
return material == Material.CLOTH;
|
||||
case "coral":
|
||||
return material == Material.CORAL;
|
||||
case "dragon_egg":
|
||||
return material == Material.DRAGON_EGG;
|
||||
case "fire":
|
||||
return material == Material.FIRE;
|
||||
case "glass":
|
||||
return material == Material.GLASS;
|
||||
case "gourd":
|
||||
return material == Material.GOURD;
|
||||
case "grass":
|
||||
return material == Material.GRASS;
|
||||
case "ground":
|
||||
return material == Material.GROUND;
|
||||
case "ice":
|
||||
return material == Material.ICE;
|
||||
case "iron":
|
||||
return material == Material.IRON;
|
||||
case "lava":
|
||||
return material == Material.LAVA;
|
||||
case "leaves":
|
||||
return material == Material.LEAVES;
|
||||
case "packed_ice":
|
||||
return material == Material.PACKED_ICE;
|
||||
case "piston":
|
||||
return material == Material.PISTON;
|
||||
case "plants":
|
||||
return material == Material.PLANTS;
|
||||
case "portal":
|
||||
return material == Material.PORTAL;
|
||||
case "redstone_light":
|
||||
return material == Material.REDSTONE_LIGHT;
|
||||
case "rock":
|
||||
return material == Material.ROCK;
|
||||
case "sand":
|
||||
return material == Material.SAND;
|
||||
case "snow":
|
||||
return material == Material.SNOW;
|
||||
case "sponge":
|
||||
return material == Material.SPONGE;
|
||||
case "structure_void":
|
||||
return material == Material.STRUCTURE_VOID;
|
||||
case "tnt":
|
||||
return material == Material.TNT;
|
||||
case "vine":
|
||||
return material == Material.VINE;
|
||||
case "water":
|
||||
return material == Material.WATER;
|
||||
case "web":
|
||||
return material == Material.WEB;
|
||||
case "wood":
|
||||
return material == Material.WOOD;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,9 @@ public class StringParser
|
|||
@Nullable
|
||||
public static Block getBlock(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
|
@ -35,6 +38,9 @@ public class StringParser
|
|||
|
||||
public static int getMeta(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return 0;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
|
@ -59,6 +65,9 @@ public class StringParser
|
|||
@Nullable
|
||||
public static IBlockState getBlockState(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
|
@ -84,6 +93,9 @@ public class StringParser
|
|||
@Nullable
|
||||
public static Item getItem(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
NBTTagCompound tag = getTagCompound(string);
|
||||
if (tag != null)
|
||||
string = string.replace(tag.toString(), "");
|
||||
|
|
@ -96,6 +108,9 @@ public class StringParser
|
|||
|
||||
public static ItemStack getItemStack(String string)
|
||||
{
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
Item item = getItem(string);
|
||||
|
||||
if(item == null)
|
||||
|
|
@ -113,6 +128,9 @@ public class StringParser
|
|||
public static NBTTagCompound getTagCompound(String string)
|
||||
{
|
||||
NBTTagCompound tag = null;
|
||||
if(string == null)
|
||||
return null;
|
||||
|
||||
if (string.contains("{"))
|
||||
{
|
||||
if (!string.contains("}"))
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ public class ItemEntity extends Item
|
|||
clearEntityData(stack);
|
||||
player.setHeldItem(hand, null);
|
||||
}
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ public class ItemTile extends Item
|
|||
clearTileData(stack);
|
||||
player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
player.setHeldItem(hand, null);
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,579 @@
|
|||
package tschipp.carryon.common.scripting;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class CarryOnOverride
|
||||
{
|
||||
// BLOCKS
|
||||
private NBTTagCompound typeBlockTag;
|
||||
private String typeMeta;
|
||||
private String typeNameBlock;
|
||||
private String typeMaterial;
|
||||
private String typeHardness;
|
||||
private String typeResistance;
|
||||
|
||||
// ENTITIES
|
||||
private NBTTagCompound typeEntityTag;
|
||||
private String typeNameEntity;
|
||||
private String typeHeight;
|
||||
private String typeWidth;
|
||||
private String typeHealth;
|
||||
|
||||
// CONDITIONS
|
||||
private String conditionGamestage;
|
||||
private String conditionAchievement;
|
||||
private String conditionXp;
|
||||
private String conditionGamemode;
|
||||
private String conditionScoreboard;
|
||||
private String conditionPosition;
|
||||
|
||||
// RENDER
|
||||
private String renderNameBlock;
|
||||
private String renderNameEntity;
|
||||
private int renderMeta;
|
||||
private NBTTagCompound renderNBT;
|
||||
private String renderTranslation;
|
||||
private String renderRotation;
|
||||
private String renderScale;
|
||||
private String renderRotationLeftArm;
|
||||
private String renderRotationRightArm;
|
||||
|
||||
private boolean isBlock;
|
||||
private boolean isEntity;
|
||||
|
||||
private boolean renderLeftArm = true;
|
||||
private boolean renderRightArm = true;
|
||||
|
||||
public String getRenderRotationLeftArm()
|
||||
{
|
||||
return renderRotationLeftArm;
|
||||
}
|
||||
|
||||
public void setRenderRotationLeftArm(String renderRotationLeftArm)
|
||||
{
|
||||
this.renderRotationLeftArm = renderRotationLeftArm;
|
||||
}
|
||||
|
||||
public String getRenderRotationRightArm()
|
||||
{
|
||||
return renderRotationRightArm;
|
||||
}
|
||||
|
||||
public void setRenderRotationRightArm(String renderRotationRightArm)
|
||||
{
|
||||
this.renderRotationRightArm = renderRotationRightArm;
|
||||
}
|
||||
|
||||
public boolean isRenderLeftArm()
|
||||
{
|
||||
return renderLeftArm;
|
||||
}
|
||||
|
||||
public void setRenderLeftArm(boolean renderLeftArm)
|
||||
{
|
||||
this.renderLeftArm = renderLeftArm;
|
||||
}
|
||||
|
||||
public boolean isRenderRightArm()
|
||||
{
|
||||
return renderRightArm;
|
||||
}
|
||||
|
||||
public void setRenderRightArm(boolean renderRightArm)
|
||||
{
|
||||
this.renderRightArm = renderRightArm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((conditionAchievement == null) ? 0 : conditionAchievement.hashCode());
|
||||
result = prime * result + ((conditionGamemode == null) ? 0 : conditionGamemode.hashCode());
|
||||
result = prime * result + ((conditionGamestage == null) ? 0 : conditionGamestage.hashCode());
|
||||
result = prime * result + ((conditionPosition == null) ? 0 : conditionPosition.hashCode());
|
||||
result = prime * result + ((conditionScoreboard == null) ? 0 : conditionScoreboard.hashCode());
|
||||
result = prime * result + ((conditionXp == null) ? 0 : conditionXp.hashCode());
|
||||
result = prime * result + (isBlock ? 1231 : 1237);
|
||||
result = prime * result + (isEntity ? 1231 : 1237);
|
||||
result = prime * result + (renderLeftArm ? 1231 : 1237);
|
||||
result = prime * result + (renderRightArm ? 1231 : 1237);
|
||||
result = prime * result + renderMeta;
|
||||
result = prime * result + ((renderNBT == null) ? 0 : renderNBT.hashCode());
|
||||
result = prime * result + ((renderNameBlock == null) ? 0 : renderNameBlock.hashCode());
|
||||
result = prime * result + ((renderNameEntity == null) ? 0 : renderNameEntity.hashCode());
|
||||
result = prime * result + ((renderRotation == null) ? 0 : renderRotation.hashCode());
|
||||
result = prime * result + ((renderRotationLeftArm == null) ? 0 : renderRotationLeftArm.hashCode());
|
||||
result = prime * result + ((renderRotationRightArm == null) ? 0 : renderRotationRightArm.hashCode());
|
||||
result = prime * result + ((renderScale == null) ? 0 : renderScale.hashCode());
|
||||
result = prime * result + ((renderTranslation == null) ? 0 : renderTranslation.hashCode());
|
||||
result = prime * result + ((typeBlockTag == null) ? 0 : typeBlockTag.hashCode());
|
||||
result = prime * result + ((typeEntityTag == null) ? 0 : typeEntityTag.hashCode());
|
||||
result = prime * result + ((typeHardness == null) ? 0 : typeHardness.hashCode());
|
||||
result = prime * result + ((typeHealth == null) ? 0 : typeHealth.hashCode());
|
||||
result = prime * result + ((typeHeight == null) ? 0 : typeHeight.hashCode());
|
||||
result = prime * result + ((typeMaterial == null) ? 0 : typeMaterial.hashCode());
|
||||
result = prime * result + ((typeMeta == null) ? 0 : typeMeta.hashCode());
|
||||
result = prime * result + ((typeNameBlock == null) ? 0 : typeNameBlock.hashCode());
|
||||
result = prime * result + ((typeNameEntity == null) ? 0 : typeNameEntity.hashCode());
|
||||
result = prime * result + ((typeResistance == null) ? 0 : typeResistance.hashCode());
|
||||
result = prime * result + ((typeWidth == null) ? 0 : typeWidth.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CarryOnOverride other = (CarryOnOverride) obj;
|
||||
if (conditionAchievement == null)
|
||||
{
|
||||
if (other.conditionAchievement != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionAchievement.equals(other.conditionAchievement))
|
||||
return false;
|
||||
if (conditionGamemode == null)
|
||||
{
|
||||
if (other.conditionGamemode != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionGamemode.equals(other.conditionGamemode))
|
||||
return false;
|
||||
if (conditionGamestage == null)
|
||||
{
|
||||
if (other.conditionGamestage != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionGamestage.equals(other.conditionGamestage))
|
||||
return false;
|
||||
if (conditionPosition == null)
|
||||
{
|
||||
if (other.conditionPosition != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionPosition.equals(other.conditionPosition))
|
||||
return false;
|
||||
if (conditionScoreboard == null)
|
||||
{
|
||||
if (other.conditionScoreboard != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionScoreboard.equals(other.conditionScoreboard))
|
||||
return false;
|
||||
if (conditionXp == null)
|
||||
{
|
||||
if (other.conditionXp != null)
|
||||
return false;
|
||||
}
|
||||
else if (!conditionXp.equals(other.conditionXp))
|
||||
return false;
|
||||
if (isBlock != other.isBlock)
|
||||
return false;
|
||||
if (isEntity != other.isEntity)
|
||||
return false;
|
||||
if (renderMeta != other.renderMeta)
|
||||
return false;
|
||||
if (renderNBT == null)
|
||||
{
|
||||
if (other.renderNBT != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderNBT.equals(other.renderNBT))
|
||||
return false;
|
||||
if (renderNameBlock == null)
|
||||
{
|
||||
if (other.renderNameBlock != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderNameBlock.equals(other.renderNameBlock))
|
||||
return false;
|
||||
if (renderNameEntity == null)
|
||||
{
|
||||
if (other.renderNameEntity != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderNameEntity.equals(other.renderNameEntity))
|
||||
return false;
|
||||
if (renderRotation == null)
|
||||
{
|
||||
if (other.renderRotation != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderRotation.equals(other.renderRotation))
|
||||
return false;
|
||||
if (renderRotationLeftArm == null)
|
||||
{
|
||||
if (other.renderRotationLeftArm != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderRotationLeftArm.equals(other.renderRotationLeftArm))
|
||||
return false;
|
||||
if (renderRotationRightArm == null)
|
||||
{
|
||||
if (other.renderRotationRightArm != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderRotationRightArm.equals(other.renderRotationRightArm))
|
||||
return false;
|
||||
if (renderScale == null)
|
||||
{
|
||||
if (other.renderScale != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderScale.equals(other.renderScale))
|
||||
return false;
|
||||
if (renderTranslation == null)
|
||||
{
|
||||
if (other.renderTranslation != null)
|
||||
return false;
|
||||
}
|
||||
else if (!renderTranslation.equals(other.renderTranslation))
|
||||
return false;
|
||||
if (typeBlockTag == null)
|
||||
{
|
||||
if (other.typeBlockTag != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeBlockTag.equals(other.typeBlockTag))
|
||||
return false;
|
||||
if (typeEntityTag == null)
|
||||
{
|
||||
if (other.typeEntityTag != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeEntityTag.equals(other.typeEntityTag))
|
||||
return false;
|
||||
if (typeHardness == null)
|
||||
{
|
||||
if (other.typeHardness != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeHardness.equals(other.typeHardness))
|
||||
return false;
|
||||
if (typeHealth == null)
|
||||
{
|
||||
if (other.typeHealth != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeHealth.equals(other.typeHealth))
|
||||
return false;
|
||||
if (typeHeight == null)
|
||||
{
|
||||
if (other.typeHeight != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeHeight.equals(other.typeHeight))
|
||||
return false;
|
||||
if (typeMaterial == null)
|
||||
{
|
||||
if (other.typeMaterial != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeMaterial.equals(other.typeMaterial))
|
||||
return false;
|
||||
if (typeMeta == null)
|
||||
{
|
||||
if (other.typeMeta != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeMeta.equals(other.typeMeta))
|
||||
return false;
|
||||
if (typeNameBlock == null)
|
||||
{
|
||||
if (other.typeNameBlock != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeNameBlock.equals(other.typeNameBlock))
|
||||
return false;
|
||||
if (typeNameEntity == null)
|
||||
{
|
||||
if (other.typeNameEntity != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeNameEntity.equals(other.typeNameEntity))
|
||||
return false;
|
||||
if (typeResistance == null)
|
||||
{
|
||||
if (other.typeResistance != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeResistance.equals(other.typeResistance))
|
||||
return false;
|
||||
if (typeWidth == null)
|
||||
{
|
||||
if (other.typeWidth != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeWidth.equals(other.typeWidth))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBlock()
|
||||
{
|
||||
return isBlock;
|
||||
}
|
||||
|
||||
public void setBlock(boolean isBlock)
|
||||
{
|
||||
this.isBlock = isBlock;
|
||||
}
|
||||
|
||||
public boolean isEntity()
|
||||
{
|
||||
return isEntity;
|
||||
}
|
||||
|
||||
public void setEntity(boolean isEntity)
|
||||
{
|
||||
this.isEntity = isEntity;
|
||||
}
|
||||
|
||||
public NBTTagCompound getTypeBlockTag()
|
||||
{
|
||||
return typeBlockTag;
|
||||
}
|
||||
|
||||
public String getTypeMeta()
|
||||
{
|
||||
return typeMeta;
|
||||
}
|
||||
|
||||
public String getTypeNameBlock()
|
||||
{
|
||||
return typeNameBlock;
|
||||
}
|
||||
|
||||
public String getTypeMaterial()
|
||||
{
|
||||
return typeMaterial;
|
||||
}
|
||||
|
||||
public String getTypeHardness()
|
||||
{
|
||||
return typeHardness;
|
||||
}
|
||||
|
||||
public String getTypeResistance()
|
||||
{
|
||||
return typeResistance;
|
||||
}
|
||||
|
||||
public NBTTagCompound getTypeEntityTag()
|
||||
{
|
||||
return typeEntityTag;
|
||||
}
|
||||
|
||||
public String getTypeNameEntity()
|
||||
{
|
||||
return typeNameEntity;
|
||||
}
|
||||
|
||||
public String getTypeHeight()
|
||||
{
|
||||
return typeHeight;
|
||||
}
|
||||
|
||||
public String getTypeWidth()
|
||||
{
|
||||
return typeWidth;
|
||||
}
|
||||
|
||||
public String getTypeHealth()
|
||||
{
|
||||
return typeHealth;
|
||||
}
|
||||
|
||||
public String getConditionGamestage()
|
||||
{
|
||||
return conditionGamestage;
|
||||
}
|
||||
|
||||
public String getConditionAchievement()
|
||||
{
|
||||
return conditionAchievement;
|
||||
}
|
||||
|
||||
public String getConditionXp()
|
||||
{
|
||||
return conditionXp;
|
||||
}
|
||||
|
||||
public String getConditionGamemode()
|
||||
{
|
||||
return conditionGamemode;
|
||||
}
|
||||
|
||||
public String getConditionScoreboard()
|
||||
{
|
||||
return conditionScoreboard;
|
||||
}
|
||||
|
||||
public String getConditionPosition()
|
||||
{
|
||||
return conditionPosition;
|
||||
}
|
||||
|
||||
public String getRenderNameBlock()
|
||||
{
|
||||
return renderNameBlock;
|
||||
}
|
||||
|
||||
public String getRenderNameEntity()
|
||||
{
|
||||
return renderNameEntity;
|
||||
}
|
||||
|
||||
public int getRenderMeta()
|
||||
{
|
||||
return renderMeta;
|
||||
}
|
||||
|
||||
public NBTTagCompound getRenderNBT()
|
||||
{
|
||||
return renderNBT;
|
||||
}
|
||||
|
||||
public String getRenderTranslation()
|
||||
{
|
||||
return renderTranslation;
|
||||
}
|
||||
|
||||
public String getRenderRotation()
|
||||
{
|
||||
return renderRotation;
|
||||
}
|
||||
|
||||
public String getRenderScale()
|
||||
{
|
||||
return renderScale;
|
||||
}
|
||||
|
||||
public void setTypeBlockTag(NBTTagCompound typeBlockTag)
|
||||
{
|
||||
this.typeBlockTag = typeBlockTag;
|
||||
}
|
||||
|
||||
public void setTypeMeta(String typeMeta)
|
||||
{
|
||||
this.typeMeta = typeMeta;
|
||||
}
|
||||
|
||||
public void setTypeNameBlock(String typeNameBlock)
|
||||
{
|
||||
this.typeNameBlock = typeNameBlock;
|
||||
}
|
||||
|
||||
public void setTypeMaterial(String typeMaterial)
|
||||
{
|
||||
this.typeMaterial = typeMaterial;
|
||||
}
|
||||
|
||||
public void setTypeHardness(String typeHardness)
|
||||
{
|
||||
this.typeHardness = typeHardness;
|
||||
}
|
||||
|
||||
public void setTypeResistance(String typeResistance)
|
||||
{
|
||||
this.typeResistance = typeResistance;
|
||||
}
|
||||
|
||||
public void setTypeEntityTag(NBTTagCompound typeEntityTag)
|
||||
{
|
||||
this.typeEntityTag = typeEntityTag;
|
||||
}
|
||||
|
||||
public void setTypeNameEntity(String typeNameEntity)
|
||||
{
|
||||
this.typeNameEntity = typeNameEntity;
|
||||
}
|
||||
|
||||
public void setTypeHeight(String typeHeight)
|
||||
{
|
||||
this.typeHeight = typeHeight;
|
||||
}
|
||||
|
||||
public void setTypeWidth(String typeWidth)
|
||||
{
|
||||
this.typeWidth = typeWidth;
|
||||
}
|
||||
|
||||
public void setTypeHealth(String typeHealth)
|
||||
{
|
||||
this.typeHealth = typeHealth;
|
||||
}
|
||||
|
||||
public void setConditionGamestage(String conditionGamestage)
|
||||
{
|
||||
this.conditionGamestage = conditionGamestage;
|
||||
}
|
||||
|
||||
public void setConditionAchievement(String conditionAchievement)
|
||||
{
|
||||
this.conditionAchievement = conditionAchievement;
|
||||
}
|
||||
|
||||
public void setConditionXp(String conditionXp)
|
||||
{
|
||||
this.conditionXp = conditionXp;
|
||||
}
|
||||
|
||||
public void setConditionGamemode(String conditionGamemode)
|
||||
{
|
||||
this.conditionGamemode = conditionGamemode;
|
||||
}
|
||||
|
||||
public void setConditionScoreboard(String conditionScoreboard)
|
||||
{
|
||||
this.conditionScoreboard = conditionScoreboard;
|
||||
}
|
||||
|
||||
public void setConditionPosition(String conditionPosition)
|
||||
{
|
||||
this.conditionPosition = conditionPosition;
|
||||
}
|
||||
|
||||
public void setRenderNameBlock(String renderNameBlock)
|
||||
{
|
||||
this.renderNameBlock = renderNameBlock;
|
||||
}
|
||||
|
||||
public void setRenderNameEntity(String renderNameEntity)
|
||||
{
|
||||
this.renderNameEntity = renderNameEntity;
|
||||
}
|
||||
|
||||
public void setRenderMeta(int renderMeta)
|
||||
{
|
||||
this.renderMeta = renderMeta;
|
||||
}
|
||||
|
||||
public void setRenderNBT(NBTTagCompound renderNBT)
|
||||
{
|
||||
this.renderNBT = renderNBT;
|
||||
}
|
||||
|
||||
public void setRenderTranslation(String renderTranslation)
|
||||
{
|
||||
this.renderTranslation = renderTranslation;
|
||||
}
|
||||
|
||||
public void setRenderRotation(String renderRotation)
|
||||
{
|
||||
this.renderRotation = renderRotation;
|
||||
}
|
||||
|
||||
public void setRenderScale(String renderScale)
|
||||
{
|
||||
this.renderScale = renderScale;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package tschipp.carryon.common.scripting;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||
|
||||
public class ScriptChecker
|
||||
{
|
||||
@Nullable
|
||||
public static CarryOnOverride inspectBlock(IBlockState state, World world, BlockPos pos, @Nullable NBTTagCompound tag)
|
||||
{
|
||||
if (!CarryOnConfig.settings.useScripts)
|
||||
return null;
|
||||
|
||||
Block block = state.getBlock();
|
||||
int meta = block.getMetaFromState(state);
|
||||
Material material = state.getMaterial();
|
||||
float hardness = state.getBlockHardness(world, pos);
|
||||
float resistance = block.getExplosionResistance(null);
|
||||
NBTTagCompound nbt = tag;
|
||||
|
||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||
{
|
||||
if (override.isBlock())
|
||||
{
|
||||
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
||||
return override;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CarryOnOverride inspectEntity(Entity entity)
|
||||
{
|
||||
if (!CarryOnConfig.settings.useScripts)
|
||||
return null;
|
||||
|
||||
String name = EntityList.getEntityString(entity).toString();
|
||||
float height = entity.height;
|
||||
float width = entity.width;
|
||||
float health = entity instanceof EntityLivingBase ? ((EntityLivingBase) entity).getHealth() : 0.0f;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
|
||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||
{
|
||||
if (override.isEntity())
|
||||
{
|
||||
if (matchesAll(override, name, height, width, health, tag))
|
||||
return override;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, NBTTagCompound tag)
|
||||
{
|
||||
boolean matchname = override.getTypeNameEntity() == null ? true : name.equals(override.getTypeNameEntity());
|
||||
boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
||||
boolean matchwidth = ScriptParseHelper.matches(width, override.getTypeWidth());
|
||||
boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth());
|
||||
boolean matchnbt = ScriptParseHelper.matches(tag, override.getTypeEntityTag());
|
||||
|
||||
return (matchname && matchheight && matchwidth && matchhealth && matchnbt);
|
||||
}
|
||||
|
||||
public static boolean matchesAll(CarryOnOverride override, Block block, int meta, Material material, float hardness, float resistance, NBTTagCompound nbt)
|
||||
{
|
||||
boolean matchnbt = ScriptParseHelper.matches(nbt, override.getTypeBlockTag());
|
||||
boolean matchblock = ScriptParseHelper.matches(block, override.getTypeNameBlock());
|
||||
boolean matchmeta = ScriptParseHelper.matches(meta, override.getTypeMeta());
|
||||
boolean matchmaterial = ScriptParseHelper.matches(material, override.getTypeMaterial());
|
||||
boolean matchhardness = ScriptParseHelper.matches(hardness, override.getTypeHardness());
|
||||
boolean matchresistance = ScriptParseHelper.matches(resistance, override.getTypeResistance());
|
||||
|
||||
return (matchnbt && matchblock && matchmeta && matchmaterial && matchhardness && matchresistance);
|
||||
}
|
||||
|
||||
public static boolean fulfillsConditions(CarryOnOverride override, EntityPlayer player)
|
||||
{
|
||||
boolean achievement = ScriptParseHelper.getAchievementFromString(override.getConditionAchievement()) == null ? true : player.hasAchievement(ScriptParseHelper.getAchievementFromString(override.getConditionAchievement()));
|
||||
boolean gamemode = ScriptParseHelper.matches(((EntityPlayerMP) player).interactionManager.getGameType().getID(), override.getConditionGamemode());
|
||||
boolean position = ScriptParseHelper.matches(player.getPosition(), override.getConditionPosition());
|
||||
boolean xp = ScriptParseHelper.matches(player.experienceLevel, override.getConditionXp());
|
||||
boolean scoreboard = ScriptParseHelper.matchesScore(player, override.getConditionScoreboard());
|
||||
|
||||
return (achievement && gamemode && position && xp && scoreboard);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CarryOnOverride getOverride(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tag = player.getEntityData();
|
||||
|
||||
if (tag != null && tag.hasKey("overrideKey"))
|
||||
{
|
||||
int key = tag.getInteger("overrideKey");
|
||||
|
||||
return ScriptReader.OVERRIDES.get(key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setCarryOnOverride(EntityPlayer player, int i)
|
||||
{
|
||||
NBTTagCompound tag = player.getEntityData();
|
||||
|
||||
if (tag != null)
|
||||
tag.setInteger("overrideKey", i);
|
||||
}
|
||||
|
||||
}
|
||||
206
src/main/java/tschipp/carryon/common/scripting/ScriptReader.java
Normal file
206
src/main/java/tschipp/carryon/common/scripting/ScriptReader.java
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
package tschipp.carryon.common.scripting;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import tschipp.carryon.CarryOn;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
|
||||
public class ScriptReader
|
||||
{
|
||||
private static ArrayList<File> scripts = new ArrayList<File>();
|
||||
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<Integer, CarryOnOverride>();
|
||||
|
||||
//public static HashSet<CarryOnOverride> OVERRIDES = new HashSet<CarryOnOverride>();
|
||||
|
||||
public static void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/");
|
||||
if (!CarryOn.CONFIGURATION_FILE.exists())
|
||||
CarryOn.CONFIGURATION_FILE.mkdir();
|
||||
|
||||
for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
||||
{
|
||||
if (file.getName().endsWith(".json"))
|
||||
scripts.add(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void parseScripts() throws JsonIOException, JsonSyntaxException, FileNotFoundException, NBTException
|
||||
{
|
||||
if(!CarryOnConfig.settings.useScripts)
|
||||
return;
|
||||
|
||||
for (File file : scripts)
|
||||
{
|
||||
boolean errored = false;
|
||||
int hash = file.getAbsolutePath().hashCode();
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
||||
|
||||
JsonObject object = (JsonObject) json.get("object");
|
||||
JsonObject conditions = (JsonObject) json.get("conditions");
|
||||
JsonObject render = (JsonObject) json.get("render");
|
||||
|
||||
if ((object != null && conditions != null) || (object != null && render != null))
|
||||
{
|
||||
JsonObject block = (JsonObject) object.get("block");
|
||||
JsonObject entity = (JsonObject) object.get("entity");
|
||||
|
||||
if ((block == null && entity == null) || (block != null && entity != null))
|
||||
errored = true;
|
||||
|
||||
if (!errored)
|
||||
{
|
||||
CarryOnOverride override = new CarryOnOverride();
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
override.setBlock(true);
|
||||
JsonElement name = block.get("name");
|
||||
JsonElement meta = block.get("meta");
|
||||
JsonElement material = block.get("material");
|
||||
JsonElement hardness = block.get("hardness");
|
||||
JsonElement resistance = block.get("resistance");
|
||||
JsonObject nbt = (JsonObject) block.get("nbt");
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameBlock(name.getAsString());
|
||||
if (meta != null)
|
||||
override.setTypeMeta(meta.getAsString());
|
||||
if (material != null)
|
||||
override.setTypeMaterial(material.getAsString());
|
||||
if (hardness != null)
|
||||
override.setTypeHardness(hardness.getAsString());
|
||||
if (resistance != null)
|
||||
override.setTypeResistance(resistance.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
override.setEntity(true);
|
||||
JsonElement name = entity.get("name");
|
||||
JsonElement health = entity.get("health");
|
||||
JsonElement height = entity.get("height");
|
||||
JsonElement width = entity.get("width");
|
||||
JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||
|
||||
if (name != null)
|
||||
override.setTypeNameEntity(name.getAsString());
|
||||
if (health != null)
|
||||
override.setTypeHealth(health.getAsString());
|
||||
if (height != null)
|
||||
override.setTypeHeight(height.getAsString());
|
||||
if (width != null)
|
||||
override.setTypeWidth(width.getAsString());
|
||||
if (nbt != null)
|
||||
override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
}
|
||||
|
||||
if (conditions != null)
|
||||
{
|
||||
JsonElement achievement = conditions.get("achievement");
|
||||
JsonElement xp = conditions.get("xp");
|
||||
JsonElement gamemode = conditions.get("gamemode");
|
||||
JsonElement scoreboard = conditions.get("scoreboard");
|
||||
JsonElement position = conditions.get("position");
|
||||
|
||||
|
||||
if(achievement != null)
|
||||
override.setConditionAchievement(achievement.getAsString());
|
||||
if(xp != null)
|
||||
override.setConditionXp(xp.getAsString());
|
||||
if(gamemode != null)
|
||||
override.setConditionGamemode(gamemode.getAsString());
|
||||
if(scoreboard != null)
|
||||
override.setConditionScoreboard(scoreboard.getAsString());
|
||||
if(position != null)
|
||||
override.setConditionPosition(position.getAsString());
|
||||
}
|
||||
|
||||
if (render != null)
|
||||
{
|
||||
JsonElement name_block = render.get("name_block");
|
||||
JsonElement name_entity = render.get("name_entity");
|
||||
JsonElement meta = render.get("meta");
|
||||
JsonObject nbt = (JsonObject) render.get("nbt");
|
||||
JsonElement translation = render.get("translation");
|
||||
JsonElement rotation = render.get("rotation");
|
||||
JsonElement scale = render.get("scale");
|
||||
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||
JsonElement renderLeftArm = render.get("render_left_arm");
|
||||
JsonElement renderRightArm = render.get("render_right_arm");
|
||||
|
||||
if(name_block != null)
|
||||
override.setRenderNameBlock(name_block.getAsString());
|
||||
if(name_entity != null)
|
||||
override.setRenderNameEntity(name_entity.getAsString());
|
||||
if(meta != null)
|
||||
override.setRenderMeta(meta.getAsInt());
|
||||
if(translation != null)
|
||||
override.setRenderTranslation(translation.getAsString());
|
||||
if(rotation != null)
|
||||
override.setRenderRotation(rotation.getAsString());
|
||||
if(scale != null)
|
||||
override.setRenderScale(scale.getAsString());
|
||||
if (nbt != null)
|
||||
override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||
if(rotationLeftArm != null)
|
||||
override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||
if(rotationRightArm != null)
|
||||
override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||
if(renderLeftArm != null)
|
||||
override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||
if(renderRightArm != null)
|
||||
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||
}
|
||||
|
||||
OVERRIDES.put(override.hashCode(), override);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Successfully parsed scripts!");
|
||||
}
|
||||
|
||||
|
||||
public static void reloadScripts()
|
||||
{
|
||||
scripts.clear();
|
||||
OVERRIDES.clear();
|
||||
|
||||
for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
||||
{
|
||||
if (file.getName().endsWith(".json"))
|
||||
scripts.add(file);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
parseScripts();
|
||||
}
|
||||
catch (JsonIOException | JsonSyntaxException | FileNotFoundException | NBTException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
package tschipp.carryon.network.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class CarrySlotPacket implements IMessage
|
||||
{
|
||||
public int slot;
|
||||
public int carryOverride = 0;
|
||||
|
||||
public CarrySlotPacket()
|
||||
{
|
||||
|
|
@ -16,17 +18,30 @@ public class CarrySlotPacket implements IMessage
|
|||
{
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public CarrySlotPacket(int slot, int carryOverride)
|
||||
{
|
||||
this.slot = slot;
|
||||
this.carryOverride = carryOverride;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.slot = ByteBufUtils.readVarInt(buf, 4);
|
||||
NBTTagCompound tag = ByteBufUtils.readTag(buf);
|
||||
|
||||
this.slot = tag.getInteger("slot");
|
||||
this.carryOverride = tag.getInteger("override");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
ByteBufUtils.writeVarInt(buf, slot, 4);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("slot", slot);
|
||||
tag.setInteger("override", carryOverride);
|
||||
ByteBufUtils.writeTag(buf, tag);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||
|
||||
public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket, IMessage>
|
||||
{
|
||||
|
|
@ -24,9 +25,19 @@ public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket,
|
|||
public void run()
|
||||
{
|
||||
if (message.slot >= 9)
|
||||
{
|
||||
player.getEntityData().removeTag("carrySlot");
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getEntityData().setInteger("carrySlot", message.slot);
|
||||
if(message.carryOverride != 0)
|
||||
ScriptChecker.setCarryOnOverride(player, message.carryOverride);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"modid" : "carryon",
|
||||
"name" : "Carry On",
|
||||
"version" : "1.5.1", "mcversion" : "1.10.2",
|
||||
"version" : "1.6", "mcversion" : "1.10.2",
|
||||
"url" : "",
|
||||
"credits" : "Tschipp, Purplicious_Cow, cy4n",
|
||||
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user