cleaned up some code
This commit is contained in:
parent
3a8d938136
commit
ff15f45ea0
|
|
@ -66,10 +66,10 @@ public class CarryOn
|
||||||
|
|
||||||
// CLIENT PACKETS
|
// CLIENT PACKETS
|
||||||
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
CarryOn.network.registerMessage(1, ScriptReloadPacket.class, ScriptReloadPacket::toBytes, ScriptReloadPacket::new, ScriptReloadPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
|
|
||||||
// SERVER PACKETS
|
// SERVER PACKETS
|
||||||
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||||
|
|
||||||
RegistrationHandler.regCommonEvents();
|
RegistrationHandler.regCommonEvents();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Lighting;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
|
|
@ -40,7 +38,7 @@ public class RenderEntityEvents
|
||||||
public static Entity getEntity(ItemStack carried, Level world)
|
public static Entity getEntity(ItemStack carried, Level world)
|
||||||
{
|
{
|
||||||
String nbt = ItemCarryonEntity.getPersistentData(carried).toString();
|
String nbt = ItemCarryonEntity.getPersistentData(carried).toString();
|
||||||
if(nbtEntityMap.containsKey(nbt))
|
if (nbtEntityMap.containsKey(nbt))
|
||||||
{
|
{
|
||||||
return nbtEntityMap.get(nbt);
|
return nbtEntityMap.get(nbt);
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +56,6 @@ public class RenderEntityEvents
|
||||||
nbtEntityMap.clear();
|
nbtEntityMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Renders the Entity in First Person
|
* Renders the Entity in First Person
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,7 +75,7 @@ public class RenderEntityEvents
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
if(ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
if (ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Entity entity = getEntity(stack, world);
|
Entity entity = getEntity(stack, world);
|
||||||
|
|
@ -100,11 +97,11 @@ public class RenderEntityEvents
|
||||||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
matrix.translate(0.0, -height - .1, width + 0.1);
|
matrix.translate(0.0, -height - .1, width + 0.1);
|
||||||
|
|
||||||
// RenderSystem.enableAlphaTest();
|
// RenderSystem.enableAlphaTest();
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
// Lighting.en
|
// Lighting.en
|
||||||
manager.setRenderShadow(false);
|
manager.setRenderShadow(false);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
|
|
@ -118,7 +115,7 @@ public class RenderEntityEvents
|
||||||
Entity newEntity = null;
|
Entity newEntity = null;
|
||||||
|
|
||||||
Optional<EntityType<?>> type = EntityType.byString(entityname);
|
Optional<EntityType<?>> type = EntityType.byString(entityname);
|
||||||
if(type.isPresent())
|
if (type.isPresent())
|
||||||
newEntity = type.get().create(world);
|
newEntity = type.get().create(world);
|
||||||
|
|
||||||
if (newEntity != null)
|
if (newEntity != null)
|
||||||
|
|
@ -135,19 +132,19 @@ public class RenderEntityEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
((LivingEntity) entity).hurtTime = 0;
|
||||||
|
|
||||||
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||||
manager.setRenderShadow(true);
|
manager.setRenderShadow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderSystem.disableAlphaTest();
|
// RenderSystem.disableAlphaTest();
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
|
||||||
// Lighting.turnOff();
|
// Lighting.turnOff();
|
||||||
// TODO
|
// TODO
|
||||||
// RenderSystem.disableRescaleNormal();
|
// RenderSystem.disableRescaleNormal();
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package tschipp.carryon.client.event;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Lighting;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
|
@ -164,7 +163,7 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||||
|
|
||||||
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))))
|
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().player.closeContainer();
|
Minecraft.getInstance().player.closeContainer();
|
||||||
Minecraft.getInstance().screen = null;
|
Minecraft.getInstance().screen = null;
|
||||||
|
|
@ -193,7 +192,7 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
ItemStack stack = Minecraft.getInstance().player.getMainHandItem();
|
ItemStack stack = Minecraft.getInstance().player.getMainHandItem();
|
||||||
|
|
||||||
if (!stack.isEmpty() && ((stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack)) || (stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))))
|
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
||||||
{
|
{
|
||||||
if (settings.keyDrop.matches(key, scancode))
|
if (settings.keyDrop.matches(key, scancode))
|
||||||
{
|
{
|
||||||
|
|
@ -268,7 +267,7 @@ public class RenderEvents
|
||||||
matrix.mulPose(Vector3f.XP.rotationDegrees(8));
|
matrix.mulPose(Vector3f.XP.rotationDegrees(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileStack, world, player, 0));
|
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : tileStack.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileStack, world, player, 0);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
|
|
@ -333,7 +332,7 @@ public class RenderEvents
|
||||||
if (perspective == 0 && player == Minecraft.getInstance().player)
|
if (perspective == 0 && player == Minecraft.getInstance().player)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
light = Minecraft.getInstance().getEntityRenderDispatcher().getPackedLightCoords(player, partialticks);
|
light = manager.getPackedLightCoords(player, partialticks);
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||||
|
|
@ -345,7 +344,7 @@ public class RenderEvents
|
||||||
|
|
||||||
applyBlockTransformations(player, partialticks, matrix, block);
|
applyBlockTransformations(player, partialticks, matrix, block);
|
||||||
|
|
||||||
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player, 0));
|
BakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : tileItem.isEmpty() ? Minecraft.getInstance().getBlockRenderer().getBlockModel(state) : Minecraft.getInstance().getItemRenderer().getModel(tileItem, world, player, 0);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
|
|
@ -365,7 +364,7 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||||
//TODO: Fix block light
|
// TODO: Fix block light
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
|
|
||||||
PoseStack.Pose p = matrix.last();
|
PoseStack.Pose p = matrix.last();
|
||||||
|
|
@ -420,8 +419,8 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity le)
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
le.hurtTime = 0;
|
||||||
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
|
@ -492,7 +491,7 @@ public class RenderEvents
|
||||||
|
|
||||||
if (pose == Pose.FALL_FLYING)
|
if (pose == Pose.FALL_FLYING)
|
||||||
{
|
{
|
||||||
float f1 = (float) player.getFallFlyingTicks() + partialticks;
|
float f1 = player.getFallFlyingTicks() + partialticks;
|
||||||
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
||||||
if (!player.isAutoSpinAttack())
|
if (!player.isAutoSpinAttack())
|
||||||
{
|
{
|
||||||
|
|
@ -537,11 +536,8 @@ public class RenderEvents
|
||||||
matrix.translate(0, 0, -0.4);
|
matrix.translate(0, 0, -0.4);
|
||||||
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
}
|
}
|
||||||
else
|
else if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
||||||
{
|
matrix.translate(0, 0, 0.4);
|
||||||
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
|
||||||
matrix.translate(0, 0, 0.4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyEntityTransformations(Player player, float partialticks, PoseStack matrix, Entity entity)
|
private void applyEntityTransformations(Player player, float partialticks, PoseStack matrix, Entity entity)
|
||||||
|
|
@ -592,10 +588,7 @@ public class RenderEvents
|
||||||
int perspective = CarryRenderHelper.getPerspective();
|
int perspective = CarryRenderHelper.getPerspective();
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
if (!Settings.renderArms.get())
|
if (!Settings.renderArms.get() || pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||||
return;
|
|
||||||
|
|
||||||
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||||
|
|
@ -631,32 +624,32 @@ public class RenderEvents
|
||||||
|
|
||||||
if (renderLeft && rotLeft != null)
|
if (renderLeft && rotLeft != null)
|
||||||
{
|
{
|
||||||
renderArmPost(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftArm, rotLeft[0], rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftSleeve, rotLeft[0], rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
else if (renderLeft)
|
else if (renderLeft)
|
||||||
{
|
{
|
||||||
renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderRight && rotRight != null)
|
if (renderRight && rotRight != null)
|
||||||
{
|
{
|
||||||
renderArmPost(model.rightArm, (float) rotRight[0], (float) rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightArm, rotRight[0], rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightSleeve, rotRight[0], rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
else if (renderRight)
|
else if (renderRight)
|
||||||
{
|
{
|
||||||
renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.leftSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0, false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
renderArmPost(model.rightSleeve, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0, true, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer instanceof BufferSource)
|
if (buffer instanceof BufferSource)
|
||||||
|
|
@ -731,9 +724,9 @@ public class RenderEvents
|
||||||
else
|
else
|
||||||
arm.y = 15;
|
arm.y = 15;
|
||||||
|
|
||||||
arm.xRot = (float) x;
|
arm.xRot = x;
|
||||||
arm.yRot = (float) 0;
|
arm.yRot = 0;
|
||||||
arm.zRot = (float) -z;
|
arm.zRot = -z;
|
||||||
arm.render(matrix, builder, light, 655360);
|
arm.render(matrix, builder, light, 655360);
|
||||||
arm.y = 2;
|
arm.y = 2;
|
||||||
matrix.popPose();
|
matrix.popPose();
|
||||||
|
|
@ -766,7 +759,7 @@ public class RenderEvents
|
||||||
if (player.getAbilities().flying)
|
if (player.getAbilities().flying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (player.isShiftKeyDown() || player.isCrouching());
|
return player.isShiftKeyDown() || player.isCrouching();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChest(Block block)
|
public static boolean isChest(Block block)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class CarryRenderHelper
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public static int getPerspective()
|
public static int getPerspective()
|
||||||
{
|
{
|
||||||
boolean isThirdPerson = !Minecraft.getInstance().options.getCameraType().isFirstPerson(); //isThirdPerson
|
boolean isThirdPerson = !Minecraft.getInstance().options.getCameraType().isFirstPerson(); // isThirdPerson
|
||||||
boolean isThirdPersonReverse = Minecraft.getInstance().options.getCameraType().isMirrored();
|
boolean isThirdPersonReverse = Minecraft.getInstance().options.getCameraType().isMirrored();
|
||||||
|
|
||||||
if (!isThirdPerson && !isThirdPersonReverse)
|
if (!isThirdPerson && !isThirdPersonReverse)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class CarryOnKeybinds
|
||||||
public static boolean isKeyPressed(Player player)
|
public static boolean isKeyPressed(Player player)
|
||||||
{
|
{
|
||||||
CompoundTag tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
if(tag != null && tag.contains(KEYBIND_KEY))
|
if (tag != null && tag.contains(KEYBIND_KEY))
|
||||||
{
|
{
|
||||||
return tag.getBoolean(KEYBIND_KEY);
|
return tag.getBoolean(KEYBIND_KEY);
|
||||||
}
|
}
|
||||||
|
|
@ -37,6 +37,4 @@ public class CarryOnKeybinds
|
||||||
tag.putBoolean(KEYBIND_KEY, pressed);
|
tag.putBoolean(KEYBIND_KEY, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ package tschipp.carryon.common.capabilities;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public interface IPosition {
|
public interface IPosition
|
||||||
|
{
|
||||||
|
|
||||||
public BlockPos getPos();
|
public BlockPos getPos();
|
||||||
|
|
||||||
|
|
@ -12,5 +13,4 @@ public interface IPosition {
|
||||||
|
|
||||||
public void setBlockActivated(boolean b);
|
public void setBlockActivated(boolean b);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,14 @@ public class PositionProvider implements ICapabilitySerializable<CompoundTag>
|
||||||
@CapabilityInject(IPosition.class)
|
@CapabilityInject(IPosition.class)
|
||||||
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
public static final Capability<IPosition> POSITION_CAPABILITY = null;
|
||||||
|
|
||||||
private IPosition instance = new TEPosition();//POSITION_CAPABILITY.getDefaultInstance();
|
private IPosition instance = new TEPosition();// POSITION_CAPABILITY.getDefaultInstance();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||||
{
|
{
|
||||||
if (cap == POSITION_CAPABILITY)
|
if (cap == POSITION_CAPABILITY)
|
||||||
return (LazyOptional<T>) LazyOptional.of(() -> {
|
return (LazyOptional<T>) LazyOptional.of(TEPosition::new);
|
||||||
return new TEPosition();
|
|
||||||
});
|
|
||||||
|
|
||||||
return LazyOptional.empty();
|
return LazyOptional.empty();
|
||||||
}
|
}
|
||||||
|
|
@ -33,10 +31,10 @@ public class PositionProvider implements ICapabilitySerializable<CompoundTag>
|
||||||
{
|
{
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
|
|
||||||
tag.putBoolean("blockActivated", instance.isBlockActivated());
|
tag.putBoolean("blockActivated", this.instance.isBlockActivated());
|
||||||
tag.putInt("x", instance.getPos().getX());
|
tag.putInt("x", this.instance.getPos().getX());
|
||||||
tag.putInt("y", instance.getPos().getY());
|
tag.putInt("y", this.instance.getPos().getY());
|
||||||
tag.putInt("z", instance.getPos().getZ());
|
tag.putInt("z", this.instance.getPos().getZ());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
@ -44,16 +42,16 @@ public class PositionProvider implements ICapabilitySerializable<CompoundTag>
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt)
|
public void deserializeNBT(CompoundTag nbt)
|
||||||
{
|
{
|
||||||
CompoundTag tag = (CompoundTag) nbt;
|
CompoundTag tag = nbt;
|
||||||
|
|
||||||
int x = tag.getInt("x");
|
int x = tag.getInt("x");
|
||||||
int y = tag.getInt("y");
|
int y = tag.getInt("y");
|
||||||
int z = tag.getInt("z");
|
int z = tag.getInt("z");
|
||||||
|
|
||||||
BlockPos pos = new BlockPos(x,y,z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
|
||||||
instance.setPos(pos);
|
this.instance.setPos(pos);
|
||||||
instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
this.instance.setBlockActivated(tag.getBoolean("blockActivated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ package tschipp.carryon.common.capabilities;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public class TEPosition implements IPosition {
|
public class TEPosition implements IPosition
|
||||||
|
{
|
||||||
|
|
||||||
private BlockPos pos = new BlockPos(0, 0, 0);
|
private BlockPos pos = new BlockPos(0, 0, 0);
|
||||||
private boolean blockActivated = false;
|
private boolean blockActivated = false;
|
||||||
|
|
@ -10,23 +11,25 @@ public class TEPosition implements IPosition {
|
||||||
@Override
|
@Override
|
||||||
public BlockPos getPos()
|
public BlockPos getPos()
|
||||||
{
|
{
|
||||||
return pos;
|
return this.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPos(BlockPos pos)
|
public void setPos(BlockPos pos)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBlockActivated()
|
public boolean isBlockActivated()
|
||||||
{
|
{
|
||||||
return blockActivated;
|
return this.blockActivated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockActivated(boolean b)
|
public void setBlockActivated(boolean b)
|
||||||
{
|
{
|
||||||
this.blockActivated = b;
|
this.blockActivated = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,26 +29,23 @@ public class PositionClientEvents
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
boolean inventory = event.getGui() instanceof AbstractContainerScreen;
|
||||||
|
|
||||||
if (player != null && inventory)
|
if (player != null && inventory && player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
|
if (cap.isBlockActivated())
|
||||||
{
|
{
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
Level world = player.level;
|
||||||
if(cap.isBlockActivated())
|
BlockPos pos = cap.getPos();
|
||||||
|
if (world != null)
|
||||||
{
|
{
|
||||||
Level world = player.level;
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
BlockPos pos = cap.getPos();
|
if (te == null)
|
||||||
if(world != null)
|
|
||||||
{
|
{
|
||||||
BlockEntity te = world.getBlockEntity(pos);
|
// player.openContainer = null;
|
||||||
if(te == null)
|
Minecraft.getInstance().screen = null;
|
||||||
{
|
// Minecraft.getInstance().fo;
|
||||||
// player.openContainer = null;
|
cap.setBlockActivated(false);
|
||||||
Minecraft.getInstance().screen = null;
|
cap.setPos(new BlockPos(0, 0, 0));
|
||||||
// Minecraft.getInstance().fo;
|
|
||||||
cap.setBlockActivated(false);
|
|
||||||
cap.setPos(new BlockPos(0,0,0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -61,15 +58,14 @@ public class PositionClientEvents
|
||||||
public void onGuiClose(PlayerContainerEvent.Close event)
|
public void onGuiClose(PlayerContainerEvent.Close event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
if (player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
cap.setBlockActivated(false);
|
cap.setBlockActivated(false);
|
||||||
cap.setPos(new BlockPos(0,0,0));
|
cap.setPos(new BlockPos(0, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerTick(PlayerTickEvent event)
|
public void onPlayerTick(PlayerTickEvent event)
|
||||||
|
|
@ -77,7 +73,7 @@ public class PositionClientEvents
|
||||||
if (event.side == LogicalSide.CLIENT)
|
if (event.side == LogicalSide.CLIENT)
|
||||||
{
|
{
|
||||||
Player player = event.player;
|
Player player = event.player;
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
if (player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
if (cap.isBlockActivated() && Minecraft.getInstance().screen == null)
|
if (cap.isBlockActivated() && Minecraft.getInstance().screen == null)
|
||||||
|
|
@ -89,5 +85,4 @@ public class PositionClientEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,27 +35,16 @@ public class PositionCommonEvents
|
||||||
Level world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (event.isCanceled())
|
if (event.isCanceled() || player == null || player instanceof FakePlayer)
|
||||||
return;
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player instanceof FakePlayer)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if (te != null)
|
if (te != null && player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
||||||
{
|
{
|
||||||
if(player.getCapability(PositionProvider.POSITION_CAPABILITY).isPresent())
|
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
||||||
{
|
cap.setBlockActivated(true);
|
||||||
IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY).orElse(new TEPosition());
|
cap.setPos(pos);
|
||||||
cap.setBlockActivated(true);
|
|
||||||
cap.setPos(pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,11 @@ public class CommandCarryOn
|
||||||
{
|
{
|
||||||
LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("carryon")
|
LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("carryon")
|
||||||
|
|
||||||
.then(Commands.literal("debug").executes((cmd) -> {
|
.then(Commands.literal("debug").executes(cmd -> handleDebug(cmd.getSource())))
|
||||||
return handleDebug(cmd.getSource());
|
|
||||||
}))
|
|
||||||
|
|
||||||
.then(Commands.literal("clear").executes((cmd) -> {
|
.then(Commands.literal("clear").executes(cmd -> handleClear(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
|
||||||
return handleClear(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()));
|
|
||||||
}))
|
|
||||||
|
|
||||||
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes((cmd) -> {
|
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
|
||||||
return handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target"));
|
|
||||||
})))
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -100,7 +94,6 @@ public class CommandCarryOn
|
||||||
}
|
}
|
||||||
catch (CommandSyntaxException e)
|
catch (CommandSyntaxException e)
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -114,7 +107,7 @@ public class CommandCarryOn
|
||||||
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO
|
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile, 64, player.inventoryMenu.getCraftSlots()); // TODO
|
||||||
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.inventoryMenu.getCraftSlots());
|
cleared += player.getInventory().clearOrCountMatchingItems(stack -> !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity, 64, player.inventoryMenu.getCraftSlots());
|
||||||
|
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(9, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> player), new CarrySlotPacket(9, player.getId()));
|
||||||
|
|
||||||
if (cleared != 1)
|
if (cleared != 1)
|
||||||
source.sendSuccess(new TextComponent("Cleared " + cleared + " Items!"), true);
|
source.sendSuccess(new TextComponent("Cleared " + cleared + " Items!"), true);
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,4 @@ public class CarryOnConfig
|
||||||
|
|
||||||
public static Configs.CustomPickupConditions customPickupConditions = new Configs.CustomPickupConditions();
|
public static Configs.CustomPickupConditions customPickupConditions = new Configs.CustomPickupConditions();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
import tschipp.carryon.common.handler.ListHandler;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD)
|
@Mod.EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.MOD)
|
||||||
public class Configs {
|
public class Configs
|
||||||
|
{
|
||||||
|
|
||||||
private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
|
private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
|
||||||
private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder();
|
private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder();
|
||||||
|
|
@ -27,7 +28,8 @@ public class Configs {
|
||||||
public static final ForgeConfigSpec SERVER_CONFIG;
|
public static final ForgeConfigSpec SERVER_CONFIG;
|
||||||
public static final ForgeConfigSpec CLIENT_CONFIG;
|
public static final ForgeConfigSpec CLIENT_CONFIG;
|
||||||
|
|
||||||
static {
|
static
|
||||||
|
{
|
||||||
|
|
||||||
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
Settings.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||||
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
Blacklist.init(SERVER_BUILDER, CLIENT_BUILDER);
|
||||||
|
|
@ -48,7 +50,7 @@ public class Configs {
|
||||||
|
|
||||||
CommentedConfig cfg = event.getConfig().getConfigData();
|
CommentedConfig cfg = event.getConfig().getConfigData();
|
||||||
|
|
||||||
if(cfg instanceof CommentedFileConfig)
|
if (cfg instanceof CommentedFileConfig)
|
||||||
((CommentedFileConfig) cfg).load();
|
((CommentedFileConfig) cfg).load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,12 +64,11 @@ public class Configs {
|
||||||
|
|
||||||
CommentedConfig cfg = event.getConfig().getConfigData();
|
CommentedConfig cfg = event.getConfig().getConfigData();
|
||||||
|
|
||||||
if(cfg instanceof CommentedFileConfig)
|
if (cfg instanceof CommentedFileConfig)
|
||||||
((CommentedFileConfig) cfg).load();
|
((CommentedFileConfig) cfg).load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class Settings
|
public static class Settings
|
||||||
{
|
{
|
||||||
public static BooleanValue facePlayer;
|
public static BooleanValue facePlayer;
|
||||||
|
|
@ -122,98 +123,51 @@ public class Configs {
|
||||||
s.push("settings");
|
s.push("settings");
|
||||||
c.push("settings");
|
c.push("settings");
|
||||||
|
|
||||||
maxDistance = s
|
maxDistance = s.comment("Maximum distance from where Blocks and Entities can be picked up").defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE);
|
||||||
.comment("Maximum distance from where Blocks and Entities can be picked up")
|
|
||||||
.defineInRange("maxDistance", 2.5, 0, Double.MAX_VALUE);
|
|
||||||
|
|
||||||
maxEntityWidth = s
|
maxEntityWidth = s.comment("Max width of entities that can be picked up in survival mode").defineInRange("maxEntityWidth", 1.5, 0, 10);
|
||||||
.comment("Max width of entities that can be picked up in survival mode")
|
|
||||||
.defineInRange("maxEntityWidth", 1.5, 0, 10);
|
|
||||||
|
|
||||||
maxEntityHeight = s
|
maxEntityHeight = s.comment("Max height of entities that can be picked up in survival mode").defineInRange("maxEntityHeight", 1.5, 0, 10);
|
||||||
.comment("Max height of entities that can be picked up in survival mode")
|
|
||||||
.defineInRange("maxEntityHeight", 1.5, 0, 10);
|
|
||||||
|
|
||||||
maxEntityWidth = s
|
maxEntityWidth = s.comment("Max width of entities that can be picked up in survival mode").defineInRange("maxEntityWidth", 1.5, 0, 10);
|
||||||
.comment("Max width of entities that can be picked up in survival mode")
|
|
||||||
.defineInRange("maxEntityWidth", 1.5, 0, 10);
|
|
||||||
|
|
||||||
blockSlownessMultiplier = s
|
blockSlownessMultiplier = s.comment("Slowness multiplier for blocks").defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
||||||
.comment("Slowness multiplier for blocks")
|
|
||||||
.defineInRange("blockSlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
|
||||||
|
|
||||||
entitySlownessMultiplier = s
|
entitySlownessMultiplier = s.comment("Slowness multiplier for entities").defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
||||||
.comment("Slowness multiplier for entities")
|
|
||||||
.defineInRange("entitySlownessMultiplier", 1, 0, Double.MAX_VALUE);
|
|
||||||
|
|
||||||
maxEntityStackLimit = s
|
maxEntityStackLimit = s.comment("Maximum stack limit for entities").defineInRange("maxEntityStackLimit", 10, 1, Integer.MAX_VALUE);
|
||||||
.comment("Maximum stack limit for entities")
|
|
||||||
.defineInRange("maxEntityStackLimit", 10, 1, Integer.MAX_VALUE);
|
|
||||||
|
|
||||||
facePlayer = c
|
facePlayer = c.comment("If the front of the Tile Entities should face the player or should face outward").define("facePlayer", false);
|
||||||
.comment("If the front of the Tile Entities should face the player or should face outward")
|
|
||||||
.define("facePlayer", false);
|
|
||||||
|
|
||||||
heavyTiles = s
|
heavyTiles = s.comment("More complex Tile Entities slow down the player more").define("heavyTiles", true);
|
||||||
.comment("More complex Tile Entities slow down the player more")
|
|
||||||
.define("heavyTiles", true);
|
|
||||||
|
|
||||||
pickupAllBlocks = s
|
pickupAllBlocks = s.comment("Allow all blocks to be picked up, not just Tile Entites").define("pickupAllBlocks", false);
|
||||||
.comment("Allow all blocks to be picked up, not just Tile Entites")
|
|
||||||
.define("pickupAllBlocks", false);
|
|
||||||
|
|
||||||
slownessInCreative = s
|
slownessInCreative = s.comment("Whether Blocks and Entities slow the creative player down when carried").define("slownessInCreative", true);
|
||||||
.comment("Whether Blocks and Entities slow the creative player down when carried")
|
|
||||||
.define("slownessInCreative", true);
|
|
||||||
|
|
||||||
pickupHostileMobs = s
|
pickupHostileMobs = s.comment("Whether hostile mobs should be able to picked up in survival mode").define("pickupHostileMobs", false);
|
||||||
.comment("Whether hostile mobs should be able to picked up in survival mode")
|
|
||||||
.define("pickupHostileMobs", false);
|
|
||||||
|
|
||||||
heavyEntities = s
|
heavyEntities = s.comment("Larger Entities slow down the player more").define("heavyEntities", true);
|
||||||
.comment("Larger Entities slow down the player more")
|
|
||||||
.define("heavyEntities", true);
|
|
||||||
|
|
||||||
renderArms = c
|
renderArms = c.comment("Arms should render on sides when carrying").define("renderArms", true);
|
||||||
.comment("Arms should render on sides when carrying")
|
|
||||||
.define("renderArms", true);
|
|
||||||
|
|
||||||
allowBabies = s
|
allowBabies = s.comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)").define("allowBabies", false);
|
||||||
.comment("Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)")
|
|
||||||
.define("allowBabies", false);
|
|
||||||
|
|
||||||
useWhitelistBlocks = s
|
useWhitelistBlocks = s.comment("Use Whitelist instead of Blacklist for Blocks").define("useWhitelistBlocks", false);
|
||||||
.comment("Use Whitelist instead of Blacklist for Blocks")
|
|
||||||
.define("useWhitelistBlocks", false);
|
|
||||||
|
|
||||||
useWhitelistEntities = s
|
useWhitelistEntities = s.comment("Use Whitelist instead of Blacklist for Entities").define("useWhitelistEntities", false);
|
||||||
.comment("Use Whitelist instead of Blacklist for Entities")
|
|
||||||
.define("useWhitelistEntities", false);
|
|
||||||
|
|
||||||
useWhitelistStacking = s
|
useWhitelistStacking = s.comment("Use Whitelist instead of Blacklist for Stacking").define("useWhitelistStacking", false);
|
||||||
.comment("Use Whitelist instead of Blacklist for Stacking")
|
|
||||||
.define("useWhitelistStacking", false);
|
|
||||||
|
|
||||||
hitWhileCarrying = s
|
hitWhileCarrying = s.comment("Whether the player can hit blocks and entities while carrying or not").define("hitWhileCarrying", false);
|
||||||
.comment("Whether the player can hit blocks and entities while carrying or not")
|
|
||||||
.define("hitWhileCarrying", false);
|
|
||||||
|
|
||||||
dropCarriedWhenHit = s
|
dropCarriedWhenHit = s.comment("Whether the player drops the carried object when hit or not").define("dropCarriedWhenHit", false);
|
||||||
.comment("Whether the player drops the carried object when hit or not")
|
|
||||||
.define("dropCarriedWhenHit", false);
|
|
||||||
|
|
||||||
useScripts = s
|
useScripts = s.comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance").worldRestart().define("useScripts", false);
|
||||||
.comment("Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance")
|
|
||||||
.worldRestart()
|
|
||||||
.define("useScripts", false);
|
|
||||||
|
|
||||||
stackableEntities = s
|
stackableEntities = s.comment("Allows entities to be stacked using Carry On").define("stackableEntities", true);
|
||||||
.comment("Allows entities to be stacked using Carry On")
|
|
||||||
.define("stackableEntities", true);
|
|
||||||
|
|
||||||
entitySizeMattersStacking = s
|
entitySizeMattersStacking = s.comment("Whether entities' size matters when stacking or not").define("stackableEntities", true);
|
||||||
.comment("Whether entities' size matters when stacking or not")
|
|
||||||
.define("stackableEntities", true);
|
|
||||||
|
|
||||||
s.pop();
|
s.pop();
|
||||||
c.pop();
|
c.pop();
|
||||||
|
|
@ -234,17 +188,11 @@ public class Configs {
|
||||||
{
|
{
|
||||||
s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
s.comment("Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
||||||
|
|
||||||
allowedEntities = s
|
allowedEntities = s.comment("Entities that CAN be picked up (useWhitelistEntities must be true)").defineList("whitelist.allowedEntities", Arrays.asList(), obj -> obj instanceof String ? true : false);
|
||||||
.comment("Entities that CAN be picked up (useWhitelistEntities must be true)")
|
|
||||||
.defineList("whitelist.allowedEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
|
|
||||||
allowedBlocks = s
|
allowedBlocks = s.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)").defineList("whitelist.allowedBlocks", Arrays.asList(), obj -> obj instanceof String ? true : false);
|
||||||
.comment("Blocks that CAN be picked up (useWhitelistBlocks must be true)")
|
|
||||||
.defineList("whitelist.allowedBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
|
|
||||||
allowedStacking = s
|
allowedStacking = s.comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)").defineList("whitelist.allowedStacking", Arrays.asList(), obj -> obj instanceof String ? true : false);
|
||||||
.comment("Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)")
|
|
||||||
.defineList("whitelist.allowedStacking", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,135 +208,11 @@ public class Configs {
|
||||||
{
|
{
|
||||||
s.comment("Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
s.comment("Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config");
|
||||||
|
|
||||||
forbiddenTiles = s
|
forbiddenTiles = s.comment("Blocks that cannot be picked up").defineList("blacklist.forbiddenTiles", Arrays.asList("#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony", "minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed", "minecraft:oak_door", "minecraft:iron_door", "minecraft:spruce_door", "minecraft:birch_door", "minecraft:jungle_door", "minecraft:acacia_door", "minecraft:dark_oak_door", "minecraft:waterlily", "minecraft:cake", "minecraft:nether_portal", "minecraft:tall_seagrass", "animania:block_trough", "animania:block_invisiblock", "colossalchests:*", "ic2:*", "bigreactors:*", "forestry:*", "tconstruct:*", "rustic:*", "botania:*", "astralsorcery:*", "quark:colored_bed_*", "immersiveengineering:*", "embers:block_furnace", "embers:ember_bore", "embers:ember_activator", "embers:mixer", "embers:heat_coil", "embers:large_tank", "embers:crystal_cell", "embers:alchemy_pedestal", "embers:boiler", "embers:combustor", "embers:catalzyer", "embers:field_chart", "embers:inferno_forge", "storagedrawers:framingtable", "skyresources:*", "lootbags:*", "exsartagine:*", "aquamunda:tank", "opencomputers:*", "malisisdoors:*", "industrialforegoing:*", "minecolonies:*", "thaumcraft:pillar*", "thaumcraft:infernal_furnace", "thaumcraft:placeholder*", "thaumcraft:infusion_matrix", "thaumcraft:golem_builder", "thaumcraft:thaumatorium*", "magneticraft:oil_heater", "magneticraft:solar_panel", "magneticraft:steam_engine", "magneticraft:shelving_unit", "magneticraft:grinder", "magneticraft:sieve", "magneticraft:solar_tower", "magneticraft:solar_mirror", "magneticraft:container", "magneticraft:pumpjack", "magneticraft:solar_panel", "magneticraft:refinery", "magneticraft:oil_heater", "magneticraft:hydraulic_press", "magneticraft:multiblock_gap", "refinedstorage:*", "mcmultipart:*", "enderstorage:*", "betterstorage:*", "practicallogistics2:*", "wearablebackpacks:*", "rftools:screen", "rftools:creative_screen", "create:*", "magic_doorknob:*", "iceandfire:*", "ftbquests:*", "waystones:*"), obj -> obj instanceof String);
|
||||||
.comment("Blocks that cannot be picked up")
|
|
||||||
.defineList("blacklist.forbiddenTiles", Arrays.asList(new String[]
|
|
||||||
{
|
|
||||||
"#forge:immovable",
|
|
||||||
"#forge:relocation_not_supported",
|
|
||||||
"minecraft:end_portal",
|
|
||||||
"minecraft:end_gateway",
|
|
||||||
"minecraft:tall_grass",
|
|
||||||
"minecraft:large_fern",
|
|
||||||
"minecraft:peony",
|
|
||||||
"minecraft:rose_bush",
|
|
||||||
"minecraft:lilac",
|
|
||||||
"minecraft:sunflower",
|
|
||||||
"minecraft:*_bed",
|
|
||||||
"minecraft:oak_door",
|
|
||||||
"minecraft:iron_door",
|
|
||||||
"minecraft:spruce_door",
|
|
||||||
"minecraft:birch_door",
|
|
||||||
"minecraft:jungle_door",
|
|
||||||
"minecraft:acacia_door",
|
|
||||||
"minecraft:dark_oak_door",
|
|
||||||
"minecraft:waterlily",
|
|
||||||
"minecraft:cake",
|
|
||||||
"minecraft:nether_portal",
|
|
||||||
"minecraft:tall_seagrass",
|
|
||||||
"animania:block_trough",
|
|
||||||
"animania:block_invisiblock",
|
|
||||||
"colossalchests:*",
|
|
||||||
"ic2:*",
|
|
||||||
"bigreactors:*",
|
|
||||||
"forestry:*",
|
|
||||||
"tconstruct:*",
|
|
||||||
"rustic:*",
|
|
||||||
"botania:*",
|
|
||||||
"astralsorcery:*",
|
|
||||||
"quark:colored_bed_*",
|
|
||||||
"immersiveengineering:*",
|
|
||||||
"embers:block_furnace",
|
|
||||||
"embers:ember_bore",
|
|
||||||
"embers:ember_activator",
|
|
||||||
"embers:mixer",
|
|
||||||
"embers:heat_coil",
|
|
||||||
"embers:large_tank",
|
|
||||||
"embers:crystal_cell",
|
|
||||||
"embers:alchemy_pedestal",
|
|
||||||
"embers:boiler",
|
|
||||||
"embers:combustor",
|
|
||||||
"embers:catalzyer",
|
|
||||||
"embers:field_chart",
|
|
||||||
"embers:inferno_forge",
|
|
||||||
"storagedrawers:framingtable",
|
|
||||||
"skyresources:*",
|
|
||||||
"lootbags:*",
|
|
||||||
"exsartagine:*",
|
|
||||||
"aquamunda:tank",
|
|
||||||
"opencomputers:*",
|
|
||||||
"malisisdoors:*",
|
|
||||||
"industrialforegoing:*",
|
|
||||||
"minecolonies:*",
|
|
||||||
"thaumcraft:pillar*",
|
|
||||||
"thaumcraft:infernal_furnace",
|
|
||||||
"thaumcraft:placeholder*",
|
|
||||||
"thaumcraft:infusion_matrix",
|
|
||||||
"thaumcraft:golem_builder",
|
|
||||||
"thaumcraft:thaumatorium*",
|
|
||||||
"magneticraft:oil_heater",
|
|
||||||
"magneticraft:solar_panel",
|
|
||||||
"magneticraft:steam_engine",
|
|
||||||
"magneticraft:shelving_unit",
|
|
||||||
"magneticraft:grinder",
|
|
||||||
"magneticraft:sieve",
|
|
||||||
"magneticraft:solar_tower",
|
|
||||||
"magneticraft:solar_mirror",
|
|
||||||
"magneticraft:container",
|
|
||||||
"magneticraft:pumpjack",
|
|
||||||
"magneticraft:solar_panel",
|
|
||||||
"magneticraft:refinery",
|
|
||||||
"magneticraft:oil_heater",
|
|
||||||
"magneticraft:hydraulic_press",
|
|
||||||
"magneticraft:multiblock_gap",
|
|
||||||
"refinedstorage:*",
|
|
||||||
"mcmultipart:*",
|
|
||||||
"enderstorage:*",
|
|
||||||
"betterstorage:*",
|
|
||||||
"practicallogistics2:*",
|
|
||||||
"wearablebackpacks:*",
|
|
||||||
"rftools:screen",
|
|
||||||
"rftools:creative_screen",
|
|
||||||
"create:*",
|
|
||||||
"magic_doorknob:*",
|
|
||||||
"iceandfire:*",
|
|
||||||
"ftbquests:*",
|
|
||||||
"waystones:*"
|
|
||||||
|
|
||||||
|
forbiddenEntities = s.comment("Entities that cannot be picked up").defineList("blacklist.forbiddenEntities", Arrays.asList("minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand", "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*"), obj -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
}), (obj) -> obj instanceof String);
|
forbiddenStacking = s.comment("Entities that cannot have other entities stacked on top of them").defineList("blacklist.forbiddenStacking", Arrays.asList("minecraft:horse"), obj -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
forbiddenEntities = s
|
|
||||||
.comment("Entities that cannot be picked up")
|
|
||||||
.defineList("blacklist.forbiddenEntities", Arrays.asList(new String[]
|
|
||||||
{
|
|
||||||
"minecraft:end_crystal",
|
|
||||||
"minecraft:ender_dragon",
|
|
||||||
"minecraft:ghast",
|
|
||||||
"minecraft:shulker",
|
|
||||||
"minecraft:leash_knot",
|
|
||||||
"minecraft:armor_stand",
|
|
||||||
"minecraft:item_frame",
|
|
||||||
"minecraft:painting",
|
|
||||||
"minecraft:shulker_bullet",
|
|
||||||
"animania:hamster",
|
|
||||||
"animania:ferret*",
|
|
||||||
"animania:hedgehog*",
|
|
||||||
"animania:cart",
|
|
||||||
"animania:wagon",
|
|
||||||
"mynko:*",
|
|
||||||
"pixelmon:*",
|
|
||||||
"mocreatures:*",
|
|
||||||
"quark:totem",
|
|
||||||
"vehicle:*"
|
|
||||||
}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
|
|
||||||
forbiddenStacking = s
|
|
||||||
.comment("Entities that cannot have other entities stacked on top of them")
|
|
||||||
.defineList("blacklist.forbiddenStacking", Arrays.asList(new String[]
|
|
||||||
{
|
|
||||||
"minecraft:horse"
|
|
||||||
}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -401,37 +225,10 @@ public class Configs {
|
||||||
{
|
{
|
||||||
c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config");
|
c.comment("Model Overrides. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config");
|
||||||
|
|
||||||
|
modelOverrides = c.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!").defineList("modeloverrides.overrides", Arrays.asList("minecraft:hopper->(block)minecraft:hopper", "minecraft:comparator->(block)minecraft:comparator", "minecraft:repeater->(block)minecraft:repeater", "minecraft:cauldron->(block)minecraft:cauldron", "minecraft:brewing_stand->(item)minecraft:brewing_stand", "minecraft:flower_pot->(block)minecraft:flower_pot", "minecraft:sugar_cane->(block)minecraft:sugar_cane", "minecraft:redstone_wire->(item)minecraft:redstone", "animania:block_nest->(block)animania:block_nest", "animania:cheese_mold;0->(block)animania:cheese_mold;0", "animania:cheese_mold;1->(block)animania:cheese_mold;1", "animania:cheese_mold;2->(block)animania:cheese_mold;2", "animania:cheese_mold;3->(block)animania:cheese_mold;3", "animania:cheese_mold;4->(block)animania:cheese_mold;4", "animania:cheese_mold;5->(block)animania:cheese_mold;5", "animania:cheese_mold;6->(block)animania:cheese_mold;6", "animania:cheese_mold;7->(block)animania:cheese_mold;7", "animania:cheese_mold;8->(block)animania:cheese_mold;8", "animania:cheese_mold;9->(block)animania:cheese_mold;9", "animania:cheese_mold;10->(block)animania:cheese_mold;10"), obj -> obj instanceof String ? true : false);
|
||||||
modelOverrides = c
|
|
||||||
.comment("Model Overrides based on NBT or on Meta. Advanced Users Only!")
|
|
||||||
.defineList("modeloverrides.overrides", Arrays.asList(new String[]
|
|
||||||
{
|
|
||||||
"minecraft:hopper->(block)minecraft:hopper",
|
|
||||||
"minecraft:comparator->(block)minecraft:comparator",
|
|
||||||
"minecraft:repeater->(block)minecraft:repeater",
|
|
||||||
"minecraft:cauldron->(block)minecraft:cauldron",
|
|
||||||
"minecraft:brewing_stand->(item)minecraft:brewing_stand",
|
|
||||||
"minecraft:flower_pot->(block)minecraft:flower_pot",
|
|
||||||
"minecraft:sugar_cane->(block)minecraft:sugar_cane",
|
|
||||||
"minecraft:redstone_wire->(item)minecraft:redstone",
|
|
||||||
"animania:block_nest->(block)animania:block_nest",
|
|
||||||
"animania:cheese_mold;0->(block)animania:cheese_mold;0",
|
|
||||||
"animania:cheese_mold;1->(block)animania:cheese_mold;1",
|
|
||||||
"animania:cheese_mold;2->(block)animania:cheese_mold;2",
|
|
||||||
"animania:cheese_mold;3->(block)animania:cheese_mold;3",
|
|
||||||
"animania:cheese_mold;4->(block)animania:cheese_mold;4",
|
|
||||||
"animania:cheese_mold;5->(block)animania:cheese_mold;5",
|
|
||||||
"animania:cheese_mold;6->(block)animania:cheese_mold;6",
|
|
||||||
"animania:cheese_mold;7->(block)animania:cheese_mold;7",
|
|
||||||
"animania:cheese_mold;8->(block)animania:cheese_mold;8",
|
|
||||||
"animania:cheese_mold;9->(block)animania:cheese_mold;9",
|
|
||||||
"animania:cheese_mold;10->(block)animania:cheese_mold;10",
|
|
||||||
}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class CustomPickupConditions
|
public static class CustomPickupConditions
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -443,14 +240,9 @@ public class Configs {
|
||||||
{
|
{
|
||||||
s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config");
|
s.comment("Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config");
|
||||||
|
|
||||||
|
customPickupConditionsBlocks = s.comment("Custom Pickup Conditions for Blocks").defineList("custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(), obj -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
customPickupConditionsBlocks = s
|
customPickupConditionsEntities = s.comment("Custom Pickup Conditions for Entities").defineList("custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(), obj -> obj instanceof String ? true : false);
|
||||||
.comment("Custom Pickup Conditions for Blocks")
|
|
||||||
.defineList("custom_pickup_conditions.customPickupConditionsBlocks", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
|
|
||||||
customPickupConditionsEntities = s
|
|
||||||
.comment("Custom Pickup Conditions for Entities")
|
|
||||||
.defineList("custom_pickup_conditions.customPickupConditionsEntities", Arrays.asList(new String[]{}), (obj) -> obj instanceof String ? true : false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,14 @@ public class IMCEvents
|
||||||
{
|
{
|
||||||
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
Stream<IMCMessage> messages = InterModComms.getMessages(CarryOn.MODID);
|
||||||
|
|
||||||
messages.forEach((msg) -> {
|
messages.forEach(msg -> {
|
||||||
|
|
||||||
String method = msg.method();
|
String method = msg.method();
|
||||||
Object obj = msg.messageSupplier().get();
|
Object obj = msg.messageSupplier().get();
|
||||||
|
|
||||||
if(!(obj instanceof String))
|
if (!(obj instanceof String str))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String str = (String)obj;
|
|
||||||
|
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
case "blacklistBlock":
|
case "blacklistBlock":
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,8 @@ public class ItemEntityEvents
|
||||||
{
|
{
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
Level world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
if (e instanceof net.minecraft.world.entity.item.ItemEntity)
|
if (e instanceof net.minecraft.world.entity.item.ItemEntity eitem)
|
||||||
{
|
{
|
||||||
net.minecraft.world.entity.item.ItemEntity eitem = (net.minecraft.world.entity.item.ItemEntity) e;
|
|
||||||
ItemStack stack = eitem.getItem();
|
ItemStack stack = eitem.getItem();
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (item == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
|
|
@ -109,40 +108,38 @@ public class ItemEntityEvents
|
||||||
if (entity instanceof Animal)
|
if (entity instanceof Animal)
|
||||||
((Animal) entity).dropLeash(true, true);
|
((Animal) entity).dropLeash(true, true);
|
||||||
|
|
||||||
if (PickupHandler.canPlayerPickUpEntity((ServerPlayer) player, entity))
|
if (PickupHandler.canPlayerPickUpEntity((ServerPlayer) player, entity) && ItemCarryonEntity.storeEntityData(entity, world, stack))
|
||||||
{
|
{
|
||||||
if (ItemCarryonEntity.storeEntityData(entity, world, stack))
|
LazyOptional<IItemHandler> handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||||
{
|
|
||||||
LazyOptional<IItemHandler> handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
|
||||||
|
|
||||||
handler.ifPresent((hand) -> {
|
handler.ifPresent(hand -> {
|
||||||
for (int i = 0; i < hand.getSlots(); i++)
|
for (int i = 0; i < hand.getSlots(); i++)
|
||||||
{
|
{
|
||||||
hand.extractItem(i, 64, false);
|
hand.extractItem(i, 64, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
||||||
int overrideHash = 0;
|
int overrideHash = 0;
|
||||||
if (override != null)
|
if (override != null)
|
||||||
overrideHash = override.hashCode();
|
overrideHash = override.hashCode();
|
||||||
|
|
||||||
ItemEvents.sendPacket(player, player.getInventory().selected, overrideHash);
|
ItemEvents.sendPacket(player, player.getInventory().selected, overrideHash);
|
||||||
|
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).setHealth(0);
|
((LivingEntity) entity).setHealth(0);
|
||||||
|
|
||||||
entity.ejectPassengers();
|
entity.ejectPassengers();
|
||||||
entity.setPos(entity.getX(), 0, entity.getZ());
|
entity.setPos(entity.getX(), 0, entity.getZ());
|
||||||
entity.discard();
|
entity.discard();
|
||||||
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
event.setCancellationResult(InteractionResult.FAIL);
|
event.setCancellationResult(InteractionResult.FAIL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && Settings.stackableEntities.get())
|
}
|
||||||
|
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(main) && !CarryOnKeybinds.isKeyPressed(player) && Settings.stackableEntities.get())
|
||||||
{
|
{
|
||||||
Entity entityHeld = ItemCarryonEntity.getEntity(main, world);
|
Entity entityHeld = ItemCarryonEntity.getEntity(main, world);
|
||||||
|
|
||||||
|
|
@ -163,11 +160,10 @@ public class ItemEntityEvents
|
||||||
if (Settings.useWhitelistStacking.get() ? ListHandler.isStackingAllowed(topEntity) : !ListHandler.isStackingForbidden(topEntity))
|
if (Settings.useWhitelistStacking.get() ? ListHandler.isStackingAllowed(topEntity) : !ListHandler.isStackingForbidden(topEntity))
|
||||||
{
|
{
|
||||||
double sizeEntity = topEntity.getBbHeight() * topEntity.getBbWidth();
|
double sizeEntity = topEntity.getBbHeight() * topEntity.getBbWidth();
|
||||||
if ((Settings.entitySizeMattersStacking.get() && sizeHeldEntity <= sizeEntity) || !Settings.entitySizeMattersStacking.get())
|
if (Settings.entitySizeMattersStacking.get() && sizeHeldEntity <= sizeEntity || !Settings.entitySizeMattersStacking.get())
|
||||||
{
|
{
|
||||||
if (topEntity instanceof Horse)
|
if (topEntity instanceof Horse horse)
|
||||||
{
|
{
|
||||||
Horse horse = (Horse) topEntity;
|
|
||||||
horse.setTamed(true);
|
horse.setTamed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,7 +176,8 @@ public class ItemEntityEvents
|
||||||
world.addFreshEntity(entityHeld);
|
world.addFreshEntity(entityHeld);
|
||||||
entityHeld.startRiding(topEntity, false);
|
entityHeld.startRiding(topEntity, false);
|
||||||
entityHeld.teleportTo(tempX, tempY, tempZ);
|
entityHeld.teleportTo(tempX, tempY, tempZ);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
entityHeld.setPos(entity.getX(), entity.getY(), entity.getZ());
|
entityHeld.setPos(entity.getX(), entity.getY(), entity.getZ());
|
||||||
world.addFreshEntity(entityHeld);
|
world.addFreshEntity(entityHeld);
|
||||||
|
|
@ -193,16 +190,16 @@ public class ItemEntityEvents
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
event.setCancellationResult(InteractionResult.FAIL);
|
event.setCancellationResult(InteractionResult.FAIL);
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.NOTE_BLOCK_BASS, SoundSource.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,8 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
Level world = event.getWorld();
|
Level world = event.getWorld();
|
||||||
if (e instanceof net.minecraft.world.entity.item.ItemEntity)
|
if (e instanceof net.minecraft.world.entity.item.ItemEntity eitem)
|
||||||
{
|
{
|
||||||
net.minecraft.world.entity.item.ItemEntity eitem = (net.minecraft.world.entity.item.ItemEntity) e;
|
|
||||||
ItemStack stack = eitem.getItem();
|
ItemStack stack = eitem.getItem();
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
if (item == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||||
|
|
@ -134,11 +133,12 @@ public class ItemEvents
|
||||||
eitem.setItem(ItemStack.EMPTY);
|
eitem.setItem(ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockPos pos = new BlockPos(Math.floor(eitem.getPosX()), Math.floor(eitem.getPosY()), Math.floor(eitem.getPosZ()));
|
// BlockPos pos = new BlockPos(Math.floor(eitem.getPosX()),
|
||||||
// if (positions.containsKey(pos))
|
// Math.floor(eitem.getPosY()), Math.floor(eitem.getPosZ()));
|
||||||
// {
|
// if (positions.containsKey(pos))
|
||||||
// event.setCanceled(true);
|
// {
|
||||||
// }
|
// event.setCanceled(true);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
if (event.getPlayer() instanceof Player)
|
if (event.getPlayer() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Level world = player.getCommandSenderWorld();
|
Level world = player.getCommandSenderWorld();
|
||||||
|
|
||||||
ItemStack carried = player.getMainHandItem();
|
ItemStack carried = player.getMainHandItem();
|
||||||
|
|
@ -161,7 +161,8 @@ public class ItemEvents
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
|
|
@ -173,13 +174,12 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(event.getPlayer() instanceof ServerPlayer)
|
if (event.getPlayer() instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void serverLoad(RegisterCommandsEvent event)
|
public void serverLoad(RegisterCommandsEvent event)
|
||||||
{
|
{
|
||||||
|
|
@ -204,9 +204,8 @@ public class ItemEvents
|
||||||
Entity e = event.getTarget();
|
Entity e = event.getTarget();
|
||||||
Player tracker = event.getPlayer();
|
Player tracker = event.getPlayer();
|
||||||
|
|
||||||
if (e instanceof Player && tracker instanceof ServerPlayer)
|
if (e instanceof Player player && tracker instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
Player player = (Player) e;
|
|
||||||
Level world = player.getCommandSenderWorld();
|
Level world = player.getCommandSenderWorld();
|
||||||
|
|
||||||
ItemStack carried = player.getMainHandItem();
|
ItemStack carried = player.getMainHandItem();
|
||||||
|
|
@ -219,7 +218,8 @@ public class ItemEvents
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId(), override.hashCode()));
|
||||||
else
|
else
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) tracker), new CarrySlotPacket(player.getInventory().selected, player.getId()));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
CarryOnOverride override = ScriptChecker.inspectEntity(ItemCarryonEntity.getEntity(carried, world));
|
||||||
if (override != null)
|
if (override != null)
|
||||||
|
|
@ -271,19 +271,15 @@ public class ItemEvents
|
||||||
public void playerAttack(LivingAttackEvent event)
|
public void playerAttack(LivingAttackEvent event)
|
||||||
{
|
{
|
||||||
LivingEntity eliving = event.getEntityLiving();
|
LivingEntity eliving = event.getEntityLiving();
|
||||||
if (eliving instanceof Player && Settings.dropCarriedWhenHit.get())
|
if (eliving instanceof Player player && Settings.dropCarriedWhenHit.get())
|
||||||
{
|
{
|
||||||
Player player = (Player) eliving;
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity) && !player.level.isClientSide)
|
||||||
{
|
{
|
||||||
if (!player.level.isClientSide)
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
{
|
ItemEntity item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack);
|
||||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
sendPacket(player, 9, 0);
|
||||||
ItemEntity item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack);
|
player.level.addFreshEntity(item);
|
||||||
sendPacket(player, 9, 0);
|
|
||||||
player.level.addFreshEntity(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +290,7 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(event.isCanceled())
|
if (event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!player.level.isClientSide)
|
if (!player.level.isClientSide)
|
||||||
|
|
@ -315,8 +311,7 @@ public class ItemEvents
|
||||||
if (PickupHandler.canPlayerPickUpBlock((ServerPlayer) player, te, world, pos))
|
if (PickupHandler.canPlayerPickUpBlock((ServerPlayer) player, te, world, pos))
|
||||||
{
|
{
|
||||||
player.closeContainer();
|
player.closeContainer();
|
||||||
world.levelEvent(1010, pos, 0);
|
world.levelEvent(1010, pos, 0);
|
||||||
|
|
||||||
|
|
||||||
if (ItemCarryonBlock.storeTileData(te, world, pos, state, stack))
|
if (ItemCarryonBlock.storeTileData(te, world, pos, state, stack))
|
||||||
{
|
{
|
||||||
|
|
@ -342,19 +337,21 @@ public class ItemEvents
|
||||||
event.setUseItem(Result.DENY);
|
event.setUseItem(Result.DENY);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (Exception e)
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sendPacket(player, player.getInventory().selected, overrideHash);
|
sendPacket(player, player.getInventory().selected, overrideHash);
|
||||||
emptyTileEntity(te);
|
emptyTileEntity(te);
|
||||||
world.removeBlock(pos,false);
|
world.removeBlock(pos, false);
|
||||||
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
player.setItemInHand(InteractionHand.MAIN_HAND, stack);
|
||||||
event.setUseBlock(Result.DENY);
|
event.setUseBlock(Result.DENY);
|
||||||
event.setUseItem(Result.DENY);
|
event.setUseItem(Result.DENY);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
sendPacket(player, 9, 0);
|
sendPacket(player, 9, 0);
|
||||||
world.setBlockAndUpdate(pos, statee);
|
world.setBlockAndUpdate(pos, statee);
|
||||||
|
|
@ -393,7 +390,7 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||||
|
|
||||||
itemHandler.ifPresent((handler) -> {
|
itemHandler.ifPresent(handler -> {
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); i++)
|
for (int i = 0; i < handler.getSlots(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -406,7 +403,7 @@ public class ItemEvents
|
||||||
|
|
||||||
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
LazyOptional<IItemHandler> itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||||
|
|
||||||
itemHandler.ifPresent((handler) -> {
|
itemHandler.ifPresent(handler -> {
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); i++)
|
for (int i = 0; i < handler.getSlots(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -415,15 +412,13 @@ public class ItemEvents
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (te instanceof Container)
|
if (te instanceof Container inv)
|
||||||
{
|
{
|
||||||
Container inv = (Container) te;
|
|
||||||
inv.clearContent();
|
inv.clearContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (te instanceof IItemHandler)
|
if (te instanceof IItemHandler itemHandler1)
|
||||||
{
|
{
|
||||||
IItemHandler itemHandler1 = (IItemHandler) te;
|
|
||||||
for (int i = 0; i < itemHandler1.getSlots(); i++)
|
for (int i = 0; i < itemHandler1.getSlots(); i++)
|
||||||
{
|
{
|
||||||
itemHandler1.extractItem(i, 64, false);
|
itemHandler1.extractItem(i, 64, false);
|
||||||
|
|
@ -454,7 +449,7 @@ public class ItemEvents
|
||||||
ItemEntity item = new ItemEntity(world, 0, 0, 0, stack);
|
ItemEntity item = new ItemEntity(world, 0, 0, 0, stack);
|
||||||
BlockPos pos = null;
|
BlockPos pos = null;
|
||||||
Optional<BlockPos> bedpos = original.getSleepingPos();
|
Optional<BlockPos> bedpos = original.getSleepingPos();
|
||||||
if(bedpos.isPresent())
|
if (bedpos.isPresent())
|
||||||
pos = bedpos.get();
|
pos = bedpos.get();
|
||||||
if (pos == null)
|
if (pos == null)
|
||||||
pos = player.blockPosition();
|
pos = player.blockPosition();
|
||||||
|
|
@ -468,54 +463,44 @@ public class ItemEvents
|
||||||
public void dropNonHotbarItems(LivingUpdateEvent event)
|
public void dropNonHotbarItems(LivingUpdateEvent event)
|
||||||
{
|
{
|
||||||
LivingEntity entity = event.getEntityLiving();
|
LivingEntity entity = event.getEntityLiving();
|
||||||
if (entity instanceof Player)
|
if (entity instanceof Player player && !entity.level.isClientSide)
|
||||||
{
|
{
|
||||||
Player player = (Player) entity;
|
boolean hasCarried = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity));
|
||||||
|
ItemStack inHand = player.getMainHandItem();
|
||||||
|
|
||||||
if (!entity.level.isClientSide)
|
if (hasCarried && inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity && player.getDimensionChangingDelay() == 0)
|
||||||
{
|
{
|
||||||
boolean hasCarried = player.getInventory().contains(new ItemStack(RegistrationHandler.itemTile)) || player.getInventory().contains(new ItemStack(RegistrationHandler.itemEntity));
|
int slotBlock = this.getSlot(player, RegistrationHandler.itemTile);
|
||||||
ItemStack inHand = player.getMainHandItem();
|
int slotEntity = this.getSlot(player, RegistrationHandler.itemEntity);
|
||||||
|
|
||||||
if (hasCarried)
|
ItemEntity item = null;
|
||||||
|
if (slotBlock != -1)
|
||||||
{
|
{
|
||||||
if ((inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity) && player.getDimensionChangingDelay() == 0)
|
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotBlock);
|
||||||
{
|
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
||||||
int slotBlock = getSlot(player, RegistrationHandler.itemTile);
|
|
||||||
int slotEntity = getSlot(player, RegistrationHandler.itemEntity);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ItemEntity item = null;
|
|
||||||
if (slotBlock != -1)
|
|
||||||
{
|
|
||||||
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotBlock);
|
|
||||||
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
|
||||||
}
|
|
||||||
if (slotEntity != -1)
|
|
||||||
{
|
|
||||||
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotEntity);
|
|
||||||
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
|
||||||
}
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
player.level.addFreshEntity(item);
|
|
||||||
sendPacket(player, 9, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (slotEntity != -1)
|
||||||
CarryOnOverride override = ScriptChecker.getOverride(player);
|
|
||||||
|
|
||||||
if (override != null)
|
|
||||||
{
|
{
|
||||||
String command = override.getCommandLoop();
|
ItemStack dropped = player.getInventory().removeItemNoUpdate(slotEntity);
|
||||||
|
item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), dropped);
|
||||||
if (command != null)
|
}
|
||||||
player.getServer().getCommands().performCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
if (item != null)
|
||||||
|
{
|
||||||
|
player.level.addFreshEntity(item);
|
||||||
|
sendPacket(player, 9, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CarryOnOverride override = ScriptChecker.getOverride(player);
|
||||||
|
|
||||||
|
if (override != null)
|
||||||
|
{
|
||||||
|
String command = override.getCommandLoop();
|
||||||
|
|
||||||
|
if (command != null)
|
||||||
|
player.getServer().getCommands().performCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,7 +526,8 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
player.getPersistentData().remove("carrySlot");
|
player.getPersistentData().remove("carrySlot");
|
||||||
player.getPersistentData().remove("overrideKey");
|
player.getPersistentData().remove("overrideKey");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
player.getPersistentData().putInt("carrySlot", currentItem);
|
player.getPersistentData().putInt("carrySlot", currentItem);
|
||||||
if (hash != 0)
|
if (hash != 0)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ import tschipp.carryon.common.helper.InvalidConfigException;
|
||||||
public class CustomPickupOverrideHandler
|
public class CustomPickupOverrideHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public static HashMap<String, String> PICKUP_CONDITIONS = new HashMap<String, String>();
|
public static HashMap<String, String> PICKUP_CONDITIONS = new HashMap<>();
|
||||||
public static HashMap<String, String> PICKUP_CONDITIONS_ENTITIES = new HashMap<String, String>();
|
public static HashMap<String, String> PICKUP_CONDITIONS_ENTITIES = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void initPickupOverrides()
|
public static void initPickupOverrides()
|
||||||
|
|
@ -78,13 +78,12 @@ public class CustomPickupOverrideHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean hasSpecialPickupConditions(BlockState state)
|
public static boolean hasSpecialPickupConditions(BlockState state)
|
||||||
{
|
{
|
||||||
if (!ModList.get().isLoaded("gamestages"))
|
if (!ModList.get().isLoaded("gamestages"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for(String cond : PICKUP_CONDITIONS.keySet())
|
for (String cond : PICKUP_CONDITIONS.keySet())
|
||||||
{
|
{
|
||||||
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
||||||
try
|
try
|
||||||
|
|
@ -94,7 +93,7 @@ public class CustomPickupOverrideHandler
|
||||||
catch (CommandSyntaxException e)
|
catch (CommandSyntaxException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if(parser.getState() == state)
|
if (parser.getState() == state)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +102,7 @@ public class CustomPickupOverrideHandler
|
||||||
|
|
||||||
public static String getPickupCondition(BlockState state)
|
public static String getPickupCondition(BlockState state)
|
||||||
{
|
{
|
||||||
for(String cond : PICKUP_CONDITIONS.keySet())
|
for (String cond : PICKUP_CONDITIONS.keySet())
|
||||||
{
|
{
|
||||||
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
BlockStateParser parser = new BlockStateParser(new StringReader(cond), false);
|
||||||
try
|
try
|
||||||
|
|
@ -113,7 +112,7 @@ public class CustomPickupOverrideHandler
|
||||||
catch (CommandSyntaxException e)
|
catch (CommandSyntaxException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if(parser.getState() == state)
|
if (parser.getState() == state)
|
||||||
return PICKUP_CONDITIONS.get(cond);
|
return PICKUP_CONDITIONS.get(cond);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -125,17 +124,13 @@ public class CustomPickupOverrideHandler
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean condition = PICKUP_CONDITIONS_ENTITIES.containsKey(name);
|
return PICKUP_CONDITIONS_ENTITIES.containsKey(name);
|
||||||
|
|
||||||
return condition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPickupCondition(Entity entity)
|
public static String getPickupCondition(Entity entity)
|
||||||
{
|
{
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
String condition = PICKUP_CONDITIONS_ENTITIES.get(name);
|
return PICKUP_CONDITIONS_ENTITIES.get(name);
|
||||||
|
|
||||||
return condition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class ListHandler
|
||||||
public static List<String> ALLOWED_ENTITIES = new ArrayList<>();
|
public static List<String> ALLOWED_ENTITIES = new ArrayList<>();
|
||||||
public static List<String> ALLOWED_TILES = new ArrayList<>();
|
public static List<String> ALLOWED_TILES = new ArrayList<>();
|
||||||
public static List<String> FORBIDDEN_STACKING = new ArrayList<>();
|
public static List<String> FORBIDDEN_STACKING = new ArrayList<>();
|
||||||
public static List<String> ALLOWED_STACKING = new ArrayList<>();
|
public static List<String> ALLOWED_STACKING = new ArrayList<>();
|
||||||
|
|
||||||
public static List<Tag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
public static List<Tag<Block>> FORBIDDEN_TILES_TAGS = new ArrayList<>();
|
||||||
public static List<Tag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
public static List<Tag<EntityType<?>>> FORBIDDEN_ENTITIES_TAGS = new ArrayList<>();
|
||||||
|
|
@ -49,9 +49,9 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Tag<Block> tag : FORBIDDEN_TILES_TAGS)
|
for (Tag<Block> tag : FORBIDDEN_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(block))
|
if (tag.contains(block))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,9 +64,9 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
boolean contains = FORBIDDEN_ENTITIES.contains(name);
|
||||||
|
|
||||||
for(Tag<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
for (Tag<EntityType<?>> tag : FORBIDDEN_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if (tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,9 +78,9 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = ALLOWED_ENTITIES.contains(name);
|
boolean contains = ALLOWED_ENTITIES.contains(name);
|
||||||
|
|
||||||
for(Tag<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
for (Tag<EntityType<?>> tag : ALLOWED_ENTITIES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if (tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,9 +92,9 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = FORBIDDEN_STACKING.contains(name);
|
boolean contains = FORBIDDEN_STACKING.contains(name);
|
||||||
|
|
||||||
for(Tag<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
for (Tag<EntityType<?>> tag : FORBIDDEN_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if (tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,9 +106,9 @@ public class ListHandler
|
||||||
String name = entity.getType().getRegistryName().toString();
|
String name = entity.getType().getRegistryName().toString();
|
||||||
boolean contains = ALLOWED_STACKING.contains(name);
|
boolean contains = ALLOWED_STACKING.contains(name);
|
||||||
|
|
||||||
for(Tag<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
for (Tag<EntityType<?>> tag : ALLOWED_STACKING_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(entity.getType()))
|
if (tag.contains(entity.getType()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,9 +133,9 @@ public class ListHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Tag<Block> tag : ALLOWED_TILES_TAGS)
|
for (Tag<Block> tag : ALLOWED_TILES_TAGS)
|
||||||
{
|
{
|
||||||
if(tag.contains(block))
|
if (tag.contains(block))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
List<String> forbidden = new ArrayList<>(Blacklist.forbiddenTiles.get());
|
||||||
forbidden.add("#carryon:block_blacklist");
|
forbidden.add("#carryon:block_blacklist");
|
||||||
FORBIDDEN_TILES = new ArrayList<String>();
|
FORBIDDEN_TILES = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < forbidden.size(); i++)
|
for (int i = 0; i < forbidden.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -171,7 +171,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
List<String> forbiddenEntity = new ArrayList<>(Blacklist.forbiddenEntities.get());
|
||||||
forbiddenEntity.add("#carryon:entity_blacklist");
|
forbiddenEntity.add("#carryon:entity_blacklist");
|
||||||
FORBIDDEN_ENTITIES = new ArrayList<String>();
|
FORBIDDEN_ENTITIES = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < forbiddenEntity.size(); i++)
|
for (int i = 0; i < forbiddenEntity.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +196,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
List<String> allowedEntities = new ArrayList<>(WhiteList.allowedEntities.get());
|
||||||
allowedEntities.add("#carryon:entity_whitelist");
|
allowedEntities.add("#carryon:entity_whitelist");
|
||||||
ALLOWED_ENTITIES = new ArrayList<String>();
|
ALLOWED_ENTITIES = new ArrayList<>();
|
||||||
for (int i = 0; i < allowedEntities.size(); i++)
|
for (int i = 0; i < allowedEntities.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedEntities.get(i).startsWith("#"))
|
if (!allowedEntities.get(i).startsWith("#"))
|
||||||
|
|
@ -220,7 +220,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
List<String> allowedBlocks = new ArrayList<>(WhiteList.allowedBlocks.get());
|
||||||
allowedBlocks.add("#carryon:block_whitelist");
|
allowedBlocks.add("#carryon:block_whitelist");
|
||||||
ALLOWED_TILES = new ArrayList<String>();
|
ALLOWED_TILES = new ArrayList<>();
|
||||||
for (int i = 0; i < allowedBlocks.size(); i++)
|
for (int i = 0; i < allowedBlocks.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedBlocks.get(i).startsWith("#"))
|
if (!allowedBlocks.get(i).startsWith("#"))
|
||||||
|
|
@ -229,7 +229,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
List<String> forbiddenStacking = new ArrayList<>(Blacklist.forbiddenStacking.get());
|
||||||
forbiddenStacking.add("#carryon:stacking_blacklist");
|
forbiddenStacking.add("#carryon:stacking_blacklist");
|
||||||
FORBIDDEN_STACKING = new ArrayList<String>();
|
FORBIDDEN_STACKING = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < forbiddenStacking.size(); i++)
|
for (int i = 0; i < forbiddenStacking.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -254,7 +254,7 @@ public class ListHandler
|
||||||
|
|
||||||
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
List<String> allowedStacking = new ArrayList<>(WhiteList.allowedStacking.get());
|
||||||
allowedStacking.add("#carryon:stacking_whitelist");
|
allowedStacking.add("#carryon:stacking_whitelist");
|
||||||
ALLOWED_STACKING = new ArrayList<String>();
|
ALLOWED_STACKING = new ArrayList<>();
|
||||||
for (int i = 0; i < allowedStacking.size(); i++)
|
for (int i = 0; i < allowedStacking.size(); i++)
|
||||||
{
|
{
|
||||||
if (!allowedStacking.get(i).startsWith("#"))
|
if (!allowedStacking.get(i).startsWith("#"))
|
||||||
|
|
@ -285,7 +285,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
String sub = s.substring(1, s.length());
|
String sub = s.substring(1);
|
||||||
Tag<Block> tag = blocktags.getTag(new ResourceLocation(sub));
|
Tag<Block> tag = blocktags.getTag(new ResourceLocation(sub));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_TILES_TAGS.add(tag);
|
FORBIDDEN_TILES_TAGS.add(tag);
|
||||||
|
|
@ -296,7 +296,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
Tag<Block> tag = blocktags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<Block> tag = blocktags.getTag(new ResourceLocation(s.substring(1)));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_TILES_TAGS.add(tag);
|
ALLOWED_TILES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +306,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1)));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
FORBIDDEN_ENTITIES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +316,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1)));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_ENTITIES_TAGS.add(tag);
|
ALLOWED_ENTITIES_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +326,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1)));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
FORBIDDEN_STACKING_TAGS.add(tag);
|
FORBIDDEN_STACKING_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ public class ListHandler
|
||||||
{
|
{
|
||||||
if (s.startsWith("#"))
|
if (s.startsWith("#"))
|
||||||
{
|
{
|
||||||
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1, s.length())));
|
Tag<EntityType<?>> tag = entitytags.getTag(new ResourceLocation(s.substring(1)));
|
||||||
if (tag != null)
|
if (tag != null)
|
||||||
ALLOWED_STACKING_TAGS.add(tag);
|
ALLOWED_STACKING_TAGS.add(tag);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import tschipp.carryon.common.helper.StringParser;
|
||||||
|
|
||||||
public class ModelOverridesHandler
|
public class ModelOverridesHandler
|
||||||
{
|
{
|
||||||
public static HashMap<CompoundTag, Object> OVERRIDE_OBJECTS = new HashMap<CompoundTag, Object>();
|
public static HashMap<CompoundTag, Object> OVERRIDE_OBJECTS = new HashMap<>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class is really ugly, will probably be replaced by something else -
|
* This class is really ugly, will probably be replaced by something else -
|
||||||
|
|
@ -94,7 +94,7 @@ public class ModelOverridesHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
overridetype = override.substring(0, override.indexOf(")") + 1);
|
overridetype = override.substring(0, override.indexOf(")") + 1);
|
||||||
override =override.replace(overridetype, "");
|
override = override.replace(overridetype, "");
|
||||||
overridetype = overridetype.replace("(", "");
|
overridetype = overridetype.replace("(", "");
|
||||||
overridetype = overridetype.replace(")", "");
|
overridetype = overridetype.replace(")", "");
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class ModelOverridesHandler
|
||||||
|
|
||||||
if ((ModList.get().isLoaded(modidOverride) || modidOverride.equals("minecraft")) && (ModList.get().isLoaded(modidToOverride) || modidToOverride.equals("minecraft")) && !errored)
|
if ((ModList.get().isLoaded(modidOverride) || modidOverride.equals("minecraft")) && (ModList.get().isLoaded(modidToOverride) || modidToOverride.equals("minecraft")) && !errored)
|
||||||
{
|
{
|
||||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||||
|
|
||||||
if (toOverrideObject != null)
|
if (toOverrideObject != null)
|
||||||
{
|
{
|
||||||
|
|
@ -144,7 +144,6 @@ public class ModelOverridesHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void initOverrides()
|
public static void initOverrides()
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
@ -259,8 +258,7 @@ public class ModelOverridesHandler
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
Object override = OVERRIDE_OBJECTS.get(key);
|
return OVERRIDE_OBJECTS.get(key);
|
||||||
return override;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,9 @@ public class PickupHandler
|
||||||
|
|
||||||
public static boolean canPlayerPickUpBlock(ServerPlayer player, @Nullable BlockEntity tile, Level world, BlockPos pos)
|
public static boolean canPlayerPickUpBlock(ServerPlayer player, @Nullable BlockEntity tile, Level world, BlockPos pos)
|
||||||
{
|
{
|
||||||
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
if (player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
|
|
@ -43,7 +42,7 @@ public class PickupHandler
|
||||||
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
CarryOnOverride override = ScriptChecker.inspectBlock(world.getBlockState(pos), world, pos, tag);
|
||||||
if (override != null)
|
if (override != null)
|
||||||
{
|
{
|
||||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((ServerPlayer) player, world, pos, state);
|
return ScriptChecker.fulfillsConditions(override, player) && handleProtections(player, world, pos, state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -54,35 +53,28 @@ public class PickupHandler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
|
||||||
{
|
{
|
||||||
if (ListHandler.isForbidden(world.getBlockState(pos).getBlock()))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state.getDestroySpeed(world, pos) != -1 || player.isCreative()))
|
if (state.getDestroySpeed(world, pos) != -1 || player.isCreative())
|
||||||
{
|
{
|
||||||
double distance = Vec3.atLowerCornerOf(pos).distanceTo(player.position());
|
double distance = Vec3.atLowerCornerOf(pos).distanceTo(player.position());
|
||||||
double maxDist = Settings.maxDistance.get();
|
double maxDist = Settings.maxDistance.get();
|
||||||
|
|
||||||
if (distance < maxDist)
|
if (distance < maxDist && !ItemCarryonBlock.isLocked(pos, world))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!ItemCarryonBlock.isLocked(pos, world))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
||||||
{
|
{
|
||||||
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(state), player) && handleProtections(player, world, pos, state);
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
|
||||||
{
|
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(state), player) && handleProtections((ServerPlayer) player, world, pos, state);
|
|
||||||
}
|
|
||||||
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
|
||||||
{
|
|
||||||
return handleProtections(player, world, pos, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
||||||
|
{
|
||||||
|
return handleProtections(player, world, pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +84,7 @@ public class PickupHandler
|
||||||
|
|
||||||
public static boolean canPlayerPickUpEntity(ServerPlayer player, Entity toPickUp)
|
public static boolean canPlayerPickUpEntity(ServerPlayer player, Entity toPickUp)
|
||||||
{
|
{
|
||||||
if(player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
if (player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR || player.gameMode.getGameModeForPlayer() == GameType.ADVENTURE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Vec3 pos = toPickUp.position();
|
Vec3 pos = toPickUp.position();
|
||||||
|
|
@ -103,34 +95,23 @@ public class PickupHandler
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
|
||||||
if (override != null)
|
if (override != null)
|
||||||
{
|
{
|
||||||
return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections(player, toPickUp);
|
return ScriptChecker.fulfillsConditions(override, player) && handleProtections(player, toPickUp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (toPickUp instanceof AgeableMob && Settings.allowBabies.get())
|
if (toPickUp instanceof AgeableMob living && Settings.allowBabies.get() && (living.getAge() < 0 || living.isBaby()))
|
||||||
{
|
{
|
||||||
AgeableMob living = (AgeableMob) toPickUp;
|
|
||||||
if (living.getAge() < 0 || living.isBaby())
|
double distance = pos.distanceToSqr(player.position());
|
||||||
|
if (distance <= Math.pow(Settings.maxDistance.get(), 2) && toPickUp instanceof TamableAnimal tame && tame.getOwnerUUID() != null && tame.getOwnerUUID() != Player.createPlayerUUID(player.getGameProfile()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
{
|
{
|
||||||
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections(player, toPickUp);
|
||||||
double distance = pos.distanceToSqr(player.position());
|
|
||||||
if (distance <= Math.pow(Settings.maxDistance.get(), 2))
|
|
||||||
{
|
|
||||||
if (toPickUp instanceof TamableAnimal)
|
|
||||||
{
|
|
||||||
TamableAnimal tame = (TamableAnimal) toPickUp;
|
|
||||||
if (tame.getOwnerUUID() != null && tame.getOwnerUUID() != Player.createPlayerUUID(player.getGameProfile()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
|
||||||
{
|
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayer) player, toPickUp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return handleProtections((ServerPlayer) player, toPickUp);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return handleProtections(player, toPickUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.useWhitelistEntities.get())
|
if (Settings.useWhitelistEntities.get())
|
||||||
|
|
@ -140,44 +121,35 @@ public class PickupHandler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (ListHandler.isForbidden(toPickUp))
|
||||||
{
|
{
|
||||||
if (ListHandler.isForbidden(toPickUp))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()))
|
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()) && (Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()))
|
||||||
{
|
{
|
||||||
if ((Settings.pickupHostileMobs.get() ? true : toPickUp.getType().getCategory() != MobCategory.MONSTER || player.isCreative()))
|
if (toPickUp.getBbHeight() <= Settings.maxEntityHeight.get() && toPickUp.getBbWidth() <= Settings.maxEntityWidth.get() || player.isCreative())
|
||||||
{
|
{
|
||||||
if ((toPickUp.getBbHeight() <= Settings.maxEntityHeight.get() && toPickUp.getBbWidth() <= Settings.maxEntityWidth.get() || player.isCreative()))
|
double distance = pos.distanceToSqr(player.position());
|
||||||
|
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
||||||
{
|
{
|
||||||
double distance = pos.distanceToSqr(player.position());
|
if (toPickUp instanceof TamableAnimal tame)
|
||||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
|
||||||
{
|
{
|
||||||
if (toPickUp instanceof TamableAnimal)
|
UUID owner = tame.getOwnerUUID();
|
||||||
{
|
UUID playerID = Player.createPlayerUUID(player.getGameProfile());
|
||||||
TamableAnimal tame = (TamableAnimal) toPickUp;
|
if (owner != null && !owner.equals(playerID))
|
||||||
UUID owner = tame.getOwnerUUID();
|
return false;
|
||||||
UUID playerID = Player.createPlayerUUID(player.getGameProfile());
|
|
||||||
if (owner != null && !owner.equals(playerID))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
|
||||||
{
|
|
||||||
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayer) player, toPickUp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return handleProtections((ServerPlayer) player, toPickUp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
|
{
|
||||||
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections(player, toPickUp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return handleProtections(player, toPickUp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,8 @@ public class RegistrationHandler
|
||||||
MinecraftForge.EVENT_BUS.register(new RenderEntityEvents());
|
MinecraftForge.EVENT_BUS.register(new RenderEntityEvents());
|
||||||
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
MinecraftForge.EVENT_BUS.register(new PositionClientEvents());
|
||||||
|
|
||||||
|
// if(ModList.get().isLoaded("obfuscate"))
|
||||||
// if(ModList.get().isLoaded("obfuscate"))
|
// MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||||
// MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +55,7 @@ public class RegistrationHandler
|
||||||
{
|
{
|
||||||
ModelOverridesHandler.initOverrides();
|
ModelOverridesHandler.initOverrides();
|
||||||
CustomPickupOverrideHandler.initPickupOverrides();
|
CustomPickupOverrideHandler.initPickupOverrides();
|
||||||
// ListHandler.initConfigLists();
|
// ListHandler.initConfigLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void regCaps()
|
public static void regCaps()
|
||||||
|
|
@ -64,7 +63,4 @@ public class RegistrationHandler
|
||||||
CapabilityManager.INSTANCE.register(IPosition.class);
|
CapabilityManager.INSTANCE.register(IPosition.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ public class CarryonGamestageHelper
|
||||||
{
|
{
|
||||||
public static boolean hasGamestage(String stage, Player player)
|
public static boolean hasGamestage(String stage, Player player)
|
||||||
{
|
{
|
||||||
// return GameStageHelper.hasStage(player, stage);
|
// return GameStageHelper.hasStage(player, stage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ public class InvalidConfigException extends Exception
|
||||||
StackTraceElement element = this.getStackTrace()[i];
|
StackTraceElement element = this.getStackTrace()[i];
|
||||||
CarryOn.LOGGER.error(element.toString());
|
CarryOn.LOGGER.error(element.toString());
|
||||||
|
|
||||||
if(i >= 10)
|
if (i >= 10)
|
||||||
{
|
{
|
||||||
CarryOn.LOGGER.error((this.getStackTrace().length - 10) + " more...");
|
CarryOn.LOGGER.error(this.getStackTrace().length - 10 + " more...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class KeyboardCallbackWrapper
|
||||||
|
|
||||||
public void setup(Minecraft mc)
|
public void setup(Minecraft mc)
|
||||||
{
|
{
|
||||||
oldCallback = GLFW.glfwSetKeyCallback(mc.getWindow().getWindow(), this::keyCallback);
|
this.oldCallback = GLFW.glfwSetKeyCallback(mc.getWindow().getWindow(), this::keyCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void keyCallback(long window, int key, int scancode, int action, int mods)
|
private void keyCallback(long window, int key, int scancode, int action, int mods)
|
||||||
|
|
@ -25,8 +25,8 @@ public class KeyboardCallbackWrapper
|
||||||
if (event.isCanceled())
|
if (event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (oldCallback != null)
|
if (this.oldCallback != null)
|
||||||
oldCallback.invoke(window, key, scancode, action, mods);
|
this.oldCallback.invoke(window, key, scancode, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some reflection helper code.
|
* Some reflection helper code.
|
||||||
*
|
*
|
||||||
|
|
@ -33,214 +34,230 @@ import com.google.common.base.Preconditions;
|
||||||
*/
|
*/
|
||||||
public class ReflectionHelper
|
public class ReflectionHelper
|
||||||
{
|
{
|
||||||
public static class UnableToFindMethodException extends RuntimeException
|
public static class UnableToFindMethodException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
//private String[] methodNames;
|
// private String[] methodNames;
|
||||||
|
|
||||||
public UnableToFindMethodException(String[] methodNames, Exception failed)
|
public UnableToFindMethodException(String[] methodNames, Exception failed)
|
||||||
{
|
{
|
||||||
super(failed);
|
super(failed);
|
||||||
//this.methodNames = methodNames;
|
// this.methodNames = methodNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnableToFindMethodException(Throwable failed)
|
public UnableToFindMethodException(Throwable failed)
|
||||||
{
|
{
|
||||||
super(failed);
|
super(failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnableToFindClassException extends RuntimeException
|
public static class UnableToFindClassException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
//private String[] classNames;
|
// private String[] classNames;
|
||||||
|
|
||||||
public UnableToFindClassException(String[] classNames, @Nullable Exception err)
|
public UnableToFindClassException(String[] classNames, @Nullable Exception err)
|
||||||
{
|
{
|
||||||
super(err);
|
super(err);
|
||||||
//this.classNames = classNames;
|
// this.classNames = classNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnableToAccessFieldException extends RuntimeException
|
public static class UnableToAccessFieldException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
//private String[] fieldNameList;
|
// private String[] fieldNameList;
|
||||||
|
|
||||||
public UnableToAccessFieldException(String[] fieldNames, Exception e)
|
public UnableToAccessFieldException(String[] fieldNames, Exception e)
|
||||||
{
|
{
|
||||||
super(e);
|
super(e);
|
||||||
//this.fieldNameList = fieldNames;
|
// this.fieldNameList = fieldNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnableToFindFieldException extends RuntimeException
|
public static class UnableToFindFieldException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
//private String[] fieldNameList;
|
|
||||||
public UnableToFindFieldException(String[] fieldNameList, Exception e)
|
|
||||||
{
|
|
||||||
super(e);
|
|
||||||
//this.fieldNameList = fieldNameList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
// private String[] fieldNameList;
|
||||||
|
public UnableToFindFieldException(String[] fieldNameList, Exception e)
|
||||||
|
{
|
||||||
|
super(e);
|
||||||
|
// this.fieldNameList = fieldNameList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public static class UnknownConstructorException extends RuntimeException
|
public static class UnknownConstructorException extends RuntimeException
|
||||||
{
|
{
|
||||||
public UnknownConstructorException(final String message)
|
public UnknownConstructorException(final String message)
|
||||||
{
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Field findField(Class<?> clazz, String... fieldNames)
|
public static Field findField(Class<?> clazz, String... fieldNames)
|
||||||
{
|
{
|
||||||
Exception failed = null;
|
Exception failed = null;
|
||||||
for (String fieldName : fieldNames)
|
for (String fieldName : fieldNames)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = clazz.getDeclaredField(fieldName);
|
Field f = clazz.getDeclaredField(fieldName);
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
failed = e;
|
failed = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new UnableToFindFieldException(fieldNames, failed);
|
throw new UnableToFindFieldException(fieldNames, failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, @Nullable E instance, int fieldIndex)
|
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, @Nullable E instance, int fieldIndex)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
return (T) f.get(instance);
|
return (T) f.get(instance);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new UnableToAccessFieldException(new String[0], e);
|
throw new UnableToAccessFieldException(new String[0], e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, String... fieldNames)
|
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String... fieldNames)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (T) findField(classToAccess, fieldNames).get(instance);
|
return (T) findField(classToAccess, fieldNames).get(instance);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new UnableToAccessFieldException(fieldNames, e);
|
throw new UnableToAccessFieldException(fieldNames, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, E value, int fieldIndex)
|
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
f.set(instance, value);
|
f.set(instance, value);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new UnableToAccessFieldException(new String[0] , e);
|
throw new UnableToAccessFieldException(new String[0], e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, E value, String... fieldNames)
|
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, String... fieldNames)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
findField(classToAccess, fieldNames).set(instance, value);
|
findField(classToAccess, fieldNames).set(instance, value);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new UnableToAccessFieldException(fieldNames, e);
|
throw new UnableToAccessFieldException(fieldNames, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Class<? super Object> getClass(ClassLoader loader, String... classNames)
|
public static Class<? super Object> getClass(ClassLoader loader, String... classNames)
|
||||||
{
|
{
|
||||||
Exception err = null;
|
Exception err = null;
|
||||||
for (String className : classNames)
|
for (String className : classNames)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (Class<? super Object>) Class.forName(className, false, loader);
|
return (Class<? super Object>) Class.forName(className, false, loader);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
err = e;
|
err = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnableToFindClassException(classNames, err);
|
throw new UnableToFindClassException(classNames, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a method with the specified name and parameters in the given class and makes it accessible.
|
* Finds a method with the specified name and parameters in the given class
|
||||||
* Note: for performance, store the returned value and avoid calling this repeatedly.
|
* and makes it accessible. Note: for performance, store the returned value
|
||||||
* <p>
|
* and avoid calling this repeatedly.
|
||||||
* Throws an exception if the method is not found.
|
* <p>
|
||||||
*
|
* Throws an exception if the method is not found.
|
||||||
* @param clazz The class to find the method on.
|
*
|
||||||
* @param methodName The name of the method to find (used in developer environments, i.e. "getWorldTime").
|
* @param clazz
|
||||||
* @param methodObfName The obfuscated name of the method to find (used in obfuscated environments, i.e. "getWorldTime").
|
* The class to find the method on.
|
||||||
* If the name you are looking for is on a class that is never obfuscated, this should be null.
|
* @param methodName
|
||||||
* @param parameterTypes The parameter types of the method to find.
|
* The name of the method to find (used in developer
|
||||||
* @return The method with the specified name and parameters in the given class.
|
* environments, i.e. "getWorldTime").
|
||||||
*/
|
* @param methodObfName
|
||||||
|
* The obfuscated name of the method to find (used in obfuscated
|
||||||
|
* environments, i.e. "getWorldTime"). If the name you are
|
||||||
|
* looking for is on a class that is never obfuscated, this
|
||||||
|
* should be null.
|
||||||
|
* @param parameterTypes
|
||||||
|
* The parameter types of the method to find.
|
||||||
|
* @return The method with the specified name and parameters in the given
|
||||||
|
* class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a constructor in the specified class that has matching parameter
|
||||||
|
* types.
|
||||||
|
*
|
||||||
|
* @param klass
|
||||||
|
* The class to find the constructor in
|
||||||
|
* @param parameterTypes
|
||||||
|
* The parameter types of the constructor.
|
||||||
|
* @param <T>
|
||||||
|
* The type
|
||||||
|
* @return The constructor
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if {@code klass} is null
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if {@code parameterTypes} is null
|
||||||
|
* @throws UnknownConstructorException
|
||||||
|
* if the constructor could not be found
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static <T> Constructor<T> findConstructor(@Nonnull final Class<T> klass, @Nonnull final Class<?>... parameterTypes)
|
||||||
|
{
|
||||||
|
Preconditions.checkNotNull(klass, "class");
|
||||||
|
Preconditions.checkNotNull(parameterTypes, "parameter types");
|
||||||
|
|
||||||
/**
|
final Constructor<T> constructor;
|
||||||
* Finds a constructor in the specified class that has matching parameter types.
|
try
|
||||||
*
|
{
|
||||||
* @param klass The class to find the constructor in
|
constructor = klass.getDeclaredConstructor(parameterTypes);
|
||||||
* @param parameterTypes The parameter types of the constructor.
|
constructor.setAccessible(true);
|
||||||
* @param <T> The type
|
}
|
||||||
* @return The constructor
|
catch (final NoSuchMethodException e)
|
||||||
* @throws NullPointerException if {@code klass} is null
|
{
|
||||||
* @throws NullPointerException if {@code parameterTypes} is null
|
final StringBuilder desc = new StringBuilder();
|
||||||
* @throws UnknownConstructorException if the constructor could not be found
|
desc.append(klass.getSimpleName()).append('(');
|
||||||
*/
|
for (int i = 0, length = parameterTypes.length; i < length; i++)
|
||||||
@Nonnull
|
{
|
||||||
public static <T> Constructor<T> findConstructor(@Nonnull final Class<T> klass, @Nonnull final Class<?>... parameterTypes)
|
desc.append(parameterTypes[i].getName());
|
||||||
{
|
if (i > length)
|
||||||
Preconditions.checkNotNull(klass, "class");
|
{
|
||||||
Preconditions.checkNotNull(parameterTypes, "parameter types");
|
desc.append(',').append(' ');
|
||||||
|
}
|
||||||
final Constructor<T> constructor;
|
}
|
||||||
try
|
desc.append(')');
|
||||||
{
|
throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + klass);
|
||||||
constructor = klass.getDeclaredConstructor(parameterTypes);
|
}
|
||||||
constructor.setAccessible(true);
|
return constructor;
|
||||||
}
|
}
|
||||||
catch (final NoSuchMethodException e)
|
|
||||||
{
|
|
||||||
final StringBuilder desc = new StringBuilder();
|
|
||||||
desc.append(klass.getSimpleName()).append('(');
|
|
||||||
for (int i = 0, length = parameterTypes.length; i < length; i++)
|
|
||||||
{
|
|
||||||
desc.append(parameterTypes[i].getName());
|
|
||||||
if (i > length)
|
|
||||||
{
|
|
||||||
desc.append(',').append(' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
desc.append(')');
|
|
||||||
throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + klass);
|
|
||||||
}
|
|
||||||
return constructor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -16,38 +16,50 @@ import net.minecraft.world.scores.Objective;
|
||||||
import net.minecraft.world.scores.Score;
|
import net.minecraft.world.scores.Score;
|
||||||
import net.minecraft.world.scores.Scoreboard;
|
import net.minecraft.world.scores.Scoreboard;
|
||||||
|
|
||||||
public class ScriptParseHelper {
|
public class ScriptParseHelper
|
||||||
|
{
|
||||||
|
|
||||||
public static boolean matches(double number, String cond) {
|
public static boolean matches(double number, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
try {
|
try
|
||||||
if (cond.contains("<=")) {
|
{
|
||||||
|
if (cond.contains("<="))
|
||||||
|
{
|
||||||
return number <= Double.parseDouble(cond.replace("<=", ""));
|
return number <= Double.parseDouble(cond.replace("<=", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains(">=")) {
|
if (cond.contains(">="))
|
||||||
|
{
|
||||||
return number >= Double.parseDouble(cond.replace(">=", ""));
|
return number >= Double.parseDouble(cond.replace(">=", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains("<")) {
|
if (cond.contains("<"))
|
||||||
|
{
|
||||||
return number < Double.parseDouble(cond.replace("<", ""));
|
return number < Double.parseDouble(cond.replace("<", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains(">")) {
|
if (cond.contains(">"))
|
||||||
|
{
|
||||||
return number > Double.parseDouble(cond.replace(">", ""));
|
return number > Double.parseDouble(cond.replace(">", ""));
|
||||||
}
|
}
|
||||||
if (cond.contains("=")) {
|
if (cond.contains("="))
|
||||||
|
{
|
||||||
return number == Double.parseDouble(cond.replace("=", ""));
|
return number == Double.parseDouble(cond.replace("=", ""));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return number == Double.parseDouble(cond);
|
return number == Double.parseDouble(cond);
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
new InvalidConfigException(e.getMessage()).printException();
|
new InvalidConfigException(e.getMessage()).printException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(Block block, String cond) {
|
public static boolean matches(Block block, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -58,12 +70,14 @@ public class ScriptParseHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(CompoundTag toCheck, CompoundTag toMatch) {
|
public static boolean matches(CompoundTag toCheck, CompoundTag toMatch)
|
||||||
|
{
|
||||||
if (toCheck == null || toMatch == null || toMatch.isEmpty())
|
if (toCheck == null || toMatch == null || toMatch.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
boolean matching = true;
|
boolean matching = true;
|
||||||
for (String key : toMatch.getAllKeys()) {
|
for (String key : toMatch.getAllKeys())
|
||||||
|
{
|
||||||
Tag tag = toMatch.get(key);
|
Tag tag = toMatch.get(key);
|
||||||
key = key.replace("\"", "");
|
key = key.replace("\"", "");
|
||||||
Tag tagToCheck = toCheck.get(key);
|
Tag tagToCheck = toCheck.get(key);
|
||||||
|
|
@ -74,7 +88,8 @@ public class ScriptParseHelper {
|
||||||
return matching;
|
return matching;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] getXYZArray(String s) {
|
public static float[] getXYZArray(String s)
|
||||||
|
{
|
||||||
float[] d = new float[3];
|
float[] d = new float[3];
|
||||||
d[0] = getValueFromString(s, "x");
|
d[0] = getValueFromString(s, "x");
|
||||||
d[1] = getValueFromString(s, "y");
|
d[1] = getValueFromString(s, "y");
|
||||||
|
|
@ -83,7 +98,8 @@ public class ScriptParseHelper {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] getScaled(String s) {
|
public static float[] getScaled(String s)
|
||||||
|
{
|
||||||
float[] d = new float[3];
|
float[] d = new float[3];
|
||||||
d[0] = getScaledValueFromString(s, "x");
|
d[0] = getScaledValueFromString(s, "x");
|
||||||
d[1] = getScaledValueFromString(s, "y");
|
d[1] = getScaledValueFromString(s, "y");
|
||||||
|
|
@ -92,19 +108,25 @@ public class ScriptParseHelper {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getScaledValueFromString(String toGetFrom, String key) {
|
public static float getScaledValueFromString(String toGetFrom, String key)
|
||||||
|
{
|
||||||
if (toGetFrom == null || toGetFrom.isEmpty())
|
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
for (String string : s) {
|
for (String string : s)
|
||||||
if (string.contains(key) && string.contains("=")) {
|
{
|
||||||
|
if (string.contains(key) && string.contains("="))
|
||||||
|
{
|
||||||
float numb = 1;
|
float numb = 1;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
numb = Float.parseFloat(string);
|
numb = Float.parseFloat(string);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
return numb;
|
return numb;
|
||||||
|
|
@ -114,7 +136,8 @@ public class ScriptParseHelper {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matchesScore(Player player, String cond) {
|
public static boolean matchesScore(Player player, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -134,9 +157,11 @@ public class ScriptParseHelper {
|
||||||
|
|
||||||
scorename = cond.replace(numb, "");
|
scorename = cond.replace(numb, "");
|
||||||
Map<Objective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
Map<Objective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
|
||||||
if (o != null) {
|
if (o != null)
|
||||||
|
{
|
||||||
Score sc = o.get(score.getObjective(scorename));
|
Score sc = o.get(score.getObjective(scorename));
|
||||||
if (sc != null) {
|
if (sc != null)
|
||||||
|
{
|
||||||
int points = sc.getScore();
|
int points = sc.getScore();
|
||||||
|
|
||||||
return matches(points, numb);
|
return matches(points, numb);
|
||||||
|
|
@ -146,36 +171,41 @@ public class ScriptParseHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(BlockPos pos, String cond) {
|
public static boolean matches(BlockPos pos, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"),
|
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
||||||
getValueFromString(cond, "z"));
|
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"), getValueFromString(cond, "dz"));
|
||||||
BlockPos expand = new BlockPos(getValueFromString(cond, "dx"), getValueFromString(cond, "dy"),
|
|
||||||
getValueFromString(cond, "dz"));
|
|
||||||
BlockPos expanded = blockpos.offset(expand);
|
BlockPos expanded = blockpos.offset(expand);
|
||||||
|
|
||||||
boolean x = (pos.getX() >= blockpos.getX() && pos.getX() <= expanded.getX()) || blockpos.getX() == 0;
|
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 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;
|
boolean z = pos.getZ() >= blockpos.getZ() && pos.getZ() <= expanded.getZ() || blockpos.getZ() == 0;
|
||||||
|
|
||||||
return x && y && z;
|
return x && y && z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getValueFromString(String toGetFrom, String key) {
|
public static float getValueFromString(String toGetFrom, String key)
|
||||||
|
{
|
||||||
if (toGetFrom == null || toGetFrom.isEmpty())
|
if (toGetFrom == null || toGetFrom.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
for (String string : s) {
|
for (String string : s)
|
||||||
if (string.contains(key) && string.contains("=")) {
|
{
|
||||||
|
if (string.contains(key) && string.contains("="))
|
||||||
|
{
|
||||||
float numb = 0;
|
float numb = 0;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
numb = Float.parseFloat(string);
|
numb = Float.parseFloat(string);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
return numb;
|
return numb;
|
||||||
|
|
@ -185,42 +215,51 @@ public class ScriptParseHelper {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEffects(Player player, String cond) {
|
public static boolean hasEffects(Player player, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Collection<MobEffectInstance> effects = player.getActiveEffects();
|
Collection<MobEffectInstance> effects = player.getActiveEffects();
|
||||||
String[] potions = cond.split(",");
|
String[] potions = cond.split(",");
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<>();
|
||||||
List<Integer> levels = new ArrayList<Integer>();
|
List<Integer> levels = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < potions.length; i++) {
|
for (String pot : potions)
|
||||||
String pot = potions[i];
|
{
|
||||||
if (pot.contains("#")) {
|
if (pot.contains("#"))
|
||||||
|
{
|
||||||
String level = pot.substring(pot.indexOf("#"));
|
String level = pot.substring(pot.indexOf("#"));
|
||||||
String name = pot.substring(0, pot.indexOf("#"));
|
String name = pot.substring(0, pot.indexOf("#"));
|
||||||
level = level.replace("#", "");
|
level = level.replace("#", "");
|
||||||
int lev = 0;
|
int lev = 0;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
lev = Integer.parseInt(level);
|
lev = Integer.parseInt(level);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
levels.add(lev);
|
levels.add(lev);
|
||||||
names.add(name);
|
names.add(name);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
levels.add(0);
|
levels.add(0);
|
||||||
names.add(pot);
|
names.add(pot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
for (MobEffectInstance effect : effects) {
|
for (MobEffectInstance effect : effects)
|
||||||
|
{
|
||||||
int amp = effect.getAmplifier();
|
int amp = effect.getAmplifier();
|
||||||
String name = effect.getEffect().getRegistryName().toString();
|
String name = effect.getEffect().getRegistryName().toString();
|
||||||
|
|
||||||
if (names.contains(name)) {
|
if (names.contains(name))
|
||||||
|
{
|
||||||
int idx = names.indexOf(name);
|
int idx = names.indexOf(name);
|
||||||
int lev = levels.get(idx);
|
int lev = levels.get(idx);
|
||||||
|
|
||||||
|
|
@ -232,11 +271,13 @@ public class ScriptParseHelper {
|
||||||
return matches == potions.length;
|
return matches == potions.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matches(Material material, String cond) {
|
public static boolean matches(Material material, String cond)
|
||||||
|
{
|
||||||
if (cond == null || cond.isEmpty())
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (cond) {
|
switch (cond)
|
||||||
|
{
|
||||||
case "air":
|
case "air":
|
||||||
return material == Material.AIR;
|
return material == Material.AIR;
|
||||||
case "anvil":
|
case "anvil":
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class ScrollCallbackWrapper
|
||||||
|
|
||||||
public void setup(Minecraft mc)
|
public void setup(Minecraft mc)
|
||||||
{
|
{
|
||||||
oldCallback = GLFW.glfwSetScrollCallback(mc.getWindow().getWindow(), this::scrollCallback);
|
this.oldCallback = GLFW.glfwSetScrollCallback(mc.getWindow().getWindow(), this::scrollCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollCallback(long window, double xoffset, double yoffset)
|
private void scrollCallback(long window, double xoffset, double yoffset)
|
||||||
|
|
@ -26,8 +26,8 @@ public class ScrollCallbackWrapper
|
||||||
if (event.isCanceled())
|
if (event.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (oldCallback != null)
|
if (this.oldCallback != null)
|
||||||
oldCallback.invoke(window, xoffset, yoffset);
|
this.oldCallback.invoke(window, xoffset, yoffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,16 @@ public class StringParser
|
||||||
public static Block getBlock(String string)
|
public static Block getBlock(String string)
|
||||||
{
|
{
|
||||||
BlockState state = getBlockState(string);
|
BlockState state = getBlockState(string);
|
||||||
if(state != null)
|
if (state != null)
|
||||||
return state.getBlock();
|
return state.getBlock();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BlockState getBlockState(String string)
|
public static BlockState getBlockState(String string)
|
||||||
{
|
{
|
||||||
if(string == null)
|
if (string == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BlockStateParser parser = new BlockStateParser(new StringReader(string), false);
|
BlockStateParser parser = new BlockStateParser(new StringReader(string), false);
|
||||||
|
|
@ -50,7 +49,7 @@ public class StringParser
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Item getItem(String string)
|
public static Item getItem(String string)
|
||||||
{
|
{
|
||||||
if(string == null)
|
if (string == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ItemParser parser = new ItemParser(new StringReader(string), false);
|
ItemParser parser = new ItemParser(new StringReader(string), false);
|
||||||
|
|
@ -69,7 +68,7 @@ public class StringParser
|
||||||
|
|
||||||
public static ItemStack getItemStack(String string)
|
public static ItemStack getItemStack(String string)
|
||||||
{
|
{
|
||||||
if(string == null)
|
if (string == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ItemParser parser = new ItemParser(new StringReader(string), false);
|
ItemParser parser = new ItemParser(new StringReader(string), false);
|
||||||
|
|
@ -77,12 +76,12 @@ public class StringParser
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parser.parse();
|
parser.parse();
|
||||||
Item item = parser.getItem();
|
Item item = parser.getItem();
|
||||||
CompoundTag nbt = parser.getNbt();
|
CompoundTag nbt = parser.getNbt();
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(item, 1);
|
ItemStack stack = new ItemStack(item, 1);
|
||||||
|
|
||||||
if(nbt != null)
|
if (nbt != null)
|
||||||
{
|
{
|
||||||
stack.setTag(nbt);
|
stack.setTag(nbt);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +101,7 @@ public class StringParser
|
||||||
public static CompoundTag getTagCompound(String string)
|
public static CompoundTag getTagCompound(String string)
|
||||||
{
|
{
|
||||||
CompoundTag tag = null;
|
CompoundTag tag = null;
|
||||||
if(string == null)
|
if (string == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (string.contains("{"))
|
if (string.contains("{"))
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String TILE_DATA_KEY = "tileData";
|
public static final String TILE_DATA_KEY = "tileData";
|
||||||
public static final String[] FACING_KEYS = new String[] { "rotation", "rot", "facing", "face", "direction", "dir", "front", "forward" };
|
public static final String[] FACING_KEYS = { "rotation", "rot", "facing", "face", "direction", "dir", "front", "forward" };
|
||||||
|
|
||||||
public ItemCarryonBlock()
|
public ItemCarryonBlock()
|
||||||
{
|
{
|
||||||
|
|
@ -89,11 +89,8 @@ public class ItemCarryonBlock extends Item
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
ItemStack stack = context.getItemInHand();
|
ItemStack stack = context.getItemInHand();
|
||||||
|
|
||||||
if (ModList.get().isLoaded("betterplacement"))
|
if (ModList.get().isLoaded("betterplacement") && CarryOnKeybinds.isKeyPressed(player))
|
||||||
{
|
return InteractionResult.FAIL;
|
||||||
if (CarryOnKeybinds.isKeyPressed(player))
|
|
||||||
return InteractionResult.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasTileData(stack))
|
if (hasTileData(stack))
|
||||||
{
|
{
|
||||||
|
|
@ -113,92 +110,92 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
boolean canPlace = containedstate.canSurvive(world, pos2);
|
boolean canPlace = containedstate.canSurvive(world, pos2);
|
||||||
|
|
||||||
if (canPlace)
|
if (canPlace && player.mayUseItemAt(pos, facing, stack) && world.mayInteract(player, pos2))
|
||||||
{
|
{
|
||||||
if (player.mayUseItemAt(pos, facing, stack) && world.mayInteract(player, pos2))
|
|
||||||
|
BlockState placementState = containedblock.getStateForPlacement(new BlockPlaceContext(context));
|
||||||
|
|
||||||
|
BlockState actualState = placementState == null ? containedstate : placementState;
|
||||||
|
|
||||||
|
// Attempted fix for #287
|
||||||
|
// for (IProperty<?> prop :
|
||||||
|
// placementState.getValues().keySet())
|
||||||
|
// {
|
||||||
|
// if (prop instanceof DirectionProperty)
|
||||||
|
// actualState = actualState.with((DirectionProperty)
|
||||||
|
// prop, placementState.get((DirectionProperty) prop));
|
||||||
|
// else if (prop == BlockStateProperties.WATERLOGGED)
|
||||||
|
// actualState = actualState.with((BooleanProperty)
|
||||||
|
// prop, placementState.get((BooleanProperty) prop));
|
||||||
|
// else if(prop instanceof EnumProperty<?>)
|
||||||
|
// {
|
||||||
|
// Object value = placementState.get(prop);
|
||||||
|
// if(value instanceof Direction.Axis)
|
||||||
|
// {
|
||||||
|
// actualState = actualState.with((EnumProperty)prop,
|
||||||
|
// (Direction.Axis)value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
BlockSnapshot snapshot = BlockSnapshot.create(world.dimension(), world, pos2);
|
||||||
|
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, world.getBlockState(pos), player);
|
||||||
|
MinecraftForge.EVENT_BUS.post(event);
|
||||||
|
|
||||||
|
if (!event.isCanceled())
|
||||||
{
|
{
|
||||||
|
world.setBlockAndUpdate(pos2, actualState);
|
||||||
|
|
||||||
BlockState placementState = containedblock.getStateForPlacement(new BlockPlaceContext(context));
|
// If the blockstate doesn't handle rotation,
|
||||||
|
// try to
|
||||||
BlockState actualState = placementState == null ? containedstate : placementState;
|
// change rotation via NBT
|
||||||
|
if (!getTileData(stack).isEmpty())
|
||||||
//Attempted fix for #287
|
|
||||||
// for (IProperty<?> prop : placementState.getValues().keySet())
|
|
||||||
// {
|
|
||||||
// if (prop instanceof DirectionProperty)
|
|
||||||
// actualState = actualState.with((DirectionProperty) prop, placementState.get((DirectionProperty) prop));
|
|
||||||
// else if (prop == BlockStateProperties.WATERLOGGED)
|
|
||||||
// actualState = actualState.with((BooleanProperty) prop, placementState.get((BooleanProperty) prop));
|
|
||||||
// else if(prop instanceof EnumProperty<?>)
|
|
||||||
// {
|
|
||||||
// Object value = placementState.get(prop);
|
|
||||||
// if(value instanceof Direction.Axis)
|
|
||||||
// {
|
|
||||||
// actualState = actualState.with((EnumProperty)prop, (Direction.Axis)value);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
BlockSnapshot snapshot = BlockSnapshot.create(world.dimension(), world, pos2);
|
|
||||||
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, world.getBlockState(pos), player);
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
|
|
||||||
if (!event.isCanceled())
|
|
||||||
{
|
{
|
||||||
world.setBlockAndUpdate(pos2, actualState);
|
CompoundTag tag = getTileData(stack);
|
||||||
|
Set<String> keys = tag.getAllKeys();
|
||||||
// If the blockstate doesn't handle rotation,
|
keytester: for (String key : keys)
|
||||||
// try to
|
|
||||||
// change rotation via NBT
|
|
||||||
if (!getTileData(stack).isEmpty())
|
|
||||||
{
|
{
|
||||||
CompoundTag tag = getTileData(stack);
|
for (String facingKey : FACING_KEYS)
|
||||||
Set<String> keys = tag.getAllKeys();
|
|
||||||
keytester: for (String key : keys)
|
|
||||||
{
|
{
|
||||||
for (String facingKey : FACING_KEYS)
|
if (key.toLowerCase().equals(facingKey))
|
||||||
{
|
{
|
||||||
if (key.toLowerCase().equals(facingKey))
|
byte type = tag.getTagType(key);
|
||||||
|
switch (type)
|
||||||
{
|
{
|
||||||
byte type = tag.getTagType(key);
|
case 8:
|
||||||
switch (type)
|
tag.putString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
||||||
{
|
break;
|
||||||
case 8:
|
case 3:
|
||||||
tag.putString(key, CharMatcher.javaUpperCase().matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
tag.putInt(key, facing2.getOpposite().get3DDataValue());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 1:
|
||||||
tag.putInt(key, facing2.getOpposite().get3DDataValue());
|
tag.putByte(key, (byte) facing2.getOpposite().get3DDataValue());
|
||||||
break;
|
break;
|
||||||
case 1:
|
default:
|
||||||
tag.putByte(key, (byte) facing2.getOpposite().get3DDataValue());
|
break;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break keytester;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break keytester;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockEntity tile = world.getBlockEntity(pos2);
|
|
||||||
if (tile != null)
|
|
||||||
{
|
|
||||||
CompoundTag data = getTileData(stack);
|
|
||||||
updateTileLocation(data, pos2);
|
|
||||||
tile.load(data);
|
|
||||||
}
|
|
||||||
clearTileData(stack);
|
|
||||||
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
|
||||||
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
|
||||||
player.getPersistentData().remove("overrideKey");
|
|
||||||
ItemEvents.sendPacket(player, 9, 0);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
BlockEntity tile = world.getBlockEntity(pos2);
|
||||||
|
if (tile != null)
|
||||||
|
{
|
||||||
|
CompoundTag data = getTileData(stack);
|
||||||
|
updateTileLocation(data, pos2);
|
||||||
|
tile.load(data);
|
||||||
|
}
|
||||||
|
clearTileData(stack);
|
||||||
|
player.playSound(actualState.getSoundType(world, pos2, player).getPlaceSound(), 1.0f, 0.5f);
|
||||||
|
player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
|
player.getPersistentData().remove("overrideKey");
|
||||||
|
ItemEvents.sendPacket(player, 9, 0);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,19 +33,21 @@ import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.event.ItemEvents;
|
import tschipp.carryon.common.event.ItemEvents;
|
||||||
|
|
||||||
public class ItemCarryonEntity extends Item {
|
public class ItemCarryonEntity extends Item
|
||||||
|
{
|
||||||
|
|
||||||
private static final Method initGoals;
|
private static final Method initGoals;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
initGoals = ObfuscationReflectionHelper.findMethod(Mob.class, "m_8099_");
|
initGoals = ObfuscationReflectionHelper.findMethod(Mob.class, "m_8099_");
|
||||||
initGoals.setAccessible(true);
|
initGoals.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String ENTITY_DATA_KEY = "entityData";
|
public static final String ENTITY_DATA_KEY = "entityData";
|
||||||
|
|
||||||
public ItemCarryonEntity() {
|
public ItemCarryonEntity()
|
||||||
|
{
|
||||||
super(new Item.Properties().stacksTo(1));
|
super(new Item.Properties().stacksTo(1));
|
||||||
this.setRegistryName(CarryOn.MODID, "entity_item");
|
this.setRegistryName(CarryOn.MODID, "entity_item");
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +55,8 @@ public class ItemCarryonEntity extends Item {
|
||||||
@Override
|
@Override
|
||||||
public Component getName(ItemStack stack)
|
public Component getName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (hasEntityData(stack)) {
|
if (hasEntityData(stack))
|
||||||
|
{
|
||||||
|
|
||||||
return new TranslatableComponent(getEntityType(stack).getDescriptionId());
|
return new TranslatableComponent(getEntityType(stack).getDescriptionId());
|
||||||
}
|
}
|
||||||
|
|
@ -61,19 +64,19 @@ public class ItemCarryonEntity extends Item {
|
||||||
return new TextComponent("");
|
return new TextComponent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEntityData(ItemStack stack) {
|
public static boolean hasEntityData(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.contains(ENTITY_DATA_KEY) && tag.contains("entity");
|
return tag.contains(ENTITY_DATA_KEY) && tag.contains("entity");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean storeEntityData(@Nonnull Entity entity, Level world, ItemStack stack) {
|
public static boolean storeEntityData(@Nonnull Entity entity, Level world, ItemStack stack)
|
||||||
if (entity == null)
|
{
|
||||||
return false;
|
if (entity == null || stack.isEmpty())
|
||||||
|
|
||||||
if (stack.isEmpty())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CompoundTag entityData = new CompoundTag();
|
CompoundTag entityData = new CompoundTag();
|
||||||
|
|
@ -92,7 +95,8 @@ public class ItemCarryonEntity extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult useOn(UseOnContext context) {
|
public InteractionResult useOn(UseOnContext context)
|
||||||
|
{
|
||||||
Player player = context.getPlayer();
|
Player player = context.getPlayer();
|
||||||
Level world = context.getLevel();
|
Level world = context.getLevel();
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
|
|
@ -102,25 +106,27 @@ public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
if (ModList.get().isLoaded("betterplacement")) {
|
if (ModList.get().isLoaded("betterplacement") && CarryOnKeybinds.isKeyPressed(player))
|
||||||
if (CarryOnKeybinds.isKeyPressed(player))
|
return InteractionResult.FAIL;
|
||||||
return InteractionResult.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasEntityData(stack)) {
|
if (hasEntityData(stack))
|
||||||
|
{
|
||||||
BlockPos finalPos = pos;
|
BlockPos finalPos = pos;
|
||||||
|
|
||||||
if (!state.canBeReplaced(new BlockPlaceContext(context))) {
|
if (!state.canBeReplaced(new BlockPlaceContext(context)))
|
||||||
|
{
|
||||||
finalPos = pos.relative(facing);
|
finalPos = pos.relative(facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = getEntity(stack, world);
|
Entity entity = getEntity(stack, world);
|
||||||
if (entity != null) {
|
if (entity != null)
|
||||||
if (!world.isClientSide) {
|
{
|
||||||
entity.absMoveTo(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5,
|
if (!world.isClientSide)
|
||||||
180 + player.yHeadRot, 0.0f);
|
{
|
||||||
|
entity.absMoveTo(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5, 180 + player.yHeadRot, 0.0f);
|
||||||
world.addFreshEntity(entity);
|
world.addFreshEntity(entity);
|
||||||
if (entity instanceof Mob) {
|
if (entity instanceof Mob)
|
||||||
|
{
|
||||||
((Mob) entity).playAmbientSound();
|
((Mob) entity).playAmbientSound();
|
||||||
}
|
}
|
||||||
clearEntityData(stack);
|
clearEntityData(stack);
|
||||||
|
|
@ -137,42 +143,50 @@ public class ItemCarryonEntity extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected)
|
||||||
if (hasEntityData(stack)) {
|
{
|
||||||
|
if (hasEntityData(stack))
|
||||||
|
{
|
||||||
if (getEntity(stack, world) == null)
|
if (getEntity(stack, world) == null)
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity)
|
||||||
if (entity instanceof Player && Settings.slownessInCreative.get() ? false
|
{
|
||||||
: ((Player) entity).isCreative())
|
if (entity instanceof Player && Settings.slownessInCreative.get() ? false : ((Player) entity).isCreative())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((LivingEntity) entity).addEffect(
|
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, this.potionLevel(stack, world), false, false));
|
||||||
new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 1, potionLevel(stack, world), false, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearEntityData(ItemStack stack) {
|
public static void clearEntityData(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
tag.remove(ENTITY_DATA_KEY);
|
tag.remove(ENTITY_DATA_KEY);
|
||||||
tag.remove("entity");
|
tag.remove("entity");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompoundTag getPersistentData(ItemStack stack) {
|
public static CompoundTag getPersistentData(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getCompound(ENTITY_DATA_KEY);
|
return tag.getCompound(ENTITY_DATA_KEY);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getEntity(ItemStack stack, Level world) {
|
public static Entity getEntity(ItemStack stack, Level world)
|
||||||
|
{
|
||||||
if (world == null)
|
if (world == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
@ -182,7 +196,8 @@ public class ItemCarryonEntity extends Item {
|
||||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||||
Entity entity = null;
|
Entity entity = null;
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent())
|
||||||
|
{
|
||||||
entity = type.get().create(world);
|
entity = type.get().create(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,28 +216,37 @@ public class ItemCarryonEntity extends Item {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEntityName(ItemStack stack) {
|
public static String getEntityName(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
return tag.getString("entity");
|
return tag.getString("entity");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCustomName(ItemStack stack) {
|
public static String getCustomName(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
if (tag.contains("CustomName") && !tag.getString("CustomName").isEmpty()) {
|
if (tag.contains("CustomName") && !tag.getString("CustomName").isEmpty())
|
||||||
|
{
|
||||||
return tag.toString();
|
return tag.toString();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return tag.toString();
|
return tag.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityType<?> getEntityType(ItemStack stack) {
|
public static EntityType<?> getEntityType(ItemStack stack)
|
||||||
if (stack.hasTag()) {
|
{
|
||||||
|
if (stack.hasTag())
|
||||||
|
{
|
||||||
CompoundTag tag = stack.getTag();
|
CompoundTag tag = stack.getTag();
|
||||||
String name = tag.getString("entity");
|
String name = tag.getString("entity");
|
||||||
Optional<EntityType<?>> type = EntityType.byString(name);
|
Optional<EntityType<?>> type = EntityType.byString(name);
|
||||||
|
|
@ -232,7 +256,8 @@ public class ItemCarryonEntity extends Item {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int potionLevel(ItemStack stack, Level world) {
|
private int potionLevel(ItemStack stack, Level world)
|
||||||
|
{
|
||||||
Entity e = getEntity(stack, world);
|
Entity e = getEntity(stack, world);
|
||||||
if (e == null)
|
if (e == null)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package tschipp.carryon.common.scripting;
|
package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
|
@ -64,7 +66,7 @@ public class CarryOnOverride
|
||||||
public CarryOnOverride(JsonElement jsonElem, ResourceLocation loc)
|
public CarryOnOverride(JsonElement jsonElem, ResourceLocation loc)
|
||||||
{
|
{
|
||||||
boolean errored = false;
|
boolean errored = false;
|
||||||
resourceLocation = loc.toString();
|
this.resourceLocation = loc.toString();
|
||||||
|
|
||||||
if (jsonElem != null && jsonElem.isJsonObject())
|
if (jsonElem != null && jsonElem.isJsonObject())
|
||||||
{
|
{
|
||||||
|
|
@ -76,19 +78,19 @@ public class CarryOnOverride
|
||||||
JsonObject render = (JsonObject) json.get("render");
|
JsonObject render = (JsonObject) json.get("render");
|
||||||
JsonObject effects = (JsonObject) json.get("effects");
|
JsonObject effects = (JsonObject) json.get("effects");
|
||||||
|
|
||||||
if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
if (object != null && (conditions != null || render != null || effects != null))
|
||||||
{
|
{
|
||||||
JsonObject block = (JsonObject) object.get("block");
|
JsonObject block = (JsonObject) object.get("block");
|
||||||
JsonObject entity = (JsonObject) object.get("entity");
|
JsonObject entity = (JsonObject) object.get("entity");
|
||||||
|
|
||||||
if ((block == null && entity == null) || (block != null && entity != null))
|
if (block == null && entity == null || block != null && entity != null)
|
||||||
errored = true;
|
errored = true;
|
||||||
|
|
||||||
if (!errored)
|
if (!errored)
|
||||||
{
|
{
|
||||||
if (block != null)
|
if (block != null)
|
||||||
{
|
{
|
||||||
setBlock(true);
|
this.setBlock(true);
|
||||||
JsonElement name = block.get("name");
|
JsonElement name = block.get("name");
|
||||||
JsonElement material = block.get("material");
|
JsonElement material = block.get("material");
|
||||||
JsonElement hardness = block.get("hardness");
|
JsonElement hardness = block.get("hardness");
|
||||||
|
|
@ -96,19 +98,19 @@ public class CarryOnOverride
|
||||||
JsonObject nbt = (JsonObject) block.get("nbt");
|
JsonObject nbt = (JsonObject) block.get("nbt");
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
setTypeNameBlock(name.getAsString());
|
this.setTypeNameBlock(name.getAsString());
|
||||||
if (material != null)
|
if (material != null)
|
||||||
setTypeMaterial(material.getAsString());
|
this.setTypeMaterial(material.getAsString());
|
||||||
if (hardness != null)
|
if (hardness != null)
|
||||||
setTypeHardness(hardness.getAsString());
|
this.setTypeHardness(hardness.getAsString());
|
||||||
if (resistance != null)
|
if (resistance != null)
|
||||||
setTypeResistance(resistance.getAsString());
|
this.setTypeResistance(resistance.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setTypeBlockTag(TagParser.parseTag(nbt.toString()));
|
this.setTypeBlockTag(TagParser.parseTag(nbt.toString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEntity(true);
|
this.setEntity(true);
|
||||||
JsonElement name = entity.get("name");
|
JsonElement name = entity.get("name");
|
||||||
JsonElement health = entity.get("health");
|
JsonElement health = entity.get("health");
|
||||||
JsonElement height = entity.get("height");
|
JsonElement height = entity.get("height");
|
||||||
|
|
@ -116,15 +118,15 @@ public class CarryOnOverride
|
||||||
JsonObject nbt = (JsonObject) entity.get("nbt");
|
JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
setTypeNameEntity(name.getAsString());
|
this.setTypeNameEntity(name.getAsString());
|
||||||
if (health != null)
|
if (health != null)
|
||||||
setTypeHealth(health.getAsString());
|
this.setTypeHealth(health.getAsString());
|
||||||
if (height != null)
|
if (height != null)
|
||||||
setTypeHeight(height.getAsString());
|
this.setTypeHeight(height.getAsString());
|
||||||
if (width != null)
|
if (width != null)
|
||||||
setTypeWidth(width.getAsString());
|
this.setTypeWidth(width.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setTypeEntityTag(TagParser.parseTag(nbt.toString()));
|
this.setTypeEntityTag(TagParser.parseTag(nbt.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conditions != null)
|
if (conditions != null)
|
||||||
|
|
@ -138,19 +140,19 @@ public class CarryOnOverride
|
||||||
JsonElement potionEffects = conditions.get("effects");
|
JsonElement potionEffects = conditions.get("effects");
|
||||||
|
|
||||||
if (gamestage != null)
|
if (gamestage != null)
|
||||||
setConditionGamestage(gamestage.getAsString());
|
this.setConditionGamestage(gamestage.getAsString());
|
||||||
if (achievement != null)
|
if (achievement != null)
|
||||||
setConditionAchievement(achievement.getAsString());
|
this.setConditionAchievement(achievement.getAsString());
|
||||||
if (xp != null)
|
if (xp != null)
|
||||||
setConditionXp(xp.getAsString());
|
this.setConditionXp(xp.getAsString());
|
||||||
if (gamemode != null)
|
if (gamemode != null)
|
||||||
setConditionGamemode(gamemode.getAsString());
|
this.setConditionGamemode(gamemode.getAsString());
|
||||||
if (scoreboard != null)
|
if (scoreboard != null)
|
||||||
setConditionScoreboard(scoreboard.getAsString());
|
this.setConditionScoreboard(scoreboard.getAsString());
|
||||||
if (position != null)
|
if (position != null)
|
||||||
setConditionPosition(position.getAsString());
|
this.setConditionPosition(position.getAsString());
|
||||||
if (potionEffects != null)
|
if (potionEffects != null)
|
||||||
setConditionEffects(potionEffects.getAsString());
|
this.setConditionEffects(potionEffects.getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (render != null)
|
if (render != null)
|
||||||
|
|
@ -167,25 +169,25 @@ public class CarryOnOverride
|
||||||
JsonElement renderRightArm = render.get("render_right_arm");
|
JsonElement renderRightArm = render.get("render_right_arm");
|
||||||
|
|
||||||
if (name_block != null)
|
if (name_block != null)
|
||||||
setRenderNameBlock(name_block.getAsString());
|
this.setRenderNameBlock(name_block.getAsString());
|
||||||
if (name_entity != null)
|
if (name_entity != null)
|
||||||
setRenderNameEntity(name_entity.getAsString());
|
this.setRenderNameEntity(name_entity.getAsString());
|
||||||
if (translation != null)
|
if (translation != null)
|
||||||
setRenderTranslation(translation.getAsString());
|
this.setRenderTranslation(translation.getAsString());
|
||||||
if (rotation != null)
|
if (rotation != null)
|
||||||
setRenderRotation(rotation.getAsString());
|
this.setRenderRotation(rotation.getAsString());
|
||||||
if (scaled != null)
|
if (scaled != null)
|
||||||
setRenderscaled(scaled.getAsString());
|
this.setRenderscaled(scaled.getAsString());
|
||||||
if (nbt != null)
|
if (nbt != null)
|
||||||
setRenderNBT(TagParser.parseTag(nbt.toString()));
|
this.setRenderNBT(TagParser.parseTag(nbt.toString()));
|
||||||
if (rotationLeftArm != null)
|
if (rotationLeftArm != null)
|
||||||
setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
this.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||||
if (rotationRightArm != null)
|
if (rotationRightArm != null)
|
||||||
setRenderRotationRightArm(rotationRightArm.getAsString());
|
this.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||||
if (renderLeftArm != null)
|
if (renderLeftArm != null)
|
||||||
setRenderLeftArm(renderLeftArm.getAsBoolean());
|
this.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||||
if (renderRightArm != null)
|
if (renderRightArm != null)
|
||||||
setRenderRightArm(renderRightArm.getAsBoolean());
|
this.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effects != null)
|
if (effects != null)
|
||||||
|
|
@ -195,35 +197,35 @@ public class CarryOnOverride
|
||||||
JsonElement commandPlace = effects.get("commandPlace");
|
JsonElement commandPlace = effects.get("commandPlace");
|
||||||
|
|
||||||
if (commandInit != null)
|
if (commandInit != null)
|
||||||
setCommandInit(commandInit.getAsString());
|
this.setCommandInit(commandInit.getAsString());
|
||||||
if (commandLoop != null)
|
if (commandLoop != null)
|
||||||
setCommandLoop(commandLoop.getAsString());
|
this.setCommandLoop(commandLoop.getAsString());
|
||||||
if (commandPlace != null)
|
if (commandPlace != null)
|
||||||
setCommandPlace(commandPlace.getAsString());
|
this.setCommandPlace(commandPlace.getAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isInvalid = true;
|
this.isInvalid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
isInvalid = true;
|
this.isInvalid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isInvalid = true;
|
this.isInvalid = true;
|
||||||
|
|
||||||
if(!isBlock && !isEntity)
|
if (!this.isBlock && !this.isEntity)
|
||||||
isInvalid = true;
|
this.isInvalid = true;
|
||||||
|
|
||||||
if(isInvalid)
|
if (this.isInvalid)
|
||||||
new InvalidConfigException("The script parsing for " + resourceLocation + " has failed! Please double check!").printException();
|
new InvalidConfigException("The script parsing for " + this.resourceLocation + " has failed! Please double check!").printException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommandInit()
|
public String getCommandInit()
|
||||||
{
|
{
|
||||||
return commandInit;
|
return this.commandInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommandInit(String commandInit)
|
public void setCommandInit(String commandInit)
|
||||||
|
|
@ -233,7 +235,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public String getCommandLoop()
|
public String getCommandLoop()
|
||||||
{
|
{
|
||||||
return commandLoop;
|
return this.commandLoop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommandLoop(String commandLoop)
|
public void setCommandLoop(String commandLoop)
|
||||||
|
|
@ -243,7 +245,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public String getConditionEffects()
|
public String getConditionEffects()
|
||||||
{
|
{
|
||||||
return conditionEffects;
|
return this.conditionEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConditionEffects(String conditionEffects)
|
public void setConditionEffects(String conditionEffects)
|
||||||
|
|
@ -253,7 +255,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public String getRenderRotationLeftArm()
|
public String getRenderRotationLeftArm()
|
||||||
{
|
{
|
||||||
return renderRotationLeftArm;
|
return this.renderRotationLeftArm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderRotationLeftArm(String renderRotationLeftArm)
|
public void setRenderRotationLeftArm(String renderRotationLeftArm)
|
||||||
|
|
@ -263,7 +265,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public String getRenderRotationRightArm()
|
public String getRenderRotationRightArm()
|
||||||
{
|
{
|
||||||
return renderRotationRightArm;
|
return this.renderRotationRightArm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderRotationRightArm(String renderRotationRightArm)
|
public void setRenderRotationRightArm(String renderRotationRightArm)
|
||||||
|
|
@ -273,7 +275,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public boolean isRenderLeftArm()
|
public boolean isRenderLeftArm()
|
||||||
{
|
{
|
||||||
return renderLeftArm;
|
return this.renderLeftArm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderLeftArm(boolean renderLeftArm)
|
public void setRenderLeftArm(boolean renderLeftArm)
|
||||||
|
|
@ -283,7 +285,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public boolean isRenderRightArm()
|
public boolean isRenderRightArm()
|
||||||
{
|
{
|
||||||
return renderRightArm;
|
return this.renderRightArm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderRightArm(boolean renderRightArm)
|
public void setRenderRightArm(boolean renderRightArm)
|
||||||
|
|
@ -296,8 +298,7 @@ public class CarryOnOverride
|
||||||
{
|
{
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((resourceLocation == null) ? 0 : resourceLocation.hashCode());
|
return prime * result + (this.resourceLocation == null ? 0 : this.resourceLocation.hashCode());
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -311,228 +312,115 @@ public class CarryOnOverride
|
||||||
{
|
{
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
if (obj == null || this.getClass() != obj.getClass())
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
return false;
|
||||||
CarryOnOverride other = (CarryOnOverride) obj;
|
CarryOnOverride other = (CarryOnOverride) obj;
|
||||||
if (commandInit == null)
|
if (!Objects.equals(this.commandInit, other.commandInit) || !Objects.equals(this.commandLoop, other.commandLoop) || !Objects.equals(this.commandPlace, other.commandPlace) || !Objects.equals(this.conditionAchievement, other.conditionAchievement))
|
||||||
{
|
{
|
||||||
if (other.commandInit != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!commandInit.equals(other.commandInit))
|
|
||||||
return false;
|
return false;
|
||||||
if (commandLoop == null)
|
}
|
||||||
|
if (!Objects.equals(this.conditionEffects, other.conditionEffects) || !Objects.equals(this.conditionGamemode, other.conditionGamemode) || !Objects.equals(this.conditionGamestage, other.conditionGamestage) || !Objects.equals(this.conditionPosition, other.conditionPosition))
|
||||||
{
|
{
|
||||||
if (other.commandLoop != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!commandLoop.equals(other.commandLoop))
|
|
||||||
return false;
|
return false;
|
||||||
if (commandPlace == null)
|
}
|
||||||
|
if (!Objects.equals(this.conditionScoreboard, other.conditionScoreboard))
|
||||||
{
|
{
|
||||||
if (other.commandPlace != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!commandPlace.equals(other.commandPlace))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionAchievement == null)
|
}
|
||||||
|
if (!Objects.equals(this.conditionXp, other.conditionXp))
|
||||||
{
|
{
|
||||||
if (other.conditionAchievement != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionAchievement.equals(other.conditionAchievement))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionEffects == null)
|
}
|
||||||
|
if (this.isBlock != other.isBlock)
|
||||||
|
return false;
|
||||||
|
if (this.isEntity != other.isEntity)
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(this.resourceLocation, other.resourceLocation))
|
||||||
{
|
{
|
||||||
if (other.conditionEffects != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionEffects.equals(other.conditionEffects))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionGamemode == null)
|
}
|
||||||
|
if (this.renderLeftArm != other.renderLeftArm)
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(this.renderNBT, other.renderNBT))
|
||||||
{
|
{
|
||||||
if (other.conditionGamemode != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionGamemode.equals(other.conditionGamemode))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionGamestage == null)
|
}
|
||||||
|
if (!Objects.equals(this.renderNameBlock, other.renderNameBlock))
|
||||||
{
|
{
|
||||||
if (other.conditionGamestage != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionGamestage.equals(other.conditionGamestage))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionPosition == null)
|
}
|
||||||
|
if (!Objects.equals(this.renderNameEntity, other.renderNameEntity))
|
||||||
{
|
{
|
||||||
if (other.conditionPosition != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionPosition.equals(other.conditionPosition))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionScoreboard == null)
|
}
|
||||||
|
if (this.renderRightArm != other.renderRightArm)
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(this.renderRotation, other.renderRotation))
|
||||||
{
|
{
|
||||||
if (other.conditionScoreboard != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!conditionScoreboard.equals(other.conditionScoreboard))
|
|
||||||
return false;
|
return false;
|
||||||
if (conditionXp == null)
|
}
|
||||||
|
if (!Objects.equals(this.renderRotationLeftArm, other.renderRotationLeftArm))
|
||||||
{
|
{
|
||||||
if (other.conditionXp != null)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else if (!conditionXp.equals(other.conditionXp))
|
if (!Objects.equals(this.renderRotationRightArm, other.renderRotationRightArm))
|
||||||
return false;
|
|
||||||
if (isBlock != other.isBlock)
|
|
||||||
return false;
|
|
||||||
if (isEntity != other.isEntity)
|
|
||||||
return false;
|
|
||||||
if (resourceLocation == null)
|
|
||||||
{
|
{
|
||||||
if (other.resourceLocation != null)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else if (!resourceLocation.equals(other.resourceLocation))
|
if (!Objects.equals(this.renderscaled, other.renderscaled))
|
||||||
return false;
|
|
||||||
if (renderLeftArm != other.renderLeftArm)
|
|
||||||
return false;
|
|
||||||
if (renderNBT == null)
|
|
||||||
{
|
{
|
||||||
if (other.renderNBT != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderNBT.equals(other.renderNBT))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderNameBlock == null)
|
}
|
||||||
|
if (!Objects.equals(this.renderTranslation, other.renderTranslation))
|
||||||
{
|
{
|
||||||
if (other.renderNameBlock != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderNameBlock.equals(other.renderNameBlock))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderNameEntity == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeBlockTag, other.typeBlockTag))
|
||||||
{
|
{
|
||||||
if (other.renderNameEntity != null)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else if (!renderNameEntity.equals(other.renderNameEntity))
|
if (!Objects.equals(this.typeEntityTag, other.typeEntityTag))
|
||||||
return false;
|
|
||||||
if (renderRightArm != other.renderRightArm)
|
|
||||||
return false;
|
|
||||||
if (renderRotation == null)
|
|
||||||
{
|
{
|
||||||
if (other.renderRotation != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderRotation.equals(other.renderRotation))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderRotationLeftArm == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeHardness, other.typeHardness))
|
||||||
{
|
{
|
||||||
if (other.renderRotationLeftArm != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderRotationLeftArm.equals(other.renderRotationLeftArm))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderRotationRightArm == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeHealth, other.typeHealth))
|
||||||
{
|
{
|
||||||
if (other.renderRotationRightArm != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderRotationRightArm.equals(other.renderRotationRightArm))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderscaled == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeHeight, other.typeHeight))
|
||||||
{
|
{
|
||||||
if (other.renderscaled != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderscaled.equals(other.renderscaled))
|
|
||||||
return false;
|
return false;
|
||||||
if (renderTranslation == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeMaterial, other.typeMaterial))
|
||||||
{
|
{
|
||||||
if (other.renderTranslation != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!renderTranslation.equals(other.renderTranslation))
|
|
||||||
return false;
|
return false;
|
||||||
if (typeBlockTag == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeNameBlock, other.typeNameBlock))
|
||||||
{
|
{
|
||||||
if (other.typeBlockTag != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!typeBlockTag.equals(other.typeBlockTag))
|
|
||||||
return false;
|
return false;
|
||||||
if (typeEntityTag == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeNameEntity, other.typeNameEntity))
|
||||||
{
|
{
|
||||||
if (other.typeEntityTag != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!typeEntityTag.equals(other.typeEntityTag))
|
|
||||||
return false;
|
return false;
|
||||||
if (typeHardness == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeResistance, other.typeResistance))
|
||||||
{
|
{
|
||||||
if (other.typeHardness != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!typeHardness.equals(other.typeHardness))
|
|
||||||
return false;
|
return false;
|
||||||
if (typeHealth == null)
|
}
|
||||||
|
if (!Objects.equals(this.typeWidth, other.typeWidth))
|
||||||
{
|
{
|
||||||
if (other.typeHealth != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!typeHealth.equals(other.typeHealth))
|
|
||||||
return false;
|
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 (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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlock()
|
public boolean isBlock()
|
||||||
{
|
{
|
||||||
return isBlock;
|
return this.isBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(boolean isBlock)
|
public void setBlock(boolean isBlock)
|
||||||
|
|
@ -542,7 +430,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public boolean isEntity()
|
public boolean isEntity()
|
||||||
{
|
{
|
||||||
return isEntity;
|
return this.isEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntity(boolean isEntity)
|
public void setEntity(boolean isEntity)
|
||||||
|
|
@ -552,112 +440,112 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public CompoundTag getTypeBlockTag()
|
public CompoundTag getTypeBlockTag()
|
||||||
{
|
{
|
||||||
return typeBlockTag;
|
return this.typeBlockTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeNameBlock()
|
public String getTypeNameBlock()
|
||||||
{
|
{
|
||||||
return typeNameBlock;
|
return this.typeNameBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeMaterial()
|
public String getTypeMaterial()
|
||||||
{
|
{
|
||||||
return typeMaterial;
|
return this.typeMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeHardness()
|
public String getTypeHardness()
|
||||||
{
|
{
|
||||||
return typeHardness;
|
return this.typeHardness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeResistance()
|
public String getTypeResistance()
|
||||||
{
|
{
|
||||||
return typeResistance;
|
return this.typeResistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getTypeEntityTag()
|
public CompoundTag getTypeEntityTag()
|
||||||
{
|
{
|
||||||
return typeEntityTag;
|
return this.typeEntityTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeNameEntity()
|
public String getTypeNameEntity()
|
||||||
{
|
{
|
||||||
return typeNameEntity;
|
return this.typeNameEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeHeight()
|
public String getTypeHeight()
|
||||||
{
|
{
|
||||||
return typeHeight;
|
return this.typeHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeWidth()
|
public String getTypeWidth()
|
||||||
{
|
{
|
||||||
return typeWidth;
|
return this.typeWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeHealth()
|
public String getTypeHealth()
|
||||||
{
|
{
|
||||||
return typeHealth;
|
return this.typeHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionGamestage()
|
public String getConditionGamestage()
|
||||||
{
|
{
|
||||||
return conditionGamestage;
|
return this.conditionGamestage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionAchievement()
|
public String getConditionAchievement()
|
||||||
{
|
{
|
||||||
return conditionAchievement;
|
return this.conditionAchievement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionXp()
|
public String getConditionXp()
|
||||||
{
|
{
|
||||||
return conditionXp;
|
return this.conditionXp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionGamemode()
|
public String getConditionGamemode()
|
||||||
{
|
{
|
||||||
return conditionGamemode;
|
return this.conditionGamemode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionScoreboard()
|
public String getConditionScoreboard()
|
||||||
{
|
{
|
||||||
return conditionScoreboard;
|
return this.conditionScoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConditionPosition()
|
public String getConditionPosition()
|
||||||
{
|
{
|
||||||
return conditionPosition;
|
return this.conditionPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderNameBlock()
|
public String getRenderNameBlock()
|
||||||
{
|
{
|
||||||
return renderNameBlock;
|
return this.renderNameBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderNameEntity()
|
public String getRenderNameEntity()
|
||||||
{
|
{
|
||||||
return renderNameEntity;
|
return this.renderNameEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getRenderNBT()
|
public CompoundTag getRenderNBT()
|
||||||
{
|
{
|
||||||
return renderNBT;
|
return this.renderNBT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderTranslation()
|
public String getRenderTranslation()
|
||||||
{
|
{
|
||||||
return renderTranslation;
|
return this.renderTranslation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderRotation()
|
public String getRenderRotation()
|
||||||
{
|
{
|
||||||
return renderRotation;
|
return this.renderRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderScaled()
|
public String getRenderScaled()
|
||||||
{
|
{
|
||||||
return renderscaled;
|
return this.renderscaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeBlockTag(CompoundTag typeBlockTag)
|
public void setTypeBlockTag(CompoundTag typeBlockTag)
|
||||||
|
|
@ -772,7 +660,7 @@ public class CarryOnOverride
|
||||||
|
|
||||||
public String getCommandPlace()
|
public String getCommandPlace()
|
||||||
{
|
{
|
||||||
return commandPlace;
|
return this.commandPlace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommandPlace(String commandPlace)
|
public void setCommandPlace(String commandPlace)
|
||||||
|
|
@ -783,48 +671,48 @@ public class CarryOnOverride
|
||||||
public void serialize(FriendlyByteBuf buf)
|
public void serialize(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
// BLOCKS
|
// BLOCKS
|
||||||
buf.writeNbt(typeBlockTag);
|
buf.writeNbt(this.typeBlockTag);
|
||||||
buf.writeUtf(typeNameBlock);
|
buf.writeUtf(this.typeNameBlock);
|
||||||
buf.writeUtf(typeMaterial);
|
buf.writeUtf(this.typeMaterial);
|
||||||
buf.writeUtf(typeHardness);
|
buf.writeUtf(this.typeHardness);
|
||||||
buf.writeUtf(typeResistance);
|
buf.writeUtf(this.typeResistance);
|
||||||
|
|
||||||
// ENTITIES
|
// ENTITIES
|
||||||
buf.writeNbt(typeEntityTag);
|
buf.writeNbt(this.typeEntityTag);
|
||||||
buf.writeUtf(typeNameEntity);
|
buf.writeUtf(this.typeNameEntity);
|
||||||
buf.writeUtf(typeHeight);
|
buf.writeUtf(this.typeHeight);
|
||||||
buf.writeUtf(typeWidth);
|
buf.writeUtf(this.typeWidth);
|
||||||
buf.writeUtf(typeHealth);
|
buf.writeUtf(this.typeHealth);
|
||||||
|
|
||||||
// CONDITIONS
|
// CONDITIONS
|
||||||
buf.writeUtf(conditionGamestage);
|
buf.writeUtf(this.conditionGamestage);
|
||||||
buf.writeUtf(conditionAchievement);
|
buf.writeUtf(this.conditionAchievement);
|
||||||
buf.writeUtf(conditionXp);
|
buf.writeUtf(this.conditionXp);
|
||||||
buf.writeUtf(conditionGamemode);
|
buf.writeUtf(this.conditionGamemode);
|
||||||
buf.writeUtf(conditionScoreboard);
|
buf.writeUtf(this.conditionScoreboard);
|
||||||
buf.writeUtf(conditionPosition);
|
buf.writeUtf(this.conditionPosition);
|
||||||
buf.writeUtf(conditionEffects);
|
buf.writeUtf(this.conditionEffects);
|
||||||
|
|
||||||
// RENDER
|
// RENDER
|
||||||
buf.writeUtf(renderNameBlock);
|
buf.writeUtf(this.renderNameBlock);
|
||||||
buf.writeUtf(renderNameEntity);
|
buf.writeUtf(this.renderNameEntity);
|
||||||
buf.writeNbt(renderNBT);
|
buf.writeNbt(this.renderNBT);
|
||||||
buf.writeUtf(renderTranslation);
|
buf.writeUtf(this.renderTranslation);
|
||||||
buf.writeUtf(renderRotation);
|
buf.writeUtf(this.renderRotation);
|
||||||
buf.writeUtf(renderscaled);
|
buf.writeUtf(this.renderscaled);
|
||||||
buf.writeUtf(renderRotationLeftArm);
|
buf.writeUtf(this.renderRotationLeftArm);
|
||||||
buf.writeUtf(renderRotationRightArm);
|
buf.writeUtf(this.renderRotationRightArm);
|
||||||
buf.writeBoolean(renderLeftArm);
|
buf.writeBoolean(this.renderLeftArm);
|
||||||
buf.writeBoolean(renderRightArm);
|
buf.writeBoolean(this.renderRightArm);
|
||||||
|
|
||||||
// EFFECTS
|
// EFFECTS
|
||||||
buf.writeUtf(commandInit);
|
buf.writeUtf(this.commandInit);
|
||||||
buf.writeUtf(commandLoop);
|
buf.writeUtf(this.commandLoop);
|
||||||
buf.writeUtf(commandPlace);
|
buf.writeUtf(this.commandPlace);
|
||||||
|
|
||||||
buf.writeBoolean(isBlock);
|
buf.writeBoolean(this.isBlock);
|
||||||
buf.writeBoolean(isEntity);
|
buf.writeBoolean(this.isEntity);
|
||||||
buf.writeUtf(resourceLocation);
|
buf.writeUtf(this.resourceLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CarryOnOverride deserialize(FriendlyByteBuf buf)
|
public static CarryOnOverride deserialize(FriendlyByteBuf buf)
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,8 @@ public class ScriptChecker
|
||||||
{
|
{
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||||
{
|
{
|
||||||
if (override.isBlock())
|
if (override.isBlock() && matchesAll(override, block, material, hardness, resistance, nbt))
|
||||||
{
|
return override;
|
||||||
if (matchesAll(override, block, material, hardness, resistance, nbt))
|
|
||||||
return override;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,18 +64,14 @@ public class ScriptChecker
|
||||||
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
||||||
CompoundTag tag = entity.serializeNBT();
|
CompoundTag tag = entity.serializeNBT();
|
||||||
|
|
||||||
|
|
||||||
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||||
|
|
||||||
if (isAllowed)
|
if (isAllowed)
|
||||||
{
|
{
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
for (CarryOnOverride override : ScriptReader.OVERRIDES.values())
|
||||||
{
|
{
|
||||||
if (override.isEntity())
|
if (override.isEntity() && matchesAll(override, name, height, width, health, tag))
|
||||||
{
|
return override;
|
||||||
if (matchesAll(override, name, height, width, health, tag))
|
|
||||||
return override;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +86,7 @@ public class ScriptChecker
|
||||||
boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth());
|
boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth());
|
||||||
boolean matchnbt = ScriptParseHelper.matches(tag, override.getTypeEntityTag());
|
boolean matchnbt = ScriptParseHelper.matches(tag, override.getTypeEntityTag());
|
||||||
|
|
||||||
return (matchname && matchheight && matchwidth && matchhealth && matchnbt);
|
return matchname && matchheight && matchwidth && matchhealth && matchnbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean matchesAll(CarryOnOverride override, Block block, Material material, float hardness, float resistance, CompoundTag nbt)
|
public static boolean matchesAll(CarryOnOverride override, Block block, Material material, float hardness, float resistance, CompoundTag nbt)
|
||||||
|
|
@ -104,54 +97,51 @@ public class ScriptChecker
|
||||||
boolean matchhardness = ScriptParseHelper.matches(hardness, override.getTypeHardness());
|
boolean matchhardness = ScriptParseHelper.matches(hardness, override.getTypeHardness());
|
||||||
boolean matchresistance = ScriptParseHelper.matches(resistance, override.getTypeResistance());
|
boolean matchresistance = ScriptParseHelper.matches(resistance, override.getTypeResistance());
|
||||||
|
|
||||||
return (matchnbt && matchblock && matchmaterial && matchhardness && matchresistance);
|
return matchnbt && matchblock && matchmaterial && matchhardness && matchresistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean fulfillsConditions(CarryOnOverride override, Player player)
|
public static boolean fulfillsConditions(CarryOnOverride override, Player player)
|
||||||
{
|
{
|
||||||
ServerAdvancementManager manager = ((ServerPlayer) player).server.getAdvancements();
|
ServerAdvancementManager manager = ((ServerPlayer) player).server.getAdvancements();
|
||||||
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()).isEmpty() ? "" : override.getConditionAchievement()));
|
Advancement adv = manager.getAdvancement(new ResourceLocation(override.getConditionAchievement().isEmpty() ? "" : override.getConditionAchievement()));
|
||||||
|
|
||||||
boolean achievement = adv == null ? true : ((ServerPlayer) player).getAdvancements().getOrStartProgress(adv).isDone();
|
boolean achievement = adv == null ? true : ((ServerPlayer) player).getAdvancements().getOrStartProgress(adv).isDone();
|
||||||
boolean gamemode = ScriptParseHelper.matches(((ServerPlayer) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
boolean gamemode = ScriptParseHelper.matches(((ServerPlayer) player).gameMode.getGameModeForPlayer().getId(), override.getConditionGamemode());
|
||||||
boolean gamestage = true;
|
boolean gamestage = true;
|
||||||
if (ModList.get().isLoaded("gamestages"))
|
if (ModList.get().isLoaded("gamestages") && !override.getConditionGamestage().isEmpty())
|
||||||
{
|
{
|
||||||
if (!override.getConditionGamestage().isEmpty())
|
try
|
||||||
|
{
|
||||||
|
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
||||||
|
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
||||||
|
|
||||||
|
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", Player.class);
|
||||||
|
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
||||||
|
|
||||||
|
Object stageData = getPlayerData.invoke(null, player);
|
||||||
|
String condition = override.getConditionGamestage();
|
||||||
|
gamestage = (boolean) hasStage.invoke(stageData, condition);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
||||||
|
|
||||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", Player.class);
|
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", Player.class);
|
||||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
||||||
|
|
||||||
Object stageData = getPlayerData.invoke(null, player);
|
Object stageData = getStageData.invoke(null, player);
|
||||||
String condition = override.getConditionGamestage();
|
String condition = override.getConditionGamestage();
|
||||||
gamestage = (boolean) hasStage.invoke(stageData, condition);
|
gamestage = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
|
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
|
|
||||||
|
|
||||||
Method getStageData = ObfuscationReflectionHelper.findMethod(playerDataHandler, "getStageData", Player.class);
|
|
||||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getStageData.invoke(null, player);
|
|
||||||
String condition = override.getConditionGamestage();
|
|
||||||
gamestage = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean position = ScriptParseHelper.matches(player.blockPosition(), override.getConditionPosition());
|
boolean position = ScriptParseHelper.matches(player.blockPosition(), override.getConditionPosition());
|
||||||
|
|
@ -159,7 +149,7 @@ public class ScriptChecker
|
||||||
boolean scoreboard = ScriptParseHelper.matchesScore(player, override.getConditionScoreboard());
|
boolean scoreboard = ScriptParseHelper.matchesScore(player, override.getConditionScoreboard());
|
||||||
boolean effects = ScriptParseHelper.hasEffects(player, override.getConditionEffects());
|
boolean effects = ScriptParseHelper.hasEffects(player, override.getConditionEffects());
|
||||||
|
|
||||||
return (achievement && gamemode && gamestage && position && xp && scoreboard && effects);
|
return achievement && gamemode && gamestage && position && xp && scoreboard && effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
||||||
|
|
@ -4,184 +4,188 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class ScriptReader
|
public class ScriptReader
|
||||||
{
|
{
|
||||||
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<Integer, CarryOnOverride>();
|
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<>();
|
||||||
|
|
||||||
// public static HashSet<CarryOnOverride> OVERRIDES = new
|
// public static HashSet<CarryOnOverride> OVERRIDES = new
|
||||||
// HashSet<CarryOnOverride>();
|
// HashSet<CarryOnOverride>();
|
||||||
|
|
||||||
// public static void preInit()
|
// public static void preInit()
|
||||||
// {
|
// {
|
||||||
// scripts.clear();
|
// scripts.clear();
|
||||||
//
|
//
|
||||||
// CarryOn.CONFIGURATION_FILE = new File(FMLPaths.CONFIGDIR.get().toString(), "/carryon-scripts/");
|
// CarryOn.CONFIGURATION_FILE = new
|
||||||
//
|
// File(FMLPaths.CONFIGDIR.get().toString(), "/carryon-scripts/");
|
||||||
// if (!CarryOn.CONFIGURATION_FILE.exists())
|
//
|
||||||
// CarryOn.CONFIGURATION_FILE.mkdir();
|
// if (!CarryOn.CONFIGURATION_FILE.exists())
|
||||||
//
|
// CarryOn.CONFIGURATION_FILE.mkdir();
|
||||||
// for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
//
|
||||||
// {
|
// for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
||||||
// if (file.getName().endsWith(".json"))
|
// {
|
||||||
// scripts.add(file);
|
// if (file.getName().endsWith(".json"))
|
||||||
// }
|
// scripts.add(file);
|
||||||
//
|
// }
|
||||||
// }
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
// public static void parseScripts()
|
// public static void parseScripts()
|
||||||
// {
|
// {
|
||||||
// OVERRIDES.clear();
|
// OVERRIDES.clear();
|
||||||
//
|
//
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// if (!Settings.useScripts.get())
|
// if (!Settings.useScripts.get())
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// for (File file : scripts)
|
// for (File file : scripts)
|
||||||
// {
|
// {
|
||||||
// boolean errored = false;
|
// boolean errored = false;
|
||||||
// JsonParser parser = new JsonParser();
|
// JsonParser parser = new JsonParser();
|
||||||
// JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
// JsonObject json = (JsonObject) parser.parse(new
|
||||||
//
|
// FileReader(file.getAbsolutePath()));
|
||||||
// JsonObject object = (JsonObject) json.get("object");
|
//
|
||||||
// JsonObject conditions = (JsonObject) json.get("conditions");
|
// JsonObject object = (JsonObject) json.get("object");
|
||||||
// JsonObject render = (JsonObject) json.get("render");
|
// JsonObject conditions = (JsonObject) json.get("conditions");
|
||||||
// JsonObject effects = (JsonObject) json.get("effects");
|
// JsonObject render = (JsonObject) json.get("render");
|
||||||
//
|
// JsonObject effects = (JsonObject) json.get("effects");
|
||||||
// if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
//
|
||||||
// {
|
// if ((object != null && conditions != null) || (object != null && render
|
||||||
// JsonObject block = (JsonObject) object.get("block");
|
// != null) || (object != null && effects != null))
|
||||||
// JsonObject entity = (JsonObject) object.get("entity");
|
// {
|
||||||
//
|
// JsonObject block = (JsonObject) object.get("block");
|
||||||
// if ((block == null && entity == null) || (block != null && entity != null))
|
// JsonObject entity = (JsonObject) object.get("entity");
|
||||||
// errored = true;
|
//
|
||||||
//
|
// if ((block == null && entity == null) || (block != null && entity !=
|
||||||
// if (!errored)
|
// null))
|
||||||
// {
|
// errored = true;
|
||||||
// CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
//
|
||||||
//
|
// if (!errored)
|
||||||
// if (block != null)
|
// {
|
||||||
// {
|
// CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
||||||
// override.setBlock(true);
|
//
|
||||||
// JsonElement name = block.get("name");
|
// if (block != null)
|
||||||
// JsonElement material = block.get("material");
|
// {
|
||||||
// JsonElement hardness = block.get("hardness");
|
// override.setBlock(true);
|
||||||
// JsonElement resistance = block.get("resistance");
|
// JsonElement name = block.get("name");
|
||||||
// JsonObject nbt = (JsonObject) block.get("nbt");
|
// JsonElement material = block.get("material");
|
||||||
//
|
// JsonElement hardness = block.get("hardness");
|
||||||
// if (name != null)
|
// JsonElement resistance = block.get("resistance");
|
||||||
// override.setTypeNameBlock(name.getAsString());
|
// JsonObject nbt = (JsonObject) block.get("nbt");
|
||||||
// if (material != null)
|
//
|
||||||
// override.setTypeMaterial(material.getAsString());
|
// if (name != null)
|
||||||
// if (hardness != null)
|
// override.setTypeNameBlock(name.getAsString());
|
||||||
// override.setTypeHardness(hardness.getAsString());
|
// if (material != null)
|
||||||
// if (resistance != null)
|
// override.setTypeMaterial(material.getAsString());
|
||||||
// override.setTypeResistance(resistance.getAsString());
|
// if (hardness != null)
|
||||||
// if (nbt != null)
|
// override.setTypeHardness(hardness.getAsString());
|
||||||
// override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
// if (resistance != null)
|
||||||
// } else
|
// override.setTypeResistance(resistance.getAsString());
|
||||||
// {
|
// if (nbt != null)
|
||||||
// override.setEntity(true);
|
// override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
// JsonElement name = entity.get("name");
|
// } else
|
||||||
// JsonElement health = entity.get("health");
|
// {
|
||||||
// JsonElement height = entity.get("height");
|
// override.setEntity(true);
|
||||||
// JsonElement width = entity.get("width");
|
// JsonElement name = entity.get("name");
|
||||||
// JsonObject nbt = (JsonObject) entity.get("nbt");
|
// JsonElement health = entity.get("health");
|
||||||
//
|
// JsonElement height = entity.get("height");
|
||||||
// if (name != null)
|
// JsonElement width = entity.get("width");
|
||||||
// override.setTypeNameEntity(name.getAsString());
|
// JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||||
// if (health != null)
|
//
|
||||||
// override.setTypeHealth(health.getAsString());
|
// if (name != null)
|
||||||
// if (height != null)
|
// override.setTypeNameEntity(name.getAsString());
|
||||||
// override.setTypeHeight(height.getAsString());
|
// if (health != null)
|
||||||
// if (width != null)
|
// override.setTypeHealth(health.getAsString());
|
||||||
// override.setTypeWidth(width.getAsString());
|
// if (height != null)
|
||||||
// if (nbt != null)
|
// override.setTypeHeight(height.getAsString());
|
||||||
// override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
// if (width != null)
|
||||||
// }
|
// override.setTypeWidth(width.getAsString());
|
||||||
//
|
// if (nbt != null)
|
||||||
// if (conditions != null)
|
// override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
// {
|
// }
|
||||||
// JsonElement gamestage = conditions.get("gamestage");
|
//
|
||||||
// JsonElement achievement = conditions.get("advancement");
|
// if (conditions != null)
|
||||||
// JsonElement xp = conditions.get("xp");
|
// {
|
||||||
// JsonElement gamemode = conditions.get("gamemode");
|
// JsonElement gamestage = conditions.get("gamestage");
|
||||||
// JsonElement scoreboard = conditions.get("scoreboard");
|
// JsonElement achievement = conditions.get("advancement");
|
||||||
// JsonElement position = conditions.get("position");
|
// JsonElement xp = conditions.get("xp");
|
||||||
// JsonElement potionEffects = conditions.get("effects");
|
// JsonElement gamemode = conditions.get("gamemode");
|
||||||
//
|
// JsonElement scoreboard = conditions.get("scoreboard");
|
||||||
// if (gamestage != null)
|
// JsonElement position = conditions.get("position");
|
||||||
// override.setConditionGamestage(gamestage.getAsString());
|
// JsonElement potionEffects = conditions.get("effects");
|
||||||
// if (achievement != null)
|
//
|
||||||
// override.setConditionAchievement(achievement.getAsString());
|
// if (gamestage != null)
|
||||||
// if (xp != null)
|
// override.setConditionGamestage(gamestage.getAsString());
|
||||||
// override.setConditionXp(xp.getAsString());
|
// if (achievement != null)
|
||||||
// if (gamemode != null)
|
// override.setConditionAchievement(achievement.getAsString());
|
||||||
// override.setConditionGamemode(gamemode.getAsString());
|
// if (xp != null)
|
||||||
// if (scoreboard != null)
|
// override.setConditionXp(xp.getAsString());
|
||||||
// override.setConditionScoreboard(scoreboard.getAsString());
|
// if (gamemode != null)
|
||||||
// if (position != null)
|
// override.setConditionGamemode(gamemode.getAsString());
|
||||||
// override.setConditionPosition(position.getAsString());
|
// if (scoreboard != null)
|
||||||
// if (potionEffects != null)
|
// override.setConditionScoreboard(scoreboard.getAsString());
|
||||||
// override.setConditionEffects(potionEffects.getAsString());
|
// if (position != null)
|
||||||
// }
|
// override.setConditionPosition(position.getAsString());
|
||||||
//
|
// if (potionEffects != null)
|
||||||
// if (render != null)
|
// override.setConditionEffects(potionEffects.getAsString());
|
||||||
// {
|
// }
|
||||||
// JsonElement name_block = render.get("name_block");
|
//
|
||||||
// JsonElement name_entity = render.get("name_entity");
|
// if (render != null)
|
||||||
// JsonObject nbt = (JsonObject) render.get("nbt");
|
// {
|
||||||
// JsonElement translation = render.get("translation");
|
// JsonElement name_block = render.get("name_block");
|
||||||
// JsonElement rotation = render.get("rotation");
|
// JsonElement name_entity = render.get("name_entity");
|
||||||
// JsonElement scaled = render.get("scale");
|
// JsonObject nbt = (JsonObject) render.get("nbt");
|
||||||
// JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
// JsonElement translation = render.get("translation");
|
||||||
// JsonElement rotationRightArm = render.get("rotation_right_arm");
|
// JsonElement rotation = render.get("rotation");
|
||||||
// JsonElement renderLeftArm = render.get("render_left_arm");
|
// JsonElement scaled = render.get("scale");
|
||||||
// JsonElement renderRightArm = render.get("render_right_arm");
|
// JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||||
//
|
// JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||||
// if (name_block != null)
|
// JsonElement renderLeftArm = render.get("render_left_arm");
|
||||||
// override.setRenderNameBlock(name_block.getAsString());
|
// JsonElement renderRightArm = render.get("render_right_arm");
|
||||||
// if (name_entity != null)
|
//
|
||||||
// override.setRenderNameEntity(name_entity.getAsString());
|
// if (name_block != null)
|
||||||
// if (translation != null)
|
// override.setRenderNameBlock(name_block.getAsString());
|
||||||
// override.setRenderTranslation(translation.getAsString());
|
// if (name_entity != null)
|
||||||
// if (rotation != null)
|
// override.setRenderNameEntity(name_entity.getAsString());
|
||||||
// override.setRenderRotation(rotation.getAsString());
|
// if (translation != null)
|
||||||
// if (scaled != null)
|
// override.setRenderTranslation(translation.getAsString());
|
||||||
// override.setRenderscaled(scaled.getAsString());
|
// if (rotation != null)
|
||||||
// if (nbt != null)
|
// override.setRenderRotation(rotation.getAsString());
|
||||||
// override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
// if (scaled != null)
|
||||||
// if (rotationLeftArm != null)
|
// override.setRenderscaled(scaled.getAsString());
|
||||||
// override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
// if (nbt != null)
|
||||||
// if (rotationRightArm != null)
|
// override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
// override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
// if (rotationLeftArm != null)
|
||||||
// if (renderLeftArm != null)
|
// override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||||
// override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
// if (rotationRightArm != null)
|
||||||
// if (renderRightArm != null)
|
// override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||||
// override.setRenderRightArm(renderRightArm.getAsBoolean());
|
// if (renderLeftArm != null)
|
||||||
// }
|
// override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||||
//
|
// if (renderRightArm != null)
|
||||||
// if (effects != null)
|
// override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||||
// {
|
// }
|
||||||
// JsonElement commandInit = effects.get("commandPickup");
|
//
|
||||||
// JsonElement commandLoop = effects.get("commandLoop");
|
// if (effects != null)
|
||||||
// JsonElement commandPlace = effects.get("commandPlace");
|
// {
|
||||||
//
|
// JsonElement commandInit = effects.get("commandPickup");
|
||||||
// if (commandInit != null)
|
// JsonElement commandLoop = effects.get("commandLoop");
|
||||||
// override.setCommandInit(commandInit.getAsString());
|
// JsonElement commandPlace = effects.get("commandPlace");
|
||||||
// if (commandLoop != null)
|
//
|
||||||
// override.setCommandLoop(commandLoop.getAsString());
|
// if (commandInit != null)
|
||||||
// if (commandPlace != null)
|
// override.setCommandInit(commandInit.getAsString());
|
||||||
// override.setCommandPlace(commandPlace.getAsString());
|
// if (commandLoop != null)
|
||||||
// }
|
// override.setCommandLoop(commandLoop.getAsString());
|
||||||
//
|
// if (commandPlace != null)
|
||||||
// OVERRIDES.put(override.hashCode(), override);
|
// override.setCommandPlace(commandPlace.getAsString());
|
||||||
// }
|
// }
|
||||||
// }
|
//
|
||||||
// }
|
// OVERRIDES.put(override.hashCode(), override);
|
||||||
//
|
// }
|
||||||
// System.out.println("Successfully parsed scripts!");
|
// }
|
||||||
// } catch (Exception e)
|
// }
|
||||||
// {
|
//
|
||||||
// CarryOn.LOGGER.error(e);
|
// System.out.println("Successfully parsed scripts!");
|
||||||
// }
|
// } catch (Exception e)
|
||||||
// }
|
// {
|
||||||
|
// CarryOn.LOGGER.error(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.FORGE)
|
@EventBusSubscriber(modid = CarryOn.MODID, bus = Bus.FORGE)
|
||||||
public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||||
{
|
{
|
||||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
public ScriptReloadListener()
|
public ScriptReloadListener()
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +37,7 @@ public class ScriptReloadListener extends SimpleJsonResourceReloadListener
|
||||||
|
|
||||||
objects.forEach((path, jsonElem) -> {
|
objects.forEach((path, jsonElem) -> {
|
||||||
CarryOnOverride override = new CarryOnOverride(jsonElem, path);
|
CarryOnOverride override = new CarryOnOverride(jsonElem, path);
|
||||||
if(!override.isInvalid)
|
if (!override.isInvalid)
|
||||||
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,100 +1,125 @@
|
||||||
//package tschipp.carryon.compat.obfuscate;
|
// package tschipp.carryon.compat.obfuscate;
|
||||||
//
|
//
|
||||||
//import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
// import com.mrcrayfish.obfuscate.client.event.PlayerModelEvent;
|
||||||
//
|
//
|
||||||
//import net.minecraft.client.model.PlayerModel;
|
// import net.minecraft.client.model.PlayerModel;
|
||||||
//import net.minecraft.client.renderer.model.ModelRenderer;
|
// import net.minecraft.client.renderer.model.ModelRenderer;
|
||||||
//import net.minecraft.entity.player.PlayerEntity;
|
// import net.minecraft.entity.player.PlayerEntity;
|
||||||
//import net.minecraft.world.item.ItemStack;
|
// import net.minecraft.world.item.ItemStack;
|
||||||
//import net.minecraftforge.api.distmarker.Dist;
|
// import net.minecraftforge.api.distmarker.Dist;
|
||||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
// import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
//import net.minecraftforge.eventbus.api.SubscribeEvent;
|
// import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
//import tschipp.carryon.common.config.Configs.Settings;
|
// import tschipp.carryon.common.config.Configs.Settings;
|
||||||
//import tschipp.carryon.common.handler.RegistrationHandler;
|
// import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
//import tschipp.carryon.common.helper.ScriptParseHelper;
|
// import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
//import tschipp.carryon.common.item.ItemCarryonBlock;
|
// import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||||
//import tschipp.carryon.common.item.ItemCarryonEntity;
|
// import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||||
//import tschipp.carryon.common.scripting.CarryOnOverride;
|
// import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
//import tschipp.carryon.common.scripting.ScriptChecker;
|
// import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
//
|
//
|
||||||
//public class ObfuscateEvents
|
// public class ObfuscateEvents
|
||||||
//{
|
// {
|
||||||
//
|
//
|
||||||
// @SubscribeEvent
|
// @SubscribeEvent
|
||||||
// public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
// public void preModelPlayerEvent(PlayerModelEvent.SetupAngles.Post event)
|
||||||
// {
|
// {
|
||||||
// if(!Settings.renderArms.get())
|
// if(!Settings.renderArms.get())
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// PlayerEntity player = event.getPlayer();
|
// PlayerEntity player = event.getPlayer();
|
||||||
//
|
//
|
||||||
// Pose pose = player.getPose();
|
// Pose pose = player.getPose();
|
||||||
// if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
// if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||||
// return;
|
// return;
|
||||||
//
|
//
|
||||||
// PlayerModel<?> model = event.getModelPlayer();
|
// PlayerModel<?> model = event.getModelPlayer();
|
||||||
// ItemStack stack = player.getMainHandItem();
|
// ItemStack stack = player.getMainHandItem();
|
||||||
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
// if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile &&
|
||||||
// {
|
// ItemCarryonBlock.hasTileData(stack) || stack.getItem() ==
|
||||||
|
// RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
|
// {
|
||||||
//
|
//
|
||||||
// float rotation = 0;
|
// float rotation = 0;
|
||||||
//
|
//
|
||||||
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
// CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||||
// if (overrider != null)
|
// if (overrider != null)
|
||||||
// {
|
// {
|
||||||
// float[] rotLeft = null;
|
// float[] rotLeft = null;
|
||||||
// float[] rotRight = null;
|
// float[] rotRight = null;
|
||||||
// if (overrider.getRenderRotationLeftArm() != null)
|
// if (overrider.getRenderRotationLeftArm() != null)
|
||||||
// rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
// rotLeft =
|
||||||
// if (overrider.getRenderRotationRightArm() != null)
|
// ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||||
// rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
// if (overrider.getRenderRotationRightArm() != null)
|
||||||
|
// rotRight =
|
||||||
|
// ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||||
//
|
//
|
||||||
// boolean renderRight = overrider.isRenderRightArm();
|
// boolean renderRight = overrider.isRenderRightArm();
|
||||||
// boolean renderLeft = overrider.isRenderLeftArm();
|
// boolean renderLeft = overrider.isRenderLeftArm();
|
||||||
//
|
//
|
||||||
// if (renderLeft && rotLeft != null)
|
// if (renderLeft && rotLeft != null)
|
||||||
// {
|
// {
|
||||||
// renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
// renderArmPre(model.leftArm, (float) rotLeft[0], (float) rotLeft[2],
|
||||||
// renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
// rotation);
|
||||||
// }
|
// renderArmPre(model.leftSleeve, (float) rotLeft[0], (float) rotLeft[2],
|
||||||
// else if (renderLeft)
|
// rotation);
|
||||||
// {
|
// }
|
||||||
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// else if (renderLeft)
|
||||||
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// {
|
||||||
// }
|
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
|
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// if (renderRight && rotRight != null)
|
// if (renderRight && rotRight != null)
|
||||||
// {
|
// {
|
||||||
// renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
// renderArmPre(model.rightArm, (float) rotRight[0], (float) rotRight[2],
|
||||||
// renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2], rotation);
|
// rotation);
|
||||||
// }
|
// renderArmPre(model.rightSleeve, (float) rotRight[0], (float) rotRight[2],
|
||||||
// else if (renderRight)
|
// rotation);
|
||||||
// {
|
// }
|
||||||
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// else if (renderRight)
|
||||||
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// {
|
||||||
// }
|
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
|
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f)
|
||||||
|
// - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// renderArmPre(model.rightArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
// renderArmPre(model.rightSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f)
|
||||||
// }
|
// - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||||
|
// renderArmPre(model.leftArm, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
|
// renderArmPre(model.leftSleeve, 0.8F + (player.isShiftKeyDown() ? 0.2f : 0f) -
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0),
|
||||||
|
// (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// @OnlyIn(Dist.CLIENT)
|
// @OnlyIn(Dist.CLIENT)
|
||||||
// private void renderArmPre(ModelRenderer arm, float x, float z, float rotation)
|
// private void renderArmPre(ModelRenderer arm, float x, float z, float
|
||||||
// {
|
// rotation)
|
||||||
// arm.xRot = (float) -x;
|
// {
|
||||||
// arm.yRot = (float) -Math.toRadians(rotation);
|
// arm.xRot = (float) -x;
|
||||||
// arm.zRot = (float) z;
|
// arm.yRot = (float) -Math.toRadians(rotation);
|
||||||
// }
|
// arm.zRot = (float) z;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//}
|
// }
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@ public class CarrySlotPacket
|
||||||
|
|
||||||
public void toBytes(ByteBuf buf)
|
public void toBytes(ByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeInt(slot);
|
buf.writeInt(this.slot);
|
||||||
buf.writeInt(carryOverride);
|
buf.writeInt(this.carryOverride);
|
||||||
buf.writeInt(entityid);
|
buf.writeInt(this.entityid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||||
|
|
@ -53,15 +53,13 @@ public class CarrySlotPacket
|
||||||
|
|
||||||
if (world != null)
|
if (world != null)
|
||||||
{
|
{
|
||||||
Entity e = world.getEntity(entityid);
|
Entity e = world.getEntity(this.entityid);
|
||||||
|
|
||||||
if (e != null && e instanceof Player)
|
if (e instanceof Player player)
|
||||||
{
|
{
|
||||||
Player player = (Player) e;
|
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
|
|
||||||
if (slot >= 9)
|
if (this.slot >= 9)
|
||||||
{
|
{
|
||||||
player.getPersistentData().remove("carrySlot");
|
player.getPersistentData().remove("carrySlot");
|
||||||
player.getPersistentData().remove("overrideKey");
|
player.getPersistentData().remove("overrideKey");
|
||||||
|
|
@ -69,9 +67,9 @@ public class CarrySlotPacket
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
player.getPersistentData().putInt("carrySlot", slot);
|
player.getPersistentData().putInt("carrySlot", this.slot);
|
||||||
if (carryOverride != 0)
|
if (this.carryOverride != 0)
|
||||||
ScriptChecker.setCarryOnOverride(player, carryOverride);
|
ScriptChecker.setCarryOnOverride(player, this.carryOverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import tschipp.carryon.common.scripting.ScriptReader;
|
||||||
|
|
||||||
public class ScriptReloadPacket
|
public class ScriptReloadPacket
|
||||||
{
|
{
|
||||||
private List<CarryOnOverride> overrides = new ArrayList<CarryOnOverride>();
|
private List<CarryOnOverride> overrides = new ArrayList<>();
|
||||||
|
|
||||||
public ScriptReloadPacket()
|
public ScriptReloadPacket()
|
||||||
{
|
{
|
||||||
|
|
@ -20,22 +20,22 @@ public class ScriptReloadPacket
|
||||||
|
|
||||||
public ScriptReloadPacket(Collection<CarryOnOverride> collection)
|
public ScriptReloadPacket(Collection<CarryOnOverride> collection)
|
||||||
{
|
{
|
||||||
overrides.addAll(collection);
|
this.overrides.addAll(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptReloadPacket(FriendlyByteBuf buf)
|
public ScriptReloadPacket(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
for(int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
overrides.add(CarryOnOverride.deserialize(buf));
|
this.overrides.add(CarryOnOverride.deserialize(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toBytes(FriendlyByteBuf buf)
|
public void toBytes(FriendlyByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeInt(overrides.size());
|
buf.writeInt(this.overrides.size());
|
||||||
overrides.forEach(override -> override.serialize(buf));
|
this.overrides.forEach(override -> override.serialize(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||||
|
|
@ -46,7 +46,7 @@ public class ScriptReloadPacket
|
||||||
|
|
||||||
ScriptReader.OVERRIDES.clear();
|
ScriptReader.OVERRIDES.clear();
|
||||||
|
|
||||||
overrides.forEach(override -> {
|
this.overrides.forEach(override -> {
|
||||||
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class SyncKeybindPacket
|
||||||
|
|
||||||
public void toBytes(ByteBuf buf)
|
public void toBytes(ByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeBoolean(pressed);
|
buf.writeBoolean(this.pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||||
|
|
@ -34,7 +34,7 @@ public class SyncKeybindPacket
|
||||||
|
|
||||||
ServerPlayer player = ctx.get().getSender();
|
ServerPlayer player = ctx.get().getSender();
|
||||||
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, pressed);
|
CarryOnKeybinds.setKeyPressed(player, this.pressed);
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
import tschipp.carryon.common.helper.KeyboardCallbackWrapper;
|
||||||
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
import tschipp.carryon.common.helper.ScrollCallbackWrapper;
|
||||||
|
|
||||||
public class ClientProxy implements IProxy {
|
public class ClientProxy implements IProxy
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(FMLCommonSetupEvent event)
|
public void setup(FMLCommonSetupEvent event)
|
||||||
|
|
@ -19,7 +19,7 @@ public class ClientProxy implements IProxy {
|
||||||
|
|
||||||
CarryOnKeybinds.init();
|
CarryOnKeybinds.init();
|
||||||
|
|
||||||
new ScrollCallbackWrapper().setup(Minecraft.getInstance());;
|
new ScrollCallbackWrapper().setup(Minecraft.getInstance());
|
||||||
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
new KeyboardCallbackWrapper().setup(Minecraft.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user