Finalized port to 1.16
This commit is contained in:
parent
c8e79860ad
commit
b470478a40
|
|
@ -88,10 +88,17 @@ repositories {
|
||||||
maven {
|
maven {
|
||||||
url "https://maven.blamejared.com/"
|
url "https://maven.blamejared.com/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url "https://maven.mcmoddev.com/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
|
//compileOnly fg.deobf("net.darkhax.gamestages:GameStages-1.16.1:3.1.8")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import tschipp.carryon.common.config.Configs;
|
import tschipp.carryon.common.config.Configs;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.scripting.ScriptReader;
|
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||||
import tschipp.carryon.network.client.ScriptReloadPacket;
|
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
import tschipp.carryon.network.server.SyncKeybindPacket;
|
import tschipp.carryon.network.server.SyncKeybindPacket;
|
||||||
|
|
@ -57,7 +56,7 @@ public class CarryOn
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Configs.SERVER_CONFIG);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Configs.SERVER_CONFIG);
|
||||||
|
|
||||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
||||||
Configs.loadConfig(Configs.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
// Configs.loadConfig(Configs.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
||||||
|
|
||||||
info = ModLoadingContext.get().getActiveContainer().getModInfo();
|
info = ModLoadingContext.get().getActiveContainer().getModInfo();
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +65,6 @@ public class CarryOn
|
||||||
{
|
{
|
||||||
String version = info.getVersion().toString();
|
String version = info.getVersion().toString();
|
||||||
// PreInitevent.
|
// PreInitevent.
|
||||||
ScriptReader.preInit();
|
|
||||||
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> version, version::equals, version::equals);
|
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> version, version::equals, version::equals);
|
||||||
|
|
||||||
// CLIENT PACKETS
|
// CLIENT PACKETS
|
||||||
|
|
@ -79,7 +77,6 @@ public class CarryOn
|
||||||
RegistrationHandler.regCommonEvents();
|
RegistrationHandler.regCommonEvents();
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
ScriptReader.parseScripts();
|
|
||||||
RegistrationHandler.regOverrideList();
|
RegistrationHandler.regOverrideList();
|
||||||
RegistrationHandler.regCaps();
|
RegistrationHandler.regCaps();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ public class RenderEvents
|
||||||
matrix.translate(0, -0.5, -1);
|
matrix.translate(0, -0.5, -1);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
|
|
||||||
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
||||||
{
|
{
|
||||||
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
|
|
@ -271,12 +271,15 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
|
|
||||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
if (!carryOverride.getRenderNameBlock().isEmpty())
|
||||||
if (b != null)
|
|
||||||
{
|
{
|
||||||
ItemStack s = new ItemStack(b, 1);
|
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
if (b != null)
|
||||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
{
|
||||||
|
ItemStack s = new ItemStack(b, 1);
|
||||||
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
|
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,12 +342,15 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
|
|
||||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
if (!carryOverride.getRenderNameBlock().isEmpty())
|
||||||
if (b != null)
|
|
||||||
{
|
{
|
||||||
ItemStack s = new ItemStack(b, 1);
|
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
if (b != null)
|
||||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
{
|
||||||
|
ItemStack s = new ItemStack(b, 1);
|
||||||
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
|
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -524,8 +530,8 @@ public class RenderEvents
|
||||||
Pose pose = player.getPose();
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
applyGeneralTransformations(player, partialticks, matrix);
|
applyGeneralTransformations(player, partialticks, matrix);
|
||||||
|
|
||||||
if(perspective == 2)
|
if (perspective == 2)
|
||||||
matrix.translate(0, -1.6, 0.65);
|
matrix.translate(0, -1.6, 0.65);
|
||||||
else
|
else
|
||||||
matrix.translate(0, -1.6, -0.65);
|
matrix.translate(0, -1.6, -0.65);
|
||||||
|
|
@ -542,7 +548,7 @@ public class RenderEvents
|
||||||
|
|
||||||
if (perspective == 2)
|
if (perspective == 2)
|
||||||
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
|
|
||||||
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||||
matrix.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
matrix.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||||
|
|
||||||
|
|
@ -550,11 +556,11 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
matrix.rotate(Vector3f.XN.rotationDegrees(90));
|
matrix.rotate(Vector3f.XN.rotationDegrees(90));
|
||||||
matrix.translate(0, -0.2 * height, 0);
|
matrix.translate(0, -0.2 * height, 0);
|
||||||
|
|
||||||
if(pose == Pose.FALL_FLYING)
|
if (pose == Pose.FALL_FLYING)
|
||||||
matrix.translate(0, 0 , 0.2);
|
matrix.translate(0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -595,9 +601,9 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
float[] rotLeft = null;
|
float[] rotLeft = null;
|
||||||
float[] rotRight = null;
|
float[] rotRight = null;
|
||||||
if (overrider.getRenderRotationLeftArm() != null)
|
if (!overrider.getRenderRotationLeftArm().isEmpty())
|
||||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||||
if (overrider.getRenderRotationRightArm() != null)
|
if (!overrider.getRenderRotationRightArm().isEmpty())
|
||||||
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||||
|
|
||||||
boolean renderRight = overrider.isRenderRightArm();
|
boolean renderRight = overrider.isRenderRightArm();
|
||||||
|
|
|
||||||
|
|
@ -40,16 +40,19 @@ public class CarryRenderHelper
|
||||||
|
|
||||||
public static void performOverrideTransformation(MatrixStack matrix, CarryOnOverride override)
|
public static void performOverrideTransformation(MatrixStack matrix, CarryOnOverride override)
|
||||||
{
|
{
|
||||||
|
int perspective = getPerspective();
|
||||||
|
|
||||||
float[] translation = ScriptParseHelper.getXYZArray(override.getRenderTranslation());
|
float[] translation = ScriptParseHelper.getXYZArray(override.getRenderTranslation());
|
||||||
float[] rotation = ScriptParseHelper.getXYZArray(override.getRenderRotation());
|
float[] rotation = ScriptParseHelper.getXYZArray(override.getRenderRotation());
|
||||||
float[] scaled = ScriptParseHelper.getScaled(override.getRenderScaled());
|
float[] scaled = ScriptParseHelper.getScaled(override.getRenderScaled());
|
||||||
|
|
||||||
matrix.translate(translation[0], translation[1], translation[2]);
|
|
||||||
Quaternion rot = Vector3f.XP.rotationDegrees(rotation[0]);
|
Quaternion rot = Vector3f.XP.rotationDegrees(rotation[0]);
|
||||||
rot.multiply(Vector3f.YP.rotationDegrees(rotation[1]));
|
rot.multiply(Vector3f.YP.rotationDegrees(rotation[1]));
|
||||||
rot.multiply(Vector3f.ZP.rotationDegrees(rotation[2]));
|
rot.multiply(Vector3f.ZP.rotationDegrees(rotation[2]));
|
||||||
|
|
||||||
matrix.rotate(rot);
|
matrix.rotate(rot);
|
||||||
|
|
||||||
|
matrix.translate(translation[0], translation[1], perspective == 1 && override.isBlock() ? -translation[2] : translation[2]);
|
||||||
|
|
||||||
matrix.scale(scaled[0], scaled[1], scaled[2]);
|
matrix.scale(scaled[0], scaled[1], scaled[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,22 +64,22 @@ public class CarryRenderHelper
|
||||||
|
|
||||||
if (override instanceof ItemStack)
|
if (override instanceof ItemStack)
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model); //Note: I'm not sure what the second to last argument does, but it seems to work like this
|
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPerspective()
|
public static int getPerspective()
|
||||||
{
|
{
|
||||||
boolean isThirdPerson = !Minecraft.getInstance().gameSettings.func_243230_g().func_243192_a();
|
boolean isThirdPerson = !Minecraft.getInstance().gameSettings.func_243230_g().func_243192_a();
|
||||||
boolean isThirdPersonReverse = Minecraft.getInstance().gameSettings.func_243230_g().func_243193_b();
|
boolean isThirdPersonReverse = Minecraft.getInstance().gameSettings.func_243230_g().func_243193_b();
|
||||||
|
|
||||||
if(!isThirdPerson && !isThirdPersonReverse)
|
if (!isThirdPerson && !isThirdPersonReverse)
|
||||||
return 0;
|
return 0;
|
||||||
if(isThirdPerson && !isThirdPersonReverse)
|
if (isThirdPerson && !isThirdPersonReverse)
|
||||||
return 1;
|
return 1;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class PositionProvider implements ICapabilitySerializable<CompoundNBT>
|
||||||
return (LazyOptional<T>) LazyOptional.of(() -> {
|
return (LazyOptional<T>) LazyOptional.of(() -> {
|
||||||
return new TEPosition();
|
return new TEPosition();
|
||||||
});
|
});
|
||||||
return null;
|
return LazyOptional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ public class Configs {
|
||||||
s.comment("Blacklist");
|
s.comment("Blacklist");
|
||||||
|
|
||||||
forbiddenTiles = s
|
forbiddenTiles = s
|
||||||
.comment("Tile Entities that cannot be picked up")
|
.comment("Blocks that cannot be picked up")
|
||||||
.defineList("blacklist.forbiddenTiles", Arrays.asList(new String[]
|
.defineList("blacklist.forbiddenTiles", Arrays.asList(new String[]
|
||||||
{
|
{
|
||||||
"minecraft:end_portal",
|
"minecraft:end_portal",
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ 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;
|
||||||
|
import tschipp.carryon.common.scripting.ScriptReader;
|
||||||
import tschipp.carryon.network.client.CarrySlotPacket;
|
import tschipp.carryon.network.client.CarrySlotPacket;
|
||||||
|
import tschipp.carryon.network.client.ScriptReloadPacket;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = CarryOn.MODID)
|
@EventBusSubscriber(modid = CarryOn.MODID)
|
||||||
public class ItemEvents
|
public class ItemEvents
|
||||||
|
|
@ -85,14 +87,14 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
String command = override.getCommandPlace();
|
String command = override.getCommandPlace();
|
||||||
|
|
||||||
if (command != null)
|
if (command != null && !command.isEmpty())
|
||||||
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
player.getServer().getCommandManager().handleCommand(player.getServer().getCommandSource(), "/execute as " + player.getGameProfile().getName() + " run " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public void onItemDropped(EntityJoinWorldEvent event)
|
public void onItemDropped(EntityJoinWorldEvent event)
|
||||||
{
|
{
|
||||||
|
|
@ -172,6 +174,10 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(event.getPlayer() instanceof ServerPlayerEntity)
|
||||||
|
{
|
||||||
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)event.getPlayer()), new ScriptReloadPacket(ScriptReader.OVERRIDES.values()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package tschipp.carryon.common.handler;
|
package tschipp.carryon.common.handler;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -15,12 +14,13 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
|
import tschipp.carryon.common.helper.CarryonGamestageHelper;
|
||||||
import tschipp.carryon.common.item.ItemCarryonBlock;
|
import tschipp.carryon.common.item.ItemCarryonBlock;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
|
|
@ -60,9 +60,10 @@ public class PickupHandler
|
||||||
|
|
||||||
if ((state.getBlockHardness(world, pos) != -1 || player.isCreative()))
|
if ((state.getBlockHardness(world, pos) != -1 || player.isCreative()))
|
||||||
{
|
{
|
||||||
double distance = pos.distanceSq(player.getPosition());
|
double distance = Vector3d.copy(pos).distanceTo(player.getPositionVec());
|
||||||
|
double maxDist = Settings.maxDistance.get();
|
||||||
if (distance < Math.pow(Settings.maxDistance.get(), 2))
|
|
||||||
|
if (distance < maxDist)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!ItemCarryonBlock.isLocked(pos, world))
|
if (!ItemCarryonBlock.isLocked(pos, world))
|
||||||
|
|
@ -70,44 +71,7 @@ public class PickupHandler
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(state))
|
||||||
{
|
{
|
||||||
try
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(state), player) && handleProtections((ServerPlayerEntity) player, world, pos, state);
|
||||||
{
|
|
||||||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
|
||||||
|
|
||||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", PlayerEntity.class);
|
|
||||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getPlayerData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
|
||||||
boolean has = (boolean) hasStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, world, pos, state);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
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", PlayerEntity.class);
|
|
||||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getStageData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(state);
|
|
||||||
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, world, pos, state);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return handleProtections((ServerPlayerEntity) player, world, pos, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
else if (Settings.pickupAllBlocks.get() ? true : tile != null)
|
||||||
{
|
{
|
||||||
|
|
@ -155,46 +119,10 @@ public class PickupHandler
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
{
|
{
|
||||||
try
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayerEntity) player, toPickUp);
|
||||||
{
|
|
||||||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
|
||||||
|
|
||||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", PlayerEntity.class);
|
|
||||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getPlayerData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
boolean has = (boolean) hasStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
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", PlayerEntity.class);
|
|
||||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getStageData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true && handleProtections((ServerPlayerEntity) player, toPickUp);
|
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,46 +161,10 @@ public class PickupHandler
|
||||||
|
|
||||||
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
|
||||||
{
|
{
|
||||||
try
|
return CarryonGamestageHelper.hasGamestage(CustomPickupOverrideHandler.getPickupCondition(toPickUp), player) && handleProtections((ServerPlayerEntity) player, toPickUp);
|
||||||
{
|
|
||||||
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
|
|
||||||
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
|
|
||||||
|
|
||||||
Method getPlayerData = ObfuscationReflectionHelper.findMethod(gameStageHelper, "getPlayerData", PlayerEntity.class);
|
|
||||||
Method hasStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getPlayerData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
boolean has = (boolean) hasStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
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", PlayerEntity.class);
|
|
||||||
Method hasUnlockedStage = ObfuscationReflectionHelper.findMethod(iStageData, "hasUnlockedStage", String.class);
|
|
||||||
|
|
||||||
Object stageData = getStageData.invoke(null, player);
|
|
||||||
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
|
|
||||||
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
|
|
||||||
|
|
||||||
if (has)
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true && handleProtections((ServerPlayerEntity) player, toPickUp);
|
return handleProtections((ServerPlayerEntity) player, toPickUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package tschipp.carryon.common.helper;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
public class CarryonGamestageHelper
|
||||||
|
{
|
||||||
|
public static boolean hasGamestage(String stage, PlayerEntity player)
|
||||||
|
{
|
||||||
|
// return GameStageHelper.hasStage(player, stage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matches(double number, String cond)
|
public static boolean matches(double number, String cond)
|
||||||
{
|
{
|
||||||
if (cond == null)
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -60,7 +60,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matches(Block block, String cond)
|
public static boolean matches(Block block, String cond)
|
||||||
{
|
{
|
||||||
if (cond == null)
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Block toCheck = StringParser.getBlock(cond);
|
Block toCheck = StringParser.getBlock(cond);
|
||||||
|
|
@ -72,7 +72,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matches(CompoundNBT toCheck, CompoundNBT toMatch)
|
public static boolean matches(CompoundNBT toCheck, CompoundNBT toMatch)
|
||||||
{
|
{
|
||||||
if (toCheck == null || toMatch == null)
|
if (toCheck == null || toMatch == null || toMatch.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
boolean matching = true;
|
boolean matching = true;
|
||||||
|
|
@ -111,7 +111,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static float getScaledValueFromString(String toGetFrom, String key)
|
public static float getScaledValueFromString(String toGetFrom, String key)
|
||||||
{
|
{
|
||||||
if(toGetFrom == null)
|
if(toGetFrom == null || toGetFrom.isEmpty())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
|
|
@ -139,7 +139,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matchesScore(PlayerEntity player, String cond)
|
public static boolean matchesScore(PlayerEntity player, String cond)
|
||||||
{
|
{
|
||||||
if (cond == null)
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Scoreboard score = player.getWorldScoreboard();
|
Scoreboard score = player.getWorldScoreboard();
|
||||||
|
|
@ -174,7 +174,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matches(BlockPos pos, String cond)
|
public static boolean matches(BlockPos pos, String cond)
|
||||||
{
|
{
|
||||||
if (cond == null)
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
BlockPos blockpos = new BlockPos(getValueFromString(cond, "x"), getValueFromString(cond, "y"), getValueFromString(cond, "z"));
|
||||||
|
|
@ -190,7 +190,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static float getValueFromString(String toGetFrom, String key)
|
public static float getValueFromString(String toGetFrom, String key)
|
||||||
{
|
{
|
||||||
if(toGetFrom == null)
|
if(toGetFrom == null || toGetFrom.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
String[] s = toGetFrom.split(",");
|
String[] s = toGetFrom.split(",");
|
||||||
|
|
@ -218,7 +218,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean hasEffects(PlayerEntity player, String cond)
|
public static boolean hasEffects(PlayerEntity player, String cond)
|
||||||
{
|
{
|
||||||
if(cond == null)
|
if(cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Collection<EffectInstance> effects = player.getActivePotionEffects();
|
Collection<EffectInstance> effects = player.getActivePotionEffects();
|
||||||
|
|
@ -274,7 +274,7 @@ public class ScriptParseHelper
|
||||||
|
|
||||||
public static boolean matches(Material material, String cond)
|
public static boolean matches(Material material, String cond)
|
||||||
{
|
{
|
||||||
if (cond == null)
|
if (cond == null || cond.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (cond)
|
switch (cond)
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,226 @@
|
||||||
package tschipp.carryon.common.scripting;
|
package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.JsonToNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import tschipp.carryon.common.helper.InvalidConfigException;
|
||||||
|
|
||||||
public class CarryOnOverride
|
public class CarryOnOverride
|
||||||
{
|
{
|
||||||
// BLOCKS
|
// BLOCKS
|
||||||
private CompoundNBT typeBlockTag;
|
private CompoundNBT typeBlockTag = new CompoundNBT();
|
||||||
private String typeNameBlock;
|
private String typeNameBlock = "";
|
||||||
private String typeMaterial;
|
private String typeMaterial = "";
|
||||||
private String typeHardness;
|
private String typeHardness = "";
|
||||||
private String typeResistance;
|
private String typeResistance = "";
|
||||||
|
|
||||||
// ENTITIES
|
// ENTITIES
|
||||||
private CompoundNBT typeEntityTag;
|
private CompoundNBT typeEntityTag;
|
||||||
private String typeNameEntity;
|
private String typeNameEntity = "";
|
||||||
private String typeHeight;
|
private String typeHeight = "";
|
||||||
private String typeWidth;
|
private String typeWidth = "";
|
||||||
private String typeHealth;
|
private String typeHealth = "";
|
||||||
|
|
||||||
// CONDITIONS
|
// CONDITIONS
|
||||||
private String conditionGamestage;
|
private String conditionGamestage = "";
|
||||||
private String conditionAchievement;
|
private String conditionAchievement = "";
|
||||||
private String conditionXp;
|
private String conditionXp = "";
|
||||||
private String conditionGamemode;
|
private String conditionGamemode = "";
|
||||||
private String conditionScoreboard;
|
private String conditionScoreboard = "";
|
||||||
private String conditionPosition;
|
private String conditionPosition = "";
|
||||||
private String conditionEffects;
|
private String conditionEffects = "";
|
||||||
|
|
||||||
// RENDER
|
// RENDER
|
||||||
private String renderNameBlock;
|
private String renderNameBlock = "";
|
||||||
private String renderNameEntity;
|
private String renderNameEntity = "";
|
||||||
private CompoundNBT renderNBT;
|
private CompoundNBT renderNBT = new CompoundNBT();
|
||||||
private String renderTranslation;
|
private String renderTranslation = "";
|
||||||
private String renderRotation;
|
private String renderRotation = "";
|
||||||
private String renderscaled;
|
private String renderscaled = "";
|
||||||
private String renderRotationLeftArm;
|
private String renderRotationLeftArm = "";
|
||||||
private String renderRotationRightArm;
|
private String renderRotationRightArm = "";
|
||||||
private boolean renderLeftArm = true;
|
private boolean renderLeftArm = true;
|
||||||
private boolean renderRightArm = true;
|
private boolean renderRightArm = true;
|
||||||
|
|
||||||
//EFFECTS
|
// EFFECTS
|
||||||
private String commandInit;
|
private String commandInit = "";
|
||||||
private String commandLoop;
|
private String commandLoop = "";
|
||||||
private String commandPlace;
|
private String commandPlace = "";
|
||||||
|
|
||||||
private boolean isBlock;
|
private boolean isBlock;
|
||||||
private boolean isEntity;
|
private boolean isEntity;
|
||||||
private String resourceLocation;
|
private String resourceLocation = "";
|
||||||
|
public boolean isInvalid = false;
|
||||||
|
|
||||||
public CarryOnOverride(String path)
|
public CarryOnOverride(String path)
|
||||||
{
|
{
|
||||||
this.resourceLocation = path;
|
this.resourceLocation = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CarryOnOverride(JsonElement jsonElem, ResourceLocation loc)
|
||||||
|
{
|
||||||
|
boolean errored = false;
|
||||||
|
resourceLocation = loc.toString();
|
||||||
|
|
||||||
|
if (jsonElem != null && jsonElem.isJsonObject())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JsonObject json = jsonElem.getAsJsonObject();
|
||||||
|
JsonObject object = (JsonObject) json.get("object");
|
||||||
|
JsonObject conditions = (JsonObject) json.get("conditions");
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
JsonObject block = (JsonObject) object.get("block");
|
||||||
|
JsonObject entity = (JsonObject) object.get("entity");
|
||||||
|
|
||||||
|
if ((block == null && entity == null) || (block != null && entity != null))
|
||||||
|
errored = true;
|
||||||
|
|
||||||
|
if (!errored)
|
||||||
|
{
|
||||||
|
if (block != null)
|
||||||
|
{
|
||||||
|
setBlock(true);
|
||||||
|
JsonElement name = block.get("name");
|
||||||
|
JsonElement material = block.get("material");
|
||||||
|
JsonElement hardness = block.get("hardness");
|
||||||
|
JsonElement resistance = block.get("resistance");
|
||||||
|
JsonObject nbt = (JsonObject) block.get("nbt");
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
|
setTypeNameBlock(name.getAsString());
|
||||||
|
if (material != null)
|
||||||
|
setTypeMaterial(material.getAsString());
|
||||||
|
if (hardness != null)
|
||||||
|
setTypeHardness(hardness.getAsString());
|
||||||
|
if (resistance != null)
|
||||||
|
setTypeResistance(resistance.getAsString());
|
||||||
|
if (nbt != null)
|
||||||
|
setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEntity(true);
|
||||||
|
JsonElement name = entity.get("name");
|
||||||
|
JsonElement health = entity.get("health");
|
||||||
|
JsonElement height = entity.get("height");
|
||||||
|
JsonElement width = entity.get("width");
|
||||||
|
JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
|
setTypeNameEntity(name.getAsString());
|
||||||
|
if (health != null)
|
||||||
|
setTypeHealth(health.getAsString());
|
||||||
|
if (height != null)
|
||||||
|
setTypeHeight(height.getAsString());
|
||||||
|
if (width != null)
|
||||||
|
setTypeWidth(width.getAsString());
|
||||||
|
if (nbt != null)
|
||||||
|
setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conditions != null)
|
||||||
|
{
|
||||||
|
JsonElement gamestage = conditions.get("gamestage");
|
||||||
|
JsonElement achievement = conditions.get("advancement");
|
||||||
|
JsonElement xp = conditions.get("xp");
|
||||||
|
JsonElement gamemode = conditions.get("gamemode");
|
||||||
|
JsonElement scoreboard = conditions.get("scoreboard");
|
||||||
|
JsonElement position = conditions.get("position");
|
||||||
|
JsonElement potionEffects = conditions.get("effects");
|
||||||
|
|
||||||
|
if (gamestage != null)
|
||||||
|
setConditionGamestage(gamestage.getAsString());
|
||||||
|
if (achievement != null)
|
||||||
|
setConditionAchievement(achievement.getAsString());
|
||||||
|
if (xp != null)
|
||||||
|
setConditionXp(xp.getAsString());
|
||||||
|
if (gamemode != null)
|
||||||
|
setConditionGamemode(gamemode.getAsString());
|
||||||
|
if (scoreboard != null)
|
||||||
|
setConditionScoreboard(scoreboard.getAsString());
|
||||||
|
if (position != null)
|
||||||
|
setConditionPosition(position.getAsString());
|
||||||
|
if (potionEffects != null)
|
||||||
|
setConditionEffects(potionEffects.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (render != null)
|
||||||
|
{
|
||||||
|
JsonElement name_block = render.get("name_block");
|
||||||
|
JsonElement name_entity = render.get("name_entity");
|
||||||
|
JsonObject nbt = (JsonObject) render.get("nbt");
|
||||||
|
JsonElement translation = render.get("translation");
|
||||||
|
JsonElement rotation = render.get("rotation");
|
||||||
|
JsonElement scaled = render.get("scale");
|
||||||
|
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||||
|
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||||
|
JsonElement renderLeftArm = render.get("render_left_arm");
|
||||||
|
JsonElement renderRightArm = render.get("render_right_arm");
|
||||||
|
|
||||||
|
if (name_block != null)
|
||||||
|
setRenderNameBlock(name_block.getAsString());
|
||||||
|
if (name_entity != null)
|
||||||
|
setRenderNameEntity(name_entity.getAsString());
|
||||||
|
if (translation != null)
|
||||||
|
setRenderTranslation(translation.getAsString());
|
||||||
|
if (rotation != null)
|
||||||
|
setRenderRotation(rotation.getAsString());
|
||||||
|
if (scaled != null)
|
||||||
|
setRenderscaled(scaled.getAsString());
|
||||||
|
if (nbt != null)
|
||||||
|
setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
|
if (rotationLeftArm != null)
|
||||||
|
setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||||
|
if (rotationRightArm != null)
|
||||||
|
setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||||
|
if (renderLeftArm != null)
|
||||||
|
setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||||
|
if (renderRightArm != null)
|
||||||
|
setRenderRightArm(renderRightArm.getAsBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effects != null)
|
||||||
|
{
|
||||||
|
JsonElement commandInit = effects.get("commandPickup");
|
||||||
|
JsonElement commandLoop = effects.get("commandLoop");
|
||||||
|
JsonElement commandPlace = effects.get("commandPlace");
|
||||||
|
|
||||||
|
if (commandInit != null)
|
||||||
|
setCommandInit(commandInit.getAsString());
|
||||||
|
if (commandLoop != null)
|
||||||
|
setCommandLoop(commandLoop.getAsString());
|
||||||
|
if (commandPlace != null)
|
||||||
|
setCommandPlace(commandPlace.getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isInvalid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
isInvalid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isInvalid = true;
|
||||||
|
|
||||||
|
if(!isBlock && !isEntity)
|
||||||
|
isInvalid = true;
|
||||||
|
|
||||||
|
if(isInvalid)
|
||||||
|
new InvalidConfigException("The script parsing for " + resourceLocation + " has failed! Please double check!").printException();
|
||||||
|
}
|
||||||
|
|
||||||
public String getCommandInit()
|
public String getCommandInit()
|
||||||
{
|
{
|
||||||
return commandInit;
|
return commandInit;
|
||||||
|
|
@ -133,13 +299,13 @@ public class CarryOnOverride
|
||||||
result = prime * result + ((resourceLocation == null) ? 0 : resourceLocation.hashCode());
|
result = prime * result + ((resourceLocation == null) ? 0 : resourceLocation.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "Code: " + this.hashCode();
|
return "Code: " + this.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
|
|
@ -364,8 +530,6 @@ public class CarryOnOverride
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isBlock()
|
public boolean isBlock()
|
||||||
{
|
{
|
||||||
return isBlock;
|
return isBlock;
|
||||||
|
|
@ -501,7 +665,6 @@ public class CarryOnOverride
|
||||||
this.typeBlockTag = typeBlockTag;
|
this.typeBlockTag = typeBlockTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setTypeNameBlock(String typeNameBlock)
|
public void setTypeNameBlock(String typeNameBlock)
|
||||||
{
|
{
|
||||||
this.typeNameBlock = typeNameBlock;
|
this.typeNameBlock = typeNameBlock;
|
||||||
|
|
@ -607,8 +770,6 @@ public class CarryOnOverride
|
||||||
this.renderscaled = renderscaled;
|
this.renderscaled = renderscaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCommandPlace()
|
public String getCommandPlace()
|
||||||
{
|
{
|
||||||
return commandPlace;
|
return commandPlace;
|
||||||
|
|
@ -618,7 +779,7 @@ public class CarryOnOverride
|
||||||
{
|
{
|
||||||
this.commandPlace = commandPlace;
|
this.commandPlace = commandPlace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(PacketBuffer buf)
|
public void serialize(PacketBuffer buf)
|
||||||
{
|
{
|
||||||
// BLOCKS
|
// BLOCKS
|
||||||
|
|
@ -655,8 +816,8 @@ public class CarryOnOverride
|
||||||
buf.writeString(renderRotationRightArm);
|
buf.writeString(renderRotationRightArm);
|
||||||
buf.writeBoolean(renderLeftArm);
|
buf.writeBoolean(renderLeftArm);
|
||||||
buf.writeBoolean(renderRightArm);
|
buf.writeBoolean(renderRightArm);
|
||||||
|
|
||||||
//EFFECTS
|
// EFFECTS
|
||||||
buf.writeString(commandInit);
|
buf.writeString(commandInit);
|
||||||
buf.writeString(commandLoop);
|
buf.writeString(commandLoop);
|
||||||
buf.writeString(commandPlace);
|
buf.writeString(commandPlace);
|
||||||
|
|
@ -665,7 +826,7 @@ public class CarryOnOverride
|
||||||
buf.writeBoolean(isEntity);
|
buf.writeBoolean(isEntity);
|
||||||
buf.writeString(resourceLocation);
|
buf.writeString(resourceLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CarryOnOverride deserialize(PacketBuffer buf)
|
public static CarryOnOverride deserialize(PacketBuffer buf)
|
||||||
{
|
{
|
||||||
CarryOnOverride override = new CarryOnOverride("");
|
CarryOnOverride override = new CarryOnOverride("");
|
||||||
|
|
@ -702,8 +863,8 @@ public class CarryOnOverride
|
||||||
override.renderRotationRightArm = buf.readString();
|
override.renderRotationRightArm = buf.readString();
|
||||||
override.renderLeftArm = buf.readBoolean();
|
override.renderLeftArm = buf.readBoolean();
|
||||||
override.renderRightArm = buf.readBoolean();
|
override.renderRightArm = buf.readBoolean();
|
||||||
|
|
||||||
//EFFECTS
|
// EFFECTS
|
||||||
override.commandInit = buf.readString();
|
override.commandInit = buf.readString();
|
||||||
override.commandLoop = buf.readString();
|
override.commandLoop = buf.readString();
|
||||||
override.commandPlace = buf.readString();
|
override.commandPlace = buf.readString();
|
||||||
|
|
@ -711,7 +872,7 @@ public class CarryOnOverride
|
||||||
override.isBlock = buf.readBoolean();
|
override.isBlock = buf.readBoolean();
|
||||||
override.isEntity = buf.readBoolean();
|
override.isEntity = buf.readBoolean();
|
||||||
override.resourceLocation = buf.readString();
|
override.resourceLocation = buf.readString();
|
||||||
|
|
||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ public class ScriptChecker
|
||||||
float height = entity.getHeight();
|
float height = entity.getHeight();
|
||||||
float width = entity.getWidth();
|
float width = entity.getWidth();
|
||||||
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
float health = entity instanceof LivingEntity ? ((LivingEntity) entity).getHealth() : 0.0f;
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundNBT tag = entity.serializeNBT();
|
||||||
entity.deserializeNBT(tag);
|
|
||||||
|
|
||||||
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
boolean isAllowed = Settings.useWhitelistEntities.get() ? ListHandler.isAllowed(entity) : !ListHandler.isForbidden(entity);
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class ScriptChecker
|
||||||
|
|
||||||
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, CompoundNBT tag)
|
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, CompoundNBT tag)
|
||||||
{
|
{
|
||||||
boolean matchname = override.getTypeNameEntity() == null ? true : name.equals(override.getTypeNameEntity());
|
boolean matchname = override.getTypeNameEntity().isEmpty() ? true : name.equals(override.getTypeNameEntity());
|
||||||
boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
boolean matchheight = ScriptParseHelper.matches(height, override.getTypeHeight());
|
||||||
boolean matchwidth = ScriptParseHelper.matches(width, override.getTypeWidth());
|
boolean matchwidth = ScriptParseHelper.matches(width, override.getTypeWidth());
|
||||||
boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth());
|
boolean matchhealth = ScriptParseHelper.matches(health, override.getTypeHealth());
|
||||||
|
|
@ -110,14 +110,14 @@ public class ScriptChecker
|
||||||
public static boolean fulfillsConditions(CarryOnOverride override, PlayerEntity player)
|
public static boolean fulfillsConditions(CarryOnOverride override, PlayerEntity player)
|
||||||
{
|
{
|
||||||
AdvancementManager manager = ((ServerPlayerEntity) player).server.getAdvancementManager();
|
AdvancementManager manager = ((ServerPlayerEntity) player).server.getAdvancementManager();
|
||||||
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()) == null ? "" : override.getConditionAchievement()));
|
Advancement adv = manager.getAdvancement(new ResourceLocation((override.getConditionAchievement()).isEmpty() ? "" : override.getConditionAchievement()));
|
||||||
|
|
||||||
boolean achievement = adv == null ? true : ((ServerPlayerEntity) player).getAdvancements().getProgress(adv).isDone();
|
boolean achievement = adv == null ? true : ((ServerPlayerEntity) player).getAdvancements().getProgress(adv).isDone();
|
||||||
boolean gamemode = ScriptParseHelper.matches(((ServerPlayerEntity) player).interactionManager.getGameType().getID(), override.getConditionGamemode());
|
boolean gamemode = ScriptParseHelper.matches(((ServerPlayerEntity) player).interactionManager.getGameType().getID(), override.getConditionGamemode());
|
||||||
boolean gamestage = true;
|
boolean gamestage = true;
|
||||||
if (ModList.get().isLoaded("gamestages"))
|
if (ModList.get().isLoaded("gamestages"))
|
||||||
{
|
{
|
||||||
if (override.getConditionGamestage() != null)
|
if (!override.getConditionGamestage().isEmpty())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,200 +1,187 @@
|
||||||
package tschipp.carryon.common.scripting;
|
package tschipp.carryon.common.scripting;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.JsonToNBT;
|
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
|
||||||
import tschipp.carryon.CarryOn;
|
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
|
||||||
|
|
||||||
public class ScriptReader
|
public class ScriptReader
|
||||||
{
|
{
|
||||||
private static ArrayList<File> scripts = new ArrayList<File>();
|
|
||||||
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<Integer, CarryOnOverride>();
|
public static HashMap<Integer, CarryOnOverride> OVERRIDES = new HashMap<Integer, CarryOnOverride>();
|
||||||
|
|
||||||
// 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();
|
||||||
|
//
|
||||||
|
// for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
||||||
|
// {
|
||||||
|
// if (file.getName().endsWith(".json"))
|
||||||
|
// scripts.add(file);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
if (!CarryOn.CONFIGURATION_FILE.exists())
|
// public static void parseScripts()
|
||||||
CarryOn.CONFIGURATION_FILE.mkdir();
|
// {
|
||||||
|
// OVERRIDES.clear();
|
||||||
for (File file : CarryOn.CONFIGURATION_FILE.listFiles())
|
//
|
||||||
{
|
// try
|
||||||
if (file.getName().endsWith(".json"))
|
// {
|
||||||
scripts.add(file);
|
// if (!Settings.useScripts.get())
|
||||||
}
|
// return;
|
||||||
|
//
|
||||||
}
|
// for (File file : scripts)
|
||||||
|
// {
|
||||||
public static void parseScripts()
|
// boolean errored = false;
|
||||||
{
|
// JsonParser parser = new JsonParser();
|
||||||
OVERRIDES.clear();
|
// JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
||||||
|
//
|
||||||
try
|
// JsonObject object = (JsonObject) json.get("object");
|
||||||
{
|
// JsonObject conditions = (JsonObject) json.get("conditions");
|
||||||
if (!Settings.useScripts.get())
|
// JsonObject render = (JsonObject) json.get("render");
|
||||||
return;
|
// JsonObject effects = (JsonObject) json.get("effects");
|
||||||
|
//
|
||||||
for (File file : scripts)
|
// if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
||||||
{
|
// {
|
||||||
boolean errored = false;
|
// JsonObject block = (JsonObject) object.get("block");
|
||||||
JsonParser parser = new JsonParser();
|
// JsonObject entity = (JsonObject) object.get("entity");
|
||||||
JsonObject json = (JsonObject) parser.parse(new FileReader(file.getAbsolutePath()));
|
//
|
||||||
|
// if ((block == null && entity == null) || (block != null && entity != null))
|
||||||
JsonObject object = (JsonObject) json.get("object");
|
// errored = true;
|
||||||
JsonObject conditions = (JsonObject) json.get("conditions");
|
//
|
||||||
JsonObject render = (JsonObject) json.get("render");
|
// if (!errored)
|
||||||
JsonObject effects = (JsonObject) json.get("effects");
|
// {
|
||||||
|
// CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
||||||
if ((object != null && conditions != null) || (object != null && render != null) || (object != null && effects != null))
|
//
|
||||||
{
|
// if (block != null)
|
||||||
JsonObject block = (JsonObject) object.get("block");
|
// {
|
||||||
JsonObject entity = (JsonObject) object.get("entity");
|
// override.setBlock(true);
|
||||||
|
// JsonElement name = block.get("name");
|
||||||
if ((block == null && entity == null) || (block != null && entity != null))
|
// JsonElement material = block.get("material");
|
||||||
errored = true;
|
// JsonElement hardness = block.get("hardness");
|
||||||
|
// JsonElement resistance = block.get("resistance");
|
||||||
if (!errored)
|
// JsonObject nbt = (JsonObject) block.get("nbt");
|
||||||
{
|
//
|
||||||
CarryOnOverride override = new CarryOnOverride(file.getAbsolutePath());
|
// if (name != null)
|
||||||
|
// override.setTypeNameBlock(name.getAsString());
|
||||||
if (block != null)
|
// if (material != null)
|
||||||
{
|
// override.setTypeMaterial(material.getAsString());
|
||||||
override.setBlock(true);
|
// if (hardness != null)
|
||||||
JsonElement name = block.get("name");
|
// override.setTypeHardness(hardness.getAsString());
|
||||||
JsonElement material = block.get("material");
|
// if (resistance != null)
|
||||||
JsonElement hardness = block.get("hardness");
|
// override.setTypeResistance(resistance.getAsString());
|
||||||
JsonElement resistance = block.get("resistance");
|
// if (nbt != null)
|
||||||
JsonObject nbt = (JsonObject) block.get("nbt");
|
// override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
|
// } else
|
||||||
if (name != null)
|
// {
|
||||||
override.setTypeNameBlock(name.getAsString());
|
// override.setEntity(true);
|
||||||
if (material != null)
|
// JsonElement name = entity.get("name");
|
||||||
override.setTypeMaterial(material.getAsString());
|
// JsonElement health = entity.get("health");
|
||||||
if (hardness != null)
|
// JsonElement height = entity.get("height");
|
||||||
override.setTypeHardness(hardness.getAsString());
|
// JsonElement width = entity.get("width");
|
||||||
if (resistance != null)
|
// JsonObject nbt = (JsonObject) entity.get("nbt");
|
||||||
override.setTypeResistance(resistance.getAsString());
|
//
|
||||||
if (nbt != null)
|
// if (name != null)
|
||||||
override.setTypeBlockTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
// override.setTypeNameEntity(name.getAsString());
|
||||||
} else
|
// if (health != null)
|
||||||
{
|
// override.setTypeHealth(health.getAsString());
|
||||||
override.setEntity(true);
|
// if (height != null)
|
||||||
JsonElement name = entity.get("name");
|
// override.setTypeHeight(height.getAsString());
|
||||||
JsonElement health = entity.get("health");
|
// if (width != null)
|
||||||
JsonElement height = entity.get("height");
|
// override.setTypeWidth(width.getAsString());
|
||||||
JsonElement width = entity.get("width");
|
// if (nbt != null)
|
||||||
JsonObject nbt = (JsonObject) entity.get("nbt");
|
// override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
|
// }
|
||||||
if (name != null)
|
//
|
||||||
override.setTypeNameEntity(name.getAsString());
|
// if (conditions != null)
|
||||||
if (health != null)
|
// {
|
||||||
override.setTypeHealth(health.getAsString());
|
// JsonElement gamestage = conditions.get("gamestage");
|
||||||
if (height != null)
|
// JsonElement achievement = conditions.get("advancement");
|
||||||
override.setTypeHeight(height.getAsString());
|
// JsonElement xp = conditions.get("xp");
|
||||||
if (width != null)
|
// JsonElement gamemode = conditions.get("gamemode");
|
||||||
override.setTypeWidth(width.getAsString());
|
// JsonElement scoreboard = conditions.get("scoreboard");
|
||||||
if (nbt != null)
|
// JsonElement position = conditions.get("position");
|
||||||
override.setTypeEntityTag(JsonToNBT.getTagFromJson(nbt.toString()));
|
// JsonElement potionEffects = conditions.get("effects");
|
||||||
}
|
//
|
||||||
|
// if (gamestage != null)
|
||||||
if (conditions != null)
|
// override.setConditionGamestage(gamestage.getAsString());
|
||||||
{
|
// if (achievement != null)
|
||||||
JsonElement gamestage = conditions.get("gamestage");
|
// override.setConditionAchievement(achievement.getAsString());
|
||||||
JsonElement achievement = conditions.get("advancement");
|
// if (xp != null)
|
||||||
JsonElement xp = conditions.get("xp");
|
// override.setConditionXp(xp.getAsString());
|
||||||
JsonElement gamemode = conditions.get("gamemode");
|
// if (gamemode != null)
|
||||||
JsonElement scoreboard = conditions.get("scoreboard");
|
// override.setConditionGamemode(gamemode.getAsString());
|
||||||
JsonElement position = conditions.get("position");
|
// if (scoreboard != null)
|
||||||
JsonElement potionEffects = conditions.get("effects");
|
// override.setConditionScoreboard(scoreboard.getAsString());
|
||||||
|
// if (position != null)
|
||||||
if (gamestage != null)
|
// override.setConditionPosition(position.getAsString());
|
||||||
override.setConditionGamestage(gamestage.getAsString());
|
// if (potionEffects != null)
|
||||||
if (achievement != null)
|
// override.setConditionEffects(potionEffects.getAsString());
|
||||||
override.setConditionAchievement(achievement.getAsString());
|
// }
|
||||||
if (xp != null)
|
//
|
||||||
override.setConditionXp(xp.getAsString());
|
// if (render != null)
|
||||||
if (gamemode != null)
|
// {
|
||||||
override.setConditionGamemode(gamemode.getAsString());
|
// JsonElement name_block = render.get("name_block");
|
||||||
if (scoreboard != null)
|
// JsonElement name_entity = render.get("name_entity");
|
||||||
override.setConditionScoreboard(scoreboard.getAsString());
|
// JsonObject nbt = (JsonObject) render.get("nbt");
|
||||||
if (position != null)
|
// JsonElement translation = render.get("translation");
|
||||||
override.setConditionPosition(position.getAsString());
|
// JsonElement rotation = render.get("rotation");
|
||||||
if (potionEffects != null)
|
// JsonElement scaled = render.get("scale");
|
||||||
override.setConditionEffects(potionEffects.getAsString());
|
// JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||||
}
|
// JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||||
|
// JsonElement renderLeftArm = render.get("render_left_arm");
|
||||||
if (render != null)
|
// JsonElement renderRightArm = render.get("render_right_arm");
|
||||||
{
|
//
|
||||||
JsonElement name_block = render.get("name_block");
|
// if (name_block != null)
|
||||||
JsonElement name_entity = render.get("name_entity");
|
// override.setRenderNameBlock(name_block.getAsString());
|
||||||
JsonObject nbt = (JsonObject) render.get("nbt");
|
// if (name_entity != null)
|
||||||
JsonElement translation = render.get("translation");
|
// override.setRenderNameEntity(name_entity.getAsString());
|
||||||
JsonElement rotation = render.get("rotation");
|
// if (translation != null)
|
||||||
JsonElement scaled = render.get("scale");
|
// override.setRenderTranslation(translation.getAsString());
|
||||||
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
// if (rotation != null)
|
||||||
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
// override.setRenderRotation(rotation.getAsString());
|
||||||
JsonElement renderLeftArm = render.get("render_left_arm");
|
// if (scaled != null)
|
||||||
JsonElement renderRightArm = render.get("render_right_arm");
|
// override.setRenderscaled(scaled.getAsString());
|
||||||
|
// if (nbt != null)
|
||||||
if (name_block != null)
|
// override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
||||||
override.setRenderNameBlock(name_block.getAsString());
|
// if (rotationLeftArm != null)
|
||||||
if (name_entity != null)
|
// override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
||||||
override.setRenderNameEntity(name_entity.getAsString());
|
// if (rotationRightArm != null)
|
||||||
if (translation != null)
|
// override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
||||||
override.setRenderTranslation(translation.getAsString());
|
// if (renderLeftArm != null)
|
||||||
if (rotation != null)
|
// override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
||||||
override.setRenderRotation(rotation.getAsString());
|
// if (renderRightArm != null)
|
||||||
if (scaled != null)
|
// override.setRenderRightArm(renderRightArm.getAsBoolean());
|
||||||
override.setRenderscaled(scaled.getAsString());
|
// }
|
||||||
if (nbt != null)
|
//
|
||||||
override.setRenderNBT(JsonToNBT.getTagFromJson(nbt.toString()));
|
// if (effects != null)
|
||||||
if (rotationLeftArm != null)
|
// {
|
||||||
override.setRenderRotationLeftArm(rotationLeftArm.getAsString());
|
// JsonElement commandInit = effects.get("commandPickup");
|
||||||
if (rotationRightArm != null)
|
// JsonElement commandLoop = effects.get("commandLoop");
|
||||||
override.setRenderRotationRightArm(rotationRightArm.getAsString());
|
// JsonElement commandPlace = effects.get("commandPlace");
|
||||||
if (renderLeftArm != null)
|
//
|
||||||
override.setRenderLeftArm(renderLeftArm.getAsBoolean());
|
// if (commandInit != null)
|
||||||
if (renderRightArm != null)
|
// override.setCommandInit(commandInit.getAsString());
|
||||||
override.setRenderRightArm(renderRightArm.getAsBoolean());
|
// if (commandLoop != null)
|
||||||
}
|
// override.setCommandLoop(commandLoop.getAsString());
|
||||||
|
// if (commandPlace != null)
|
||||||
if (effects != null)
|
// override.setCommandPlace(commandPlace.getAsString());
|
||||||
{
|
// }
|
||||||
JsonElement commandInit = effects.get("commandPickup");
|
//
|
||||||
JsonElement commandLoop = effects.get("commandLoop");
|
// OVERRIDES.put(override.hashCode(), override);
|
||||||
JsonElement commandPlace = effects.get("commandPlace");
|
// }
|
||||||
|
// }
|
||||||
if (commandInit != null)
|
// }
|
||||||
override.setCommandInit(commandInit.getAsString());
|
//
|
||||||
if (commandLoop != null)
|
// System.out.println("Successfully parsed scripts!");
|
||||||
override.setCommandLoop(commandLoop.getAsString());
|
// } catch (Exception e)
|
||||||
if (commandPlace != null)
|
// {
|
||||||
override.setCommandPlace(commandPlace.getAsString());
|
// CarryOn.LOGGER.error(e);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
OVERRIDES.put(override.hashCode(), override);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Successfully parsed scripts!");
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
CarryOn.LOGGER.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,10 @@ public class ScriptReloadListener extends JsonReloadListener
|
||||||
{
|
{
|
||||||
ScriptReader.OVERRIDES.clear();
|
ScriptReader.OVERRIDES.clear();
|
||||||
|
|
||||||
objects.forEach((path, jsonObj) -> {
|
objects.forEach((path, jsonElem) -> {
|
||||||
CarryOnOverride override = GSON.fromJson(jsonObj, CarryOnOverride.class);
|
CarryOnOverride override = new CarryOnOverride(jsonElem, path);
|
||||||
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
if(!override.isInvalid)
|
||||||
|
ScriptReader.OVERRIDES.put(override.hashCode(), override);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (EffectiveSide.get().isServer() && ServerLifecycleHooks.getCurrentServer() != null)
|
if (EffectiveSide.get().isServer() && ServerLifecycleHooks.getCurrentServer() != null)
|
||||||
|
|
|
||||||
|
|
@ -45,35 +45,39 @@ public class CarrySlotPacket
|
||||||
|
|
||||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||||
{
|
{
|
||||||
ctx.get().enqueueWork(() -> {
|
if (ctx.get().getDirection().getReceptionSide().isClient())
|
||||||
|
{
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
|
|
||||||
World world = CarryOn.proxy.getWorld();
|
World world = CarryOn.proxy.getWorld();
|
||||||
|
|
||||||
if (world != null)
|
if (world != null)
|
||||||
{
|
|
||||||
Entity e = world.getEntityByID(entityid);
|
|
||||||
|
|
||||||
if (e != null && e instanceof PlayerEntity)
|
|
||||||
{
|
{
|
||||||
PlayerEntity player = (PlayerEntity) e;
|
Entity e = world.getEntityByID(entityid);
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
if (e != null && e instanceof PlayerEntity)
|
||||||
|
|
||||||
if (slot >= 9)
|
|
||||||
{
|
|
||||||
player.getPersistentData().remove("carrySlot");
|
|
||||||
player.getPersistentData().remove("overrideKey");
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
|
PlayerEntity player = (PlayerEntity) e;
|
||||||
|
|
||||||
player.getPersistentData().putInt("carrySlot", slot);
|
ctx.get().setPacketHandled(true);
|
||||||
if (carryOverride != 0)
|
|
||||||
ScriptChecker.setCarryOnOverride(player, carryOverride);
|
if (slot >= 9)
|
||||||
|
{
|
||||||
|
player.getPersistentData().remove("carrySlot");
|
||||||
|
player.getPersistentData().remove("overrideKey");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
player.getPersistentData().putInt("carrySlot", slot);
|
||||||
|
if (carryOverride != 0)
|
||||||
|
ScriptChecker.setCarryOnOverride(player, carryOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,17 @@ public class SyncKeybindPacket
|
||||||
|
|
||||||
public void handle(Supplier<NetworkEvent.Context> ctx)
|
public void handle(Supplier<NetworkEvent.Context> ctx)
|
||||||
{
|
{
|
||||||
ctx.get().enqueueWork(() -> {
|
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||||
|
{
|
||||||
ServerPlayerEntity player = ctx.get().getSender();
|
ctx.get().enqueueWork(() -> {
|
||||||
|
|
||||||
CarryOnKeybinds.setKeyPressed(player, pressed);
|
ServerPlayerEntity player = ctx.get().getSender();
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
CarryOnKeybinds.setKeyPressed(player, pressed);
|
||||||
});
|
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"description": "Mod Resources",
|
"description": "Carryon Resources and Data",
|
||||||
"pack_format": 4,
|
"pack_format": 6
|
||||||
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user