Added Arm rotation for scripting and increased script performance

This commit is contained in:
Tschipp 2017-10-01 17:57:08 +02:00
parent 33066df231
commit 99709703d8
12 changed files with 609 additions and 71 deletions

View File

@ -164,7 +164,7 @@ public class RenderEntityEvents
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
Minecraft.getMinecraft().getRenderManager().setRenderShadow(false); Minecraft.getMinecraft().getRenderManager().setRenderShadow(false);
CarryOnOverride carryOverride = ScriptChecker.inspectEntity(entity); CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
if (carryOverride != null) if (carryOverride != null)
{ {
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation()); double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());

View File

@ -209,7 +209,7 @@ public class RenderEvents
{ {
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(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.inspectBlock(state, world, player.getPosition(), tag); CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
if (carryOverride != null) if (carryOverride != null)
{ {
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation()); double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
@ -448,16 +448,41 @@ public class RenderEvents
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
{ {
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; for (int k = 0; k < model.bipedBody.childModels.size(); k++)
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
{ {
model.bipedBody.childModels.remove(k); double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
k = k - 1; 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;
}
} }
} }
} }
@ -492,44 +517,169 @@ public class RenderEvents
this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F + 0.25F); this.fakeRightArmwear.addBox(model.bipedRightArm.offsetX - 7.2F, model.bipedRightArm.offsetY, model.bipedRightArm.offsetZ, 3, 12, 4, .08F + 0.25F);
} }
if (item == RegistrationHandler.itemTile) CarryOnOverride override = ScriptChecker.getOverride(player);
if (override != null)
{ {
if (!player.isSneaking()) 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 (rotLeft != null)
{ {
this.fakeRightArm.rotateAngleX = -.9001F; if (!player.isSneaking())
this.fakeLeftArm.rotateAngleX = -.9001F; {
this.fakeLeftArmwear.rotateAngleX = -.9001F; this.fakeLeftArm.rotateAngleX = (float) rotLeft[0];
this.fakeRightArmwear.rotateAngleX = -.9001F; 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 else
{ {
this.fakeRightArm.rotateAngleX = -1.4001F; if (item == RegistrationHandler.itemTile)
this.fakeLeftArm.rotateAngleX = -1.4001F; {
this.fakeLeftArmwear.rotateAngleX = -1.4001F; if (!player.isSneaking())
this.fakeRightArmwear.rotateAngleX = -1.4001F; {
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 else
{ {
if (!player.isSneaking()) if (item == RegistrationHandler.itemTile)
{ {
this.fakeRightArm.rotateAngleX = -1.2001F; if (!player.isSneaking())
this.fakeLeftArm.rotateAngleX = -1.2001F; {
this.fakeLeftArmwear.rotateAngleX = -1.2001F; this.fakeRightArm.rotateAngleX = -.9001F;
this.fakeRightArmwear.rotateAngleX = -1.2001F; 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 else
{ {
this.fakeRightArm.rotateAngleX = -1.7001F; if (!player.isSneaking())
this.fakeLeftArm.rotateAngleX = -1.7001F; {
this.fakeLeftArmwear.rotateAngleX = -1.7001F; this.fakeRightArm.rotateAngleX = -1.2001F;
this.fakeRightArmwear.rotateAngleX = -1.7001F; 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;
} }
this.fakeRightArm.rotateAngleY = -0.15f; this.fakeRightArm.rotateAngleZ = 0F;
this.fakeLeftArm.rotateAngleY = 0.15f; this.fakeLeftArm.rotateAngleZ = 0F;
this.fakeLeftArmwear.rotateAngleY = 0.15f; this.fakeLeftArmwear.rotateAngleZ = 0F;
this.fakeRightArmwear.rotateAngleY = -0.15f; this.fakeRightArmwear.rotateAngleZ = 0F;
} }
model.bipedBody.addChild(this.fakeLeftArm); model.bipedBody.addChild(this.fakeLeftArm);
@ -551,16 +701,41 @@ public class RenderEvents
model.bipedLeftArmwear.isHidden = false; model.bipedLeftArmwear.isHidden = false;
model.bipedRightArmwear.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; for (int k = 0; k < model.bipedBody.childModels.size(); k++)
if (chkRot == -0.9001F || chkRot == -1.2001F || chkRot == -1.4001F || chkRot == -1.7001F)
{ {
model.bipedBody.childModels.remove(k); double[] rotLeft1 = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
k = k - 1; 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;
}
} }
} }
} }

View File

@ -136,11 +136,6 @@ public class CommandCarryOn extends CommandBase implements ICommand
} }
} }
} }
else if (args[0].toLowerCase().equals("reload"))
{
ScriptReader.reloadScripts();
sender.sendMessage(new TextComponentString("Successfully reloaded Scripts!"));
}
else else
{ {
throw new WrongUsageException(this.getUsage(sender)); throw new WrongUsageException(this.getUsage(sender));

View File

@ -25,6 +25,8 @@ import tschipp.carryon.client.keybinds.CarryOnKeybinds;
import tschipp.carryon.common.handler.PickupHandler; import tschipp.carryon.common.handler.PickupHandler;
import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.handler.RegistrationHandler;
import tschipp.carryon.common.item.ItemEntity; import tschipp.carryon.common.item.ItemEntity;
import tschipp.carryon.common.scripting.CarryOnOverride;
import tschipp.carryon.common.scripting.ScriptChecker;
import tschipp.carryon.network.client.CarrySlotPacket; import tschipp.carryon.network.client.CarrySlotPacket;
public class ItemEntityEvents public class ItemEntityEvents
@ -97,7 +99,13 @@ public class ItemEntityEvents
handler.extractItem(i, 64, false); 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(); entity.setDead();
player.setHeldItem(EnumHand.MAIN_HAND, stack); player.setHeldItem(EnumHand.MAIN_HAND, stack);
event.setCanceled(true); event.setCanceled(true);

View File

@ -29,6 +29,8 @@ import tschipp.carryon.common.handler.ListHandler;
import tschipp.carryon.common.handler.PickupHandler; import tschipp.carryon.common.handler.PickupHandler;
import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.handler.RegistrationHandler;
import tschipp.carryon.common.item.ItemTile; import tschipp.carryon.common.item.ItemTile;
import tschipp.carryon.common.scripting.CarryOnOverride;
import tschipp.carryon.common.scripting.ScriptChecker;
import tschipp.carryon.network.client.CarrySlotPacket; import tschipp.carryon.network.client.CarrySlotPacket;
public class ItemEvents public class ItemEvents
@ -114,10 +116,14 @@ public class ItemEvents
IBlockState statee = world.getBlockState(pos); IBlockState statee = world.getBlockState(pos);
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).writeToNBT(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 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.removeTileEntity(pos);
world.setBlockToAir(pos); world.setBlockToAir(pos);
player.setHeldItem(EnumHand.MAIN_HAND, stack); player.setHeldItem(EnumHand.MAIN_HAND, stack);

View File

@ -110,6 +110,7 @@ public class ItemEntity extends Item
clearEntityData(stack); clearEntityData(stack);
player.setHeldItem(hand, ItemStack.EMPTY); player.setHeldItem(hand, ItemStack.EMPTY);
} }
player.getEntityData().removeTag("overrideKey");
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
} }

View File

@ -141,6 +141,7 @@ public class ItemTile extends Item
clearTileData(stack); clearTileData(stack);
player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f); player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f);
player.setHeldItem(hand, ItemStack.EMPTY); player.setHeldItem(hand, ItemStack.EMPTY);
player.getEntityData().removeTag("overrideKey");
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }

View File

@ -4,7 +4,7 @@ import net.minecraft.nbt.NBTTagCompound;
public class CarryOnOverride public class CarryOnOverride
{ {
//BLOCKS // BLOCKS
private NBTTagCompound typeBlockTag; private NBTTagCompound typeBlockTag;
private String typeMeta; private String typeMeta;
private String typeNameBlock; private String typeNameBlock;
@ -12,14 +12,14 @@ public class CarryOnOverride
private String typeHardness; private String typeHardness;
private String typeResistance; private String typeResistance;
//ENTITIES // ENTITIES
private NBTTagCompound typeEntityTag; private NBTTagCompound typeEntityTag;
private String typeNameEntity; private String typeNameEntity;
private String typeHeight; private String typeHeight;
private String typeWidth; private String typeWidth;
private String typeHealth; private String typeHealth;
//CONDITIONS // CONDITIONS
private String conditionGamestage; private String conditionGamestage;
private String conditionAchievement; private String conditionAchievement;
private String conditionXp; private String conditionXp;
@ -27,7 +27,7 @@ public class CarryOnOverride
private String conditionScoreboard; private String conditionScoreboard;
private String conditionPosition; private String conditionPosition;
//RENDER // RENDER
private String renderNameBlock; private String renderNameBlock;
private String renderNameEntity; private String renderNameEntity;
private int renderMeta; private int renderMeta;
@ -35,225 +35,520 @@ public class CarryOnOverride
private String renderTranslation; private String renderTranslation;
private String renderRotation; private String renderRotation;
private String renderScale; private String renderScale;
private String renderRotationLeftArm;
private String renderRotationRightArm;
private boolean isBlock; private boolean isBlock;
private boolean isEntity; private boolean isEntity;
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;
}
@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 + 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() public boolean isBlock()
{ {
return isBlock; return isBlock;
} }
public void setBlock(boolean isBlock) public void setBlock(boolean isBlock)
{ {
this.isBlock = isBlock; this.isBlock = isBlock;
} }
public boolean isEntity() public boolean isEntity()
{ {
return isEntity; return isEntity;
} }
public void setEntity(boolean isEntity) public void setEntity(boolean isEntity)
{ {
this.isEntity = isEntity; this.isEntity = isEntity;
} }
public NBTTagCompound getTypeBlockTag() public NBTTagCompound getTypeBlockTag()
{ {
return typeBlockTag; return typeBlockTag;
} }
public String getTypeMeta() public String getTypeMeta()
{ {
return typeMeta; return typeMeta;
} }
public String getTypeNameBlock() public String getTypeNameBlock()
{ {
return typeNameBlock; return typeNameBlock;
} }
public String getTypeMaterial() public String getTypeMaterial()
{ {
return typeMaterial; return typeMaterial;
} }
public String getTypeHardness() public String getTypeHardness()
{ {
return typeHardness; return typeHardness;
} }
public String getTypeResistance() public String getTypeResistance()
{ {
return typeResistance; return typeResistance;
} }
public NBTTagCompound getTypeEntityTag() public NBTTagCompound getTypeEntityTag()
{ {
return typeEntityTag; return typeEntityTag;
} }
public String getTypeNameEntity() public String getTypeNameEntity()
{ {
return typeNameEntity; return typeNameEntity;
} }
public String getTypeHeight() public String getTypeHeight()
{ {
return typeHeight; return typeHeight;
} }
public String getTypeWidth() public String getTypeWidth()
{ {
return typeWidth; return typeWidth;
} }
public String getTypeHealth() public String getTypeHealth()
{ {
return typeHealth; return typeHealth;
} }
public String getConditionGamestage() public String getConditionGamestage()
{ {
return conditionGamestage; return conditionGamestage;
} }
public String getConditionAchievement() public String getConditionAchievement()
{ {
return conditionAchievement; return conditionAchievement;
} }
public String getConditionXp() public String getConditionXp()
{ {
return conditionXp; return conditionXp;
} }
public String getConditionGamemode() public String getConditionGamemode()
{ {
return conditionGamemode; return conditionGamemode;
} }
public String getConditionScoreboard() public String getConditionScoreboard()
{ {
return conditionScoreboard; return conditionScoreboard;
} }
public String getConditionPosition() public String getConditionPosition()
{ {
return conditionPosition; return conditionPosition;
} }
public String getRenderNameBlock() public String getRenderNameBlock()
{ {
return renderNameBlock; return renderNameBlock;
} }
public String getRenderNameEntity() public String getRenderNameEntity()
{ {
return renderNameEntity; return renderNameEntity;
} }
public int getRenderMeta() public int getRenderMeta()
{ {
return renderMeta; return renderMeta;
} }
public NBTTagCompound getRenderNBT() public NBTTagCompound getRenderNBT()
{ {
return renderNBT; return renderNBT;
} }
public String getRenderTranslation() public String getRenderTranslation()
{ {
return renderTranslation; return renderTranslation;
} }
public String getRenderRotation() public String getRenderRotation()
{ {
return renderRotation; return renderRotation;
} }
public String getRenderScale() public String getRenderScale()
{ {
return renderScale; return renderScale;
} }
public void setTypeBlockTag(NBTTagCompound typeBlockTag) public void setTypeBlockTag(NBTTagCompound typeBlockTag)
{ {
this.typeBlockTag = typeBlockTag; this.typeBlockTag = typeBlockTag;
} }
public void setTypeMeta(String typeMeta) public void setTypeMeta(String typeMeta)
{ {
this.typeMeta = typeMeta; this.typeMeta = typeMeta;
} }
public void setTypeNameBlock(String typeNameBlock) public void setTypeNameBlock(String typeNameBlock)
{ {
this.typeNameBlock = typeNameBlock; this.typeNameBlock = typeNameBlock;
} }
public void setTypeMaterial(String typeMaterial) public void setTypeMaterial(String typeMaterial)
{ {
this.typeMaterial = typeMaterial; this.typeMaterial = typeMaterial;
} }
public void setTypeHardness(String typeHardness) public void setTypeHardness(String typeHardness)
{ {
this.typeHardness = typeHardness; this.typeHardness = typeHardness;
} }
public void setTypeResistance(String typeResistance) public void setTypeResistance(String typeResistance)
{ {
this.typeResistance = typeResistance; this.typeResistance = typeResistance;
} }
public void setTypeEntityTag(NBTTagCompound typeEntityTag) public void setTypeEntityTag(NBTTagCompound typeEntityTag)
{ {
this.typeEntityTag = typeEntityTag; this.typeEntityTag = typeEntityTag;
} }
public void setTypeNameEntity(String typeNameEntity) public void setTypeNameEntity(String typeNameEntity)
{ {
this.typeNameEntity = typeNameEntity; this.typeNameEntity = typeNameEntity;
} }
public void setTypeHeight(String typeHeight) public void setTypeHeight(String typeHeight)
{ {
this.typeHeight = typeHeight; this.typeHeight = typeHeight;
} }
public void setTypeWidth(String typeWidth) public void setTypeWidth(String typeWidth)
{ {
this.typeWidth = typeWidth; this.typeWidth = typeWidth;
} }
public void setTypeHealth(String typeHealth) public void setTypeHealth(String typeHealth)
{ {
this.typeHealth = typeHealth; this.typeHealth = typeHealth;
} }
public void setConditionGamestage(String conditionGamestage) public void setConditionGamestage(String conditionGamestage)
{ {
this.conditionGamestage = conditionGamestage; this.conditionGamestage = conditionGamestage;
} }
public void setConditionAchievement(String conditionAchievement) public void setConditionAchievement(String conditionAchievement)
{ {
this.conditionAchievement = conditionAchievement; this.conditionAchievement = conditionAchievement;
} }
public void setConditionXp(String conditionXp) public void setConditionXp(String conditionXp)
{ {
this.conditionXp = conditionXp; this.conditionXp = conditionXp;
} }
public void setConditionGamemode(String conditionGamemode) public void setConditionGamemode(String conditionGamemode)
{ {
this.conditionGamemode = conditionGamemode; this.conditionGamemode = conditionGamemode;
} }
public void setConditionScoreboard(String conditionScoreboard) public void setConditionScoreboard(String conditionScoreboard)
{ {
this.conditionScoreboard = conditionScoreboard; this.conditionScoreboard = conditionScoreboard;
} }
public void setConditionPosition(String conditionPosition) public void setConditionPosition(String conditionPosition)
{ {
this.conditionPosition = conditionPosition; this.conditionPosition = conditionPosition;
} }
public void setRenderNameBlock(String renderNameBlock) public void setRenderNameBlock(String renderNameBlock)
{ {
this.renderNameBlock = renderNameBlock; this.renderNameBlock = renderNameBlock;
} }
public void setRenderNameEntity(String renderNameEntity) public void setRenderNameEntity(String renderNameEntity)
{ {
this.renderNameEntity = renderNameEntity; this.renderNameEntity = renderNameEntity;
} }
public void setRenderMeta(int renderMeta) public void setRenderMeta(int renderMeta)
{ {
this.renderMeta = renderMeta; this.renderMeta = renderMeta;
} }
public void setRenderNBT(NBTTagCompound renderNBT) public void setRenderNBT(NBTTagCompound renderNBT)
{ {
this.renderNBT = renderNBT; this.renderNBT = renderNBT;
} }
public void setRenderTranslation(String renderTranslation) public void setRenderTranslation(String renderTranslation)
{ {
this.renderTranslation = renderTranslation; this.renderTranslation = renderTranslation;
} }
public void setRenderRotation(String renderRotation) public void setRenderRotation(String renderRotation)
{ {
this.renderRotation = renderRotation; this.renderRotation = renderRotation;
} }
public void setRenderScale(String renderScale) public void setRenderScale(String renderScale)
{ {
this.renderScale = renderScale; this.renderScale = renderScale;
} }
} }

View File

@ -33,7 +33,7 @@ public class ScriptChecker
float resistance = block.getExplosionResistance(null); float resistance = block.getExplosionResistance(null);
NBTTagCompound nbt = tag; NBTTagCompound nbt = tag;
for (CarryOnOverride override : ScriptReader.OVERRIDES) for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
{ {
if (override.isBlock()) if (override.isBlock())
{ {
@ -58,7 +58,7 @@ public class ScriptChecker
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBT(tag); entity.writeToNBT(tag);
for (CarryOnOverride override : ScriptReader.OVERRIDES) for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
{ {
if (override.isEntity()) if (override.isEntity())
{ {
@ -104,4 +104,28 @@ public class ScriptChecker
return (achievement && gamemode && gamestage && position && xp && scoreboard); return (achievement && gamemode && gamestage && 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);
}
} }

View File

@ -15,7 +15,6 @@ import com.google.gson.JsonSyntaxException;
import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import tschipp.carryon.CarryOn; import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig; import tschipp.carryon.common.config.CarryOnConfig;
@ -23,8 +22,9 @@ import tschipp.carryon.common.config.CarryOnConfig;
public class ScriptReader public class ScriptReader
{ {
private static ArrayList<File> scripts = new ArrayList<File>(); 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 HashSet<CarryOnOverride> OVERRIDES = new HashSet<CarryOnOverride>();
public static void preInit(FMLPreInitializationEvent event) public static void preInit(FMLPreInitializationEvent event)
{ {
@ -145,6 +145,8 @@ public class ScriptReader
JsonElement translation = render.get("translation"); JsonElement translation = render.get("translation");
JsonElement rotation = render.get("rotation"); JsonElement rotation = render.get("rotation");
JsonElement scale = render.get("scale"); JsonElement scale = render.get("scale");
JsonElement rotationLeftArm = render.get("rotation_left_arm");
JsonElement rotationRightArm = render.get("rotation_right_arm");
if(name_block != null) if(name_block != null)
override.setRenderNameBlock(name_block.getAsString()); override.setRenderNameBlock(name_block.getAsString());
@ -160,9 +162,14 @@ public class ScriptReader
override.setRenderScale(scale.getAsString()); override.setRenderScale(scale.getAsString());
if (nbt != null) if (nbt != null)
override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString())); override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
if(rotationLeftArm != null)
override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
if(rotationRightArm != null)
override.setRenderRotationRightArm(rotationRightArm.getAsString());
} }
OVERRIDES.add(override); OVERRIDES.put(override.hashCode(), override);
} }
} }

View File

@ -1,12 +1,14 @@
package tschipp.carryon.network.client; package tschipp.carryon.network.client;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
public class CarrySlotPacket implements IMessage public class CarrySlotPacket implements IMessage
{ {
public int slot; public int slot;
public int carryOverride = 0;
public CarrySlotPacket() public CarrySlotPacket()
{ {
@ -17,16 +19,29 @@ public class CarrySlotPacket implements IMessage
this.slot = slot; this.slot = slot;
} }
public CarrySlotPacket(int slot, int carryOverride)
{
this.slot = slot;
this.carryOverride = carryOverride;
}
@Override @Override
public void fromBytes(ByteBuf buf) 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 @Override
public void toBytes(ByteBuf buf) 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);
} }
} }

View File

@ -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.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import tschipp.carryon.client.keybinds.CarryOnKeybinds; import tschipp.carryon.client.keybinds.CarryOnKeybinds;
import tschipp.carryon.common.scripting.ScriptChecker;
public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket, IMessage> public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket, IMessage>
{ {
@ -24,9 +25,19 @@ public class CarrySlotPacketHandler implements IMessageHandler<CarrySlotPacket,
public void run() public void run()
{ {
if (message.slot >= 9) if (message.slot >= 9)
{
player.getEntityData().removeTag("carrySlot"); player.getEntityData().removeTag("carrySlot");
player.getEntityData().removeTag("overrideKey");
}
else else
{
player.getEntityData().setInteger("carrySlot", message.slot); player.getEntityData().setInteger("carrySlot", message.slot);
if(message.carryOverride != 0)
ScriptChecker.setCarryOnOverride(player, message.carryOverride);
}
} }
}); });