Fixed bugs

This commit is contained in:
Tschipp 2022-12-10 18:28:21 +01:00
parent 2d24b3d8ce
commit 49f3990eee
9 changed files with 52 additions and 11 deletions

View File

@ -150,6 +150,13 @@ public class CarryRenderHelper
// matrix.translate(0, 0, -0.4);
matrix.mulPose(Vector3f.YP.rotationDegrees(180));
}
// if(perspective == 1)
// {
// matrix.pushPose();
// //matrix.mulPose(Vector3f.YP.rotationDegrees(180));
// matrix.popPose();
// }
//else if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
// matrix.translate(0, 0, 0.4);
//matrix.mulPose(Vector3f.YP.rotationDegrees(180));

View File

@ -16,6 +16,7 @@ import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
import tschipp.carryon.common.carry.CarryOnData;
import tschipp.carryon.common.carry.CarryOnData.CarryType;
import tschipp.carryon.common.carry.CarryOnDataManager;
import tschipp.carryon.common.carry.PlacementHandler;
import tschipp.carryon.common.pickupcondition.PickupCondition;
import tschipp.carryon.common.pickupcondition.PickupConditionHandler;
@ -35,7 +36,11 @@ public class CommandCarryOn
.then(Commands.literal("clear").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handleClear(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
;
.then(Commands.literal("place").requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), Collections.singleton(cmd.getSource().getPlayerOrException()))))
.then(Commands.literal("place").then(Commands.argument("target", EntityArgument.players()).requires(src -> src.hasPermission(2)).executes(cmd -> handlePlace(cmd.getSource(), EntityArgument.getPlayers(cmd, "target")))))
;
dispatcher.register(builder);
@ -116,6 +121,23 @@ public class CommandCarryOn
return 1;
}
private static int handlePlace(CommandSourceStack source, Collection<ServerPlayer> players)
{
int cleared = 0;
for (ServerPlayer player : players)
{
PlacementHandler.placeCarried(player);
cleared++;
}
if (cleared != 1)
source.sendSuccess(Component.literal("Placed " + cleared + " Items!"), true);
else
source.sendSuccess(Component.literal("Placed " + cleared + " Item!"), true);
return 1;
}
private static void log(CommandSourceStack source, String toLog)
{
source.sendSuccess(Component.literal(toLog), true);

View File

@ -153,7 +153,11 @@ public class CarryConfig {
public String[] placementStateExceptions = {
"minecraft:chest[type]",
"minecraft:stone_button[face]",
"minecraft:vine[north,east,south,west,up]"
"minecraft:vine[north,east,south,west,up]",
"minecraft:creeper_head[rotation]",
"minecraft:glow_lichen[north,east,south,west,up,down]",
"minecraft:oak_sign[rotation]",
"minecraft:oak_trapdoor[half]",
};
@Property(
@ -294,7 +298,8 @@ public class CarryConfig {
)
public String[] modelOverrides = {
"minecraft:redstone_wire->(item)minecraft:redstone",
"minecraft:bamboo_sapling->(block)minecraft:bamboo"
"minecraft:bamboo_sapling->(block)minecraft:bamboo",
"minecraft:candle_cake->(block)minecraft:cake"
};
}

View File

@ -34,7 +34,7 @@ public class PickupCondition
if(!(str.contains("(") && str.endsWith(")")))
return DataResult.error("Error while parsing: "+ str +". Pickup Condition must contain proper brackets.");
String cond = str.substring(str.indexOf("("), str.length()-1);
String cond = str.substring(str.indexOf("(") + 1, str.length()-1);
String match = str.substring(0, str.indexOf("("));

View File

@ -14,6 +14,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
import net.minecraft.util.profiling.ProfilerFiller;
import tschipp.carryon.Constants;
import tschipp.carryon.common.carry.CarryOnData;
import tschipp.carryon.networking.clientbound.ClientboundSyncScriptsPacket;
import tschipp.carryon.platform.Services;
@ -37,10 +38,14 @@ public class ScriptReloadListener extends SimpleJsonResourceReloadListener
try {
objects.forEach((path, jsonElem) -> {
DataResult<CarryOnScript> res = CarryOnScript.CODEC.parse(JsonOps.INSTANCE, jsonElem);
CarryOnScript script = res.getOrThrow(false, (s) -> {throw new RuntimeException(s);});
if (script.isValid())
ScriptManager.SCRIPTS.add(script);
if(res.result().isPresent())
{
CarryOnScript script = res.result().get();
if (script.isValid())
ScriptManager.SCRIPTS.add(script);
}
else
Constants.LOG.warn("Error while parsing script: " + res.error().get().message());
});
}
catch (Exception e)

View File

@ -23,7 +23,6 @@ public abstract class PlayerMixin extends LivingEntity {
@Inject(method = "defineSynchedData()V", at = @At("RETURN"))
private void onDefineSynchedData(CallbackInfo info) {
this.entityData.define(CarryOnDataManager.CARRY_DATA_KEY, new CompoundTag());
System.out.println("Added Carry Data!");
}
@Inject(method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("RETURN"))

View File

@ -34,6 +34,8 @@ public class ConfigLoaderImpl {
FileUtils.write(cfgFile, GSON.toJson(loadConfig(entry.getValue(), cfgJson)), StandardCharsets.UTF_8);
}
}
ConfigLoader.onConfigLoaded();
}
private static JsonObject loadConfig(BuiltCategory category, JsonObject config) {

View File

@ -106,7 +106,8 @@ repositories {
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly project(":Common")
compileOnly fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.2:16.1.9")
annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
}

View File

@ -95,7 +95,7 @@ public class ConfigLoaderImpl {
case BOOLEAN -> builder.define(data.getId(), data.getBoolean());
case INT -> builder.defineInRange(data.getId(), data.getInt(), annotationData.min(), annotationData.max());
case DOUBLE -> builder.defineInRange(data.getId(), data.getDouble(), annotationData.minD(), annotationData.maxD());
case STRING_ARRAY -> builder.defineList(data.getId(), Arrays.asList(data.getStringArray()), obj -> obj instanceof String);
case STRING_ARRAY -> builder.defineList(data.getId(), Arrays.asList(data.getStringArray()), obj -> true);
default -> throw new IllegalAccessException("Unknown property type.");
}
}