Compare commits

...

14 Commits

Author SHA1 Message Date
Tschipp
c5e3c55384 updated config 2024-02-27 23:35:04 +01:00
Tschipp
52252107a0 Fixed tags not loading, updated configs 2024-02-27 23:28:42 +01:00
Tschipp
e68553e2d2 Fixed memory leak, updated blacklist 2023-11-19 23:25:40 +01:00
Tschipp
7c559cddb9 fixed bugs relating to placement 2023-08-30 22:37:25 +02:00
Tschipp
ee510adc4b stopped shipping amecs 2023-07-25 13:56:17 +02:00
Tschipp
5fe65552ef updated version number 2023-07-09 21:47:00 +02:00
Tschipp
5c27a735b5 fixed crash with amecs on 1.19.2 2023-07-09 21:45:04 +02:00
Tschipp
1ca409c43d Fixed IMC, Keybinds, other bugs 2023-07-06 17:25:45 +02:00
Tschipp
9ed3268e30
Update build.gradle 2023-04-28 22:06:05 +02:00
Tschipp
89653e84ad
Update build.gradle 2023-04-28 22:05:17 +02:00
Tschipp
f2101ae6ab
Update gradle.properties 2023-04-28 22:04:31 +02:00
Tschipp
84b303a7fd
Update build.gradle 2023-04-28 22:04:11 +02:00
Tschipp
9f0f26eb83 Fixed Bugs 2023-04-24 22:51:30 +02:00
Tschipp
e06962c125 Fixed MixinExtras by using JarJar 2023-02-01 18:28:10 +01:00
21 changed files with 486 additions and 333 deletions

View File

@ -28,8 +28,8 @@ repositories {
dependencies { dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5' compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation("com.github.LlamaLad7:MixinExtras:${mixinextras_version}") implementation("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}")
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}") annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}")
} }
processResources { processResources {
@ -57,4 +57,4 @@ publishing {
url "file://" + System.getenv("local_maven") url "file://" + System.getenv("local_maven")
} }
} }
} }

View File

@ -14,11 +14,11 @@ public class CarryOnCommonClient
Player player = mc.player; Player player = mc.player;
if(player != null) { if(player != null) {
CarryOnData carry = CarryOnDataManager.getCarryData(player); CarryOnData carry = CarryOnDataManager.getCarryData(player);
if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : CarryOnKeybinds.carryKey.isDown()) && !carry.isKeyPressed()) { if ((CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse())) && !carry.isKeyPressed()) {
CarryOnKeybinds.onCarryKey(true); CarryOnKeybinds.onCarryKey(true);
carry.setKeyPressed(true); carry.setKeyPressed(true);
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
} else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : CarryOnKeybinds.carryKey.isDown()) && carry.isKeyPressed()) { } else if (!(CarryOnKeybinds.carryKey.isUnbound() ? player.isShiftKeyDown() : (CarryOnKeybinds.carryKey.isDown() || checkMouse()) ) && carry.isKeyPressed()) {
CarryOnKeybinds.onCarryKey(false); CarryOnKeybinds.onCarryKey(false);
carry.setKeyPressed(false); carry.setKeyPressed(false);
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
@ -26,6 +26,12 @@ public class CarryOnCommonClient
} }
} }
private static boolean checkMouse()
{
Minecraft mc = Minecraft.getInstance();
return (CarryOnKeybinds.carryKey.matchesMouse(0) && mc.mouseHandler.isLeftPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(1) && mc.mouseHandler.isRightPressed()) || (CarryOnKeybinds.carryKey.matchesMouse(3) && mc.mouseHandler.isMiddlePressed());
}
public static void onCarryClientTick() public static void onCarryClientTick()
{ {
Player player = Minecraft.getInstance().player; Player player = Minecraft.getInstance().player;

View File

@ -14,7 +14,11 @@ public class CarryOnKeybinds
public static void registerKeybinds(Consumer<KeyMapping> registrar) public static void registerKeybinds(Consumer<KeyMapping> registrar)
{ {
carryKey = new ConflictFreeKeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), "key.carry.category"); if(Services.PLATFORM.isModLoaded("amecsapi"))
carryKey = new ConflictFreeKeyMapping("key.carry.desc", InputConstants.KEY_LSHIFT, "key.carry.category");
else
carryKey = new ConflictFreeKeyMapping("key.carry.desc", Services.PLATFORM.getPlatformName().equals("Forge") ? InputConstants.KEY_LSHIFT : InputConstants.UNKNOWN.getValue(), "key.carry.category");
registrar.accept(carryKey); registrar.accept(carryKey);
} }

View File

@ -1,13 +1,16 @@
package tschipp.carryon.client.render; package tschipp.carryon.client.render;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.MultiBufferSource.BufferSource; import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.HumanoidArm;
@ -26,11 +29,20 @@ import tschipp.carryon.common.scripting.CarryOnScript;
import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender; import tschipp.carryon.common.scripting.CarryOnScript.ScriptRender;
import tschipp.carryon.platform.Services; import tschipp.carryon.platform.Services;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class CarriedObjectRender public class CarriedObjectRender
{ {
private static Map<RenderType, BufferBuilder> builders = Map.of(
RenderType.glint(), new BufferBuilder(RenderType.glint().bufferSize()),
RenderType.glintDirect(), new BufferBuilder(RenderType.glintDirect().bufferSize()),
RenderType.glintTranslucent(), new BufferBuilder(RenderType.glintTranslucent().bufferSize()),
RenderType.entityGlint(), new BufferBuilder(RenderType.entityGlint().bufferSize()),
RenderType.entityGlintDirect(), new BufferBuilder(RenderType.entityGlintDirect().bufferSize())
);
public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks) public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks)
{ {
if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod")) if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod"))
@ -133,10 +145,11 @@ public class CarriedObjectRender
{ {
} }
manager.setRenderShadow(true); manager.setRenderShadow(true);
matrix.popPose();
} }
// RenderSystem.disableAlphaTest(); // RenderSystem.disableAlphaTest();
matrix.popPose();
} }
/** /**
@ -147,7 +160,6 @@ public class CarriedObjectRender
public static void drawThirdPerson(float partialticks, PoseStack matrix) { public static void drawThirdPerson(float partialticks, PoseStack matrix) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
Level level = mc.level; Level level = mc.level;
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
int light = 0; int light = 0;
int perspective = CarryRenderHelper.getPerspective(); int perspective = CarryRenderHelper.getPerspective();
EntityRenderDispatcher manager = mc.getEntityRenderDispatcher(); EntityRenderDispatcher manager = mc.getEntityRenderDispatcher();
@ -156,9 +168,12 @@ public class CarriedObjectRender
RenderSystem.disableCull(); RenderSystem.disableCull();
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, Tesselator.getInstance().getBuilder());
for (Player player : level.players()) for (Player player : level.players())
{ {
try { try {
CarryOnData carry = CarryOnDataManager.getCarryData(player); CarryOnData carry = CarryOnDataManager.getCarryData(player);
if (perspective == 0 && player == mc.player && !(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod"))) if (perspective == 0 && player == mc.player && !(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod")))
@ -193,7 +208,6 @@ public class CarriedObjectRender
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
CarryRenderHelper.renderBakedModel(tileItem, copy, buffer, light, model); CarryRenderHelper.renderBakedModel(tileItem, copy, buffer, light, model);
buffer.endBatch();
matrix.popPose(); matrix.popPose();
} else if (carry.isCarrying(CarryType.ENTITY)) { } else if (carry.isCarrying(CarryType.ENTITY)) {
@ -216,19 +230,26 @@ public class CarriedObjectRender
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light); manager.render(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
buffer.endBatch();
matrix.popPose(); matrix.popPose();
manager.setRenderShadow(true); manager.setRenderShadow(true);
matrix.popPose(); matrix.popPose();
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
} }
} }
buffer.endLastBatch();
buffer.endBatch(RenderType.entitySolid(TextureAtlas.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entityCutout(TextureAtlas.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entityCutoutNoCull(TextureAtlas.LOCATION_BLOCKS));
buffer.endBatch(RenderType.entitySmoothCutout(TextureAtlas.LOCATION_BLOCKS));
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
RenderSystem.enableCull(); RenderSystem.enableCull();
RenderSystem.disableBlend(); RenderSystem.disableBlend();

View File

@ -1,12 +1,10 @@
package tschipp.carryon.client.render; package tschipp.carryon.client.render;
import com.mojang.authlib.minecraft.client.MinecraftClient;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;

View File

@ -6,12 +6,14 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import tschipp.carryon.Constants;
import tschipp.carryon.common.scripting.CarryOnScript; import tschipp.carryon.common.scripting.CarryOnScript;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -121,7 +123,13 @@ public class CarryOnData {
if(this.type != CarryType.ENTITY) if(this.type != CarryType.ENTITY)
throw new IllegalStateException("Called getEntity on data that contained " + this.type); throw new IllegalStateException("Called getEntity on data that contained " + this.type);
return EntityType.create(nbt.getCompound("entity"), level).orElseThrow(() -> new IllegalStateException("Called EntityType#create even though no entity data was present. Data: " + nbt.toString())); var optionalEntity = EntityType.create(nbt.getCompound("entity"), level);
if(optionalEntity.isPresent())
return optionalEntity.get();
Constants.LOG.error("Called EntityType#create even though no entity data was present. Data: " + nbt.toString());
this.clear();
return new AreaEffectCloud(level, 0, 0, 0);
} }
public Optional<CarryOnScript> getActiveScript() public Optional<CarryOnScript> getActiveScript()

View File

@ -137,6 +137,9 @@ public class PickupHandler {
if (entity.invulnerableTime != 0) if (entity.invulnerableTime != 0)
return false; return false;
if(entity.isRemoved())
return false;
if (entity instanceof TamableAnimal tame) if (entity instanceof TamableAnimal tame)
{ {
UUID owner = tame.getOwnerUUID(); UUID owner = tame.getOwnerUUID();

View File

@ -1,7 +1,6 @@
package tschipp.carryon.common.carry; package tschipp.carryon.common.carry;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
@ -29,6 +28,8 @@ import tschipp.carryon.common.config.ListHandler;
import tschipp.carryon.common.scripting.CarryOnScript.ScriptEffects; import tschipp.carryon.common.scripting.CarryOnScript.ScriptEffects;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@ -77,8 +78,11 @@ public class PlacementHandler
} }
level.setBlockAndUpdate(pos, state); level.setBlockAndUpdate(pos, state);
if (blockEntity != null) if (blockEntity != null) {
blockEntity.setBlockState(state);
level.setBlockEntity(blockEntity); level.setBlockEntity(blockEntity);
}
level.updateNeighborsAt(pos.relative(Direction.DOWN), level.getBlockState(pos.relative(Direction.DOWN)).getBlock()); level.updateNeighborsAt(pos.relative(Direction.DOWN), level.getBlockState(pos.relative(Direction.DOWN)).getBlock());
carry.clear(); carry.clear();
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
@ -284,30 +288,34 @@ public class PlacementHandler
private static BlockPos getDeathPlacementPos(BlockState state, ServerPlayer player) private static BlockPos getDeathPlacementPos(BlockState state, ServerPlayer player)
{ {
MutableBlockPos pos = new MutableBlockPos();
BlockPos p = player.blockPosition(); BlockPos p = player.blockPosition();
int DISTANCE = 15; int DISTANCE = 15;
List<BlockPos> potentialPositions = new ArrayList<>();
for (int j = 0; j < DISTANCE * 2; j++) { for (int j = 0; j < DISTANCE * 2; j++) {
for (int i = 0; i < DISTANCE * 2; i++) { for (int i = 0; i < DISTANCE * 2; i++) {
for (int k = 0; k < DISTANCE * 2; k++) { for (int k = 0; k < DISTANCE * 2; k++) {
int x = i % 2 == 0 ? i / 2 : -(i / 2); int x = i % 2 == 0 ? i / 2 : -(i / 2);
int y = j % 2 == 0 ? j / 2 : -(j / 2); int y = j % 2 == 0 ? j / 2 : -(j / 2);
int z = k % 2 == 0 ? k / 2 : -(k / 2); int z = k % 2 == 0 ? k / 2 : -(k / 2);
potentialPositions.add(new BlockPos(p.getX() + x, p.getY() + y, p.getZ() + z));
pos.set(p.getX() + x, p.getY() + y, p.getZ() + z);
BlockPlaceContext context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(Vec3.atCenterOf(pos), Direction.DOWN, pos));
boolean canPlace = state.canSurvive(player.level, pos) && player.level.getBlockState(pos).canBeReplaced(context) && player.level.isUnobstructed(state, pos, CollisionContext.of(player));
if (canPlace)
return pos;
} }
} }
} }
potentialPositions.sort(Comparator.comparingDouble(posA -> posA.distToCenterSqr(player.position())));
for(BlockPos potential : potentialPositions)
{
BlockPlaceContext context = new BlockPlaceContext(player, InteractionHand.MAIN_HAND, ItemStack.EMPTY, BlockHitResult.miss(Vec3.atCenterOf(potential), Direction.DOWN, potential));
boolean canPlace = state.canSurvive(player.level, potential) && player.level.getBlockState(potential).canBeReplaced(context) && player.level.isUnobstructed(state, potential, CollisionContext.of(player));
if (canPlace)
return potential;
}
return p; return p;
} }

View File

@ -5,302 +5,318 @@ import tschipp.carryon.config.annotations.Category;
import tschipp.carryon.config.annotations.Config; import tschipp.carryon.config.annotations.Config;
import tschipp.carryon.config.annotations.Property; import tschipp.carryon.config.annotations.Property;
public class CarryConfig { public class CarryConfig
{
@Config("carryon-common") @Config("carryon-common")
public static class Common { public static class Common
//Settings {
@Property( //Settings
type = PropertyType.CATEGORY, @Property(
description = "General Settings" type = PropertyType.CATEGORY,
) description = "General Settings"
public Settings settings = new Settings(); )
public Settings settings = new Settings();
@Category("settings") @Category("settings")
public static class Settings { public static class Settings
@Property( {
type = PropertyType.DOUBLE, @Property(
description = "Maximum distance from where Blocks and Entities can be picked up", type = PropertyType.DOUBLE,
minD = 0 description = "Maximum distance from where Blocks and Entities can be picked up",
) minD = 0
public double maxDistance = 2.5; )
public double maxDistance = 2.5;
@Property( @Property(
type = PropertyType.DOUBLE, type = PropertyType.DOUBLE,
description = "Max width of entities that can be picked up in survival mode", description = "Max width of entities that can be picked up in survival mode",
minD = 0, minD = 0,
maxD = 10 maxD = 10
) )
public double maxEntityWidth = 1.5; public double maxEntityWidth = 1.5;
@Property( @Property(
type = PropertyType.DOUBLE, type = PropertyType.DOUBLE,
description = "Max height of entities that can be picked up in survival mode", description = "Max height of entities that can be picked up in survival mode",
minD = 0, minD = 0,
maxD = 10 maxD = 10
) )
public double maxEntityHeight = 2.5; public double maxEntityHeight = 2.5;
@Property( @Property(
type = PropertyType.DOUBLE, type = PropertyType.DOUBLE,
description = "Slowness multiplier for blocks", description = "Slowness multiplier for blocks",
minD = 0 minD = 0
) )
public double blockSlownessMultiplier = 1; public double blockSlownessMultiplier = 1;
@Property( @Property(
type = PropertyType.DOUBLE, type = PropertyType.DOUBLE,
description = "Slowness multiplier for entities", description = "Slowness multiplier for entities",
minD = 0 minD = 0
) )
public double entitySlownessMultiplier = 1; public double entitySlownessMultiplier = 1;
@Property( @Property(
type = PropertyType.INT, type = PropertyType.INT,
description = "Maximum stack limit for entities", description = "Maximum stack limit for entities",
min = 1 min = 1
) )
public int maxEntityStackLimit = 10; public int maxEntityStackLimit = 10;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "More complex Tile Entities slow down the player more" description = "More complex Tile Entities slow down the player more"
) )
public boolean heavyTiles = true; public boolean heavyTiles = true;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Allow all blocks to be picked up, not just Tile Entites. White/Blacklist will still be respected." description = "Allow all blocks to be picked up, not just Tile Entites. White/Blacklist will still be respected."
) )
public boolean pickupAllBlocks = false; public boolean pickupAllBlocks = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether Blocks and Entities slow the creative player down when carried" description = "Whether Blocks and Entities slow the creative player down when carried"
) )
public boolean slownessInCreative = true; public boolean slownessInCreative = true;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether hostile mobs should be able to picked up in survival mode" description = "Whether hostile mobs should be able to picked up in survival mode"
) )
public boolean pickupHostileMobs = false; public boolean pickupHostileMobs = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Larger Entities slow down the player more" description = "Larger Entities slow down the player more"
) )
public boolean heavyEntities = true; public boolean heavyEntities = true;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)" description = "Allow babies to be carried even when adult mob is blacklisted (or not whitelisted)"
) )
public boolean allowBabies = false; public boolean allowBabies = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Use Whitelist instead of Blacklist for Blocks" description = "Use Whitelist instead of Blacklist for Blocks"
) )
public boolean useWhitelistBlocks = false; public boolean useWhitelistBlocks = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Use Whitelist instead of Blacklist for Entities" description = "Use Whitelist instead of Blacklist for Entities"
) )
public boolean useWhitelistEntities = false; public boolean useWhitelistEntities = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Use Whitelist instead of Blacklist for Stacking" description = "Use Whitelist instead of Blacklist for Stacking"
) )
public boolean useWhitelistStacking = false; public boolean useWhitelistStacking = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether the player can hit blocks and entities while carrying or not" description = "Whether the player can hit blocks and entities while carrying or not"
) )
public boolean hitWhileCarrying = false; public boolean hitWhileCarrying = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether the player drops the carried object when hit or not" description = "Whether the player drops the carried object when hit or not"
) )
public boolean dropCarriedWhenHit = false; public boolean dropCarriedWhenHit = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance" description = "Use custom Pickup Scripts. Having this set to false, will not allow you to run scripts, but will increase your performance"
) )
public boolean useScripts = false; public boolean useScripts = false;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Allows entities to be stacked on top of each other" description = "Allows entities to be stacked on top of each other"
) )
public boolean stackableEntities = true; public boolean stackableEntities = true;
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether entities' size matters when stacking or not. This means that larger entities cannot be stacked on smaller ones" description = "Whether entities' size matters when stacking or not. This means that larger entities cannot be stacked on smaller ones"
) )
public boolean entitySizeMattersStacking = true; public boolean entitySizeMattersStacking = true;
@Property( @Property(
type = PropertyType.STRING_ARRAY, type = PropertyType.STRING_ARRAY,
description = "Usually all the block state information is retained when placing a block that was picked up. But some information is changed to a modified property, like rotation or orientation. In this list, add additional properties that should NOT be saved and instead be updated when placed. Format: modid:block[propertyname]. Note: You don't need to add an entry for every subtype of a same block. For example, we only add an entry for one type of slab, but the change is applied to all slabs." description = "Usually all the block state information is retained when placing a block that was picked up. But some information is changed to a modified property, like rotation or orientation. In this list, add additional properties that should NOT be saved and instead be updated when placed. Format: modid:block[propertyname]. Note: You don't need to add an entry for every subtype of a same block. For example, we only add an entry for one type of slab, but the change is applied to all slabs."
) )
public String[] placementStateExceptions = { public String[] placementStateExceptions = {
"minecraft:chest[type]", "minecraft:chest[type]",
"minecraft:stone_button[face]", "minecraft:stone_button[face]",
"minecraft:vine[north,east,south,west,up]", "minecraft:vine[north,east,south,west,up]",
"minecraft:creeper_head[rotation]", "minecraft:creeper_head[rotation]",
"minecraft:glow_lichen[north,east,south,west,up,down]", "minecraft:glow_lichen[north,east,south,west,up,down]",
"minecraft:oak_sign[rotation]", "minecraft:oak_sign[rotation]",
"minecraft:oak_trapdoor[half]", "minecraft:oak_trapdoor[half]",
}; };
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.BOOLEAN,
description = "Whether Players can be picked up. Creative players can't be picked up in Survival Mode" description = "Whether Players can be picked up. Creative players can't be picked up in Survival Mode"
) )
public boolean pickupPlayers = true; public boolean pickupPlayers = true;
} }
@Property( @Property(
type = PropertyType.CATEGORY, type = PropertyType.CATEGORY,
description = "Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config" description = "Whitelist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"
) )
//Whitelist //Whitelist
public Whitelist whitelist = new Whitelist(); public Whitelist whitelist = new Whitelist();
@Category("whitelist")
public static class Whitelist {
@Property(
type = PropertyType.STRING_ARRAY,
description = "Entities that CAN be picked up (useWhitelistEntities must be true)"
)
public String[] allowedEntities = {};
@Property( @Category("whitelist")
type = PropertyType.STRING_ARRAY, public static class Whitelist
description = "Blocks that CAN be picked up (useWhitelistBlocks must be true)" {
) @Property(
public String[] allowedBlocks = {}; type = PropertyType.STRING_ARRAY,
description = "Entities that CAN be picked up (useWhitelistEntities must be true)"
)
public String[] allowedEntities = {};
@Property( @Property(
type = PropertyType.STRING_ARRAY, type = PropertyType.STRING_ARRAY,
description = "Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)" description = "Blocks that CAN be picked up (useWhitelistBlocks must be true)"
) )
public String[] allowedStacking = {}; public String[] allowedBlocks = {};
}
//Blacklist @Property(
@Property( type = PropertyType.STRING_ARRAY,
type = PropertyType.CATEGORY, description = "Entities that CAN have other entities stacked on top of them (useWhitelistStacking must be true)"
description = "Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config" )
) public String[] allowedStacking = {};
public Blacklist blacklist = new Blacklist(); }
@Category("blacklist")
public static class Blacklist {
@Property(
type = PropertyType.STRING_ARRAY,
description = "Blocks that cannot be picked up"
)
public String[] forbiddenTiles = {
"#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:piston_head",
"minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony",
"minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed",
"minecraft:*_door", "minecraft:big_dripleaf_stem", "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:*", "contact:*", "framedblocks:*"
};
@Property( //Blacklist
type = PropertyType.STRING_ARRAY, @Property(
description = "Entities that cannot be picked up" type = PropertyType.CATEGORY,
) description = "Blacklist. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Black---and-Whitelist-Config"
public String[] forbiddenEntities = { )
"minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast", public Blacklist blacklist = new Blacklist();
"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:*"
};
@Property( @Category("blacklist")
type = PropertyType.STRING_ARRAY, public static class Blacklist
description = "Entities that cannot have other entities stacked on top of them" {
) @Property(
public String[] forbiddenStacking = { type = PropertyType.STRING_ARRAY,
"minecraft:horse" description = "Blocks that cannot be picked up"
}; )
} public String[] forbiddenTiles = {
"#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:piston_head",
"minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony",
"minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed",
"minecraft:*_door", "minecraft:big_dripleaf_stem", "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:*", "contact:*", "framedblocks:*", "securitycraft:*", "forgemultipartcbe:*", "integrateddynamics:cable",
"mekanismgenerators:wind_generator", "cookingforblockheads:cabinet", "cookingforblockheads:corner", "cookingforblockheads:counter",
"cookingforblockheads:oven", "cookingforblockheads:toaster", "cookingforblockheads:milk_jar", "cookingforblockheads:cow_jar",
"cookingforblockheads:fruit_basket", "cookingforblockheads:cooking_table", "cookingforblockheads:fridge", "cookingforblockheads:sink",
"chipped:*",
"powah:*", "advancementtrophies:trophy", "mekanismgenerators:heat_generator", "mna:filler_block", "create_enchantment_industry:*", "graveyard:*", "immersivepetroleum:*", "tardis:interior_door"
};
//Custom Pickup Conditions @Property(
@Property( type = PropertyType.STRING_ARRAY,
type = PropertyType.CATEGORY, description = "Entities that cannot be picked up"
description = "Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config" )
) public String[] forbiddenEntities = {
public CustomPickupConditions customPickupConditions = new CustomPickupConditions(); "minecraft:end_crystal", "minecraft:ender_dragon", "minecraft:ghast",
@Category("customPickupConditions") "minecraft:shulker", "minecraft:leash_knot", "minecraft:armor_stand",
public static class CustomPickupConditions { "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet",
@Property( "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart",
type = PropertyType.STRING_ARRAY, "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*",
description = "Custom Pickup Conditions for Blocks" "securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body"
) };
public String[] customPickupConditionsBlocks = {};
@Property( @Property(
type = PropertyType.STRING_ARRAY, type = PropertyType.STRING_ARRAY,
description = "Custom Pickup Conditions for Entities" description = "Entities that cannot have other entities stacked on top of them"
) )
public String[] customPickupConditionsEntities = {}; public String[] forbiddenStacking = {
} "minecraft:horse"
} };
}
@Config("carryon-client") //Custom Pickup Conditions
public static class Client { @Property(
type = PropertyType.CATEGORY,
description = "Custom Pickup Conditions. Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Custom-Pickup-Condition-Config"
)
public CustomPickupConditions customPickupConditions = new CustomPickupConditions();
@Property( @Category("customPickupConditions")
type = PropertyType.BOOLEAN, public static class CustomPickupConditions
description = "If the front of the Tile Entities should face the player or should face outward" {
) @Property(
public boolean facePlayer = false; type = PropertyType.STRING_ARRAY,
description = "Custom Pickup Conditions for Blocks"
)
public String[] customPickupConditionsBlocks = {};
@Property( @Property(
type = PropertyType.BOOLEAN, type = PropertyType.STRING_ARRAY,
description = "Arms should render on sides when carrying. Set to false if you experience issues with mods that replace the player model (like MoBends, etc)" description = "Custom Pickup Conditions for Entities"
) )
public boolean renderArms = true; public String[] customPickupConditionsEntities = {};
}
}
@Property( @Config("carryon-client")
type = PropertyType.STRING_ARRAY, public static class Client
description = "Model Overrides based on NBT or Meta. Advanced users only! Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config" {
)
public String[] modelOverrides = { @Property(
"minecraft:redstone_wire->(item)minecraft:redstone", type = PropertyType.BOOLEAN,
"minecraft:bamboo_sapling->(block)minecraft:bamboo", description = "If the front of the Tile Entities should face the player or should face outward"
"minecraft:candle_cake->(block)minecraft:cake" )
}; public boolean facePlayer = false;
}
@Property(
type = PropertyType.BOOLEAN,
description = "Arms should render on sides when carrying. Set to false if you experience issues with mods that replace the player model (like MoBends, etc)"
)
public boolean renderArms = true;
@Property(
type = PropertyType.STRING_ARRAY,
description = "Model Overrides based on NBT or Meta. Advanced users only! Read about the format here: https://github.com/Tschipp/CarryOn/wiki/Model-Override-Config"
)
public String[] modelOverrides = {
"minecraft:redstone_wire->(item)minecraft:redstone",
"minecraft:bamboo_sapling->(block)minecraft:bamboo",
"minecraft:candle_cake->(block)minecraft:cake"
};
}
} }

View File

@ -1,6 +1,5 @@
package tschipp.carryon.common.config; package tschipp.carryon.common.config;
import com.mojang.datafixers.kinds.Const;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -30,9 +29,7 @@ public class ListHandler {
private static List<TagKey<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>(); private static List<TagKey<EntityType<?>>> FORBIDDEN_STACKING_TAGS = new ArrayList<>();
private static List<TagKey<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>(); private static List<TagKey<EntityType<?>>> ALLOWED_STACKING_TAGS = new ArrayList<>();
private static Set<Property<?>> PROPERTY_EXCEPTION_CLASSES = new HashSet<>();
private static Set<Class<?>> PROPERTY_EXCEPTION_CLASSES = new HashSet<>();
public static boolean isPermitted(Block block) public static boolean isPermitted(Block block)
{ {
@ -60,7 +57,7 @@ public class ListHandler {
public static boolean isPropertyException(Property<?> prop) public static boolean isPropertyException(Property<?> prop)
{ {
return PROPERTY_EXCEPTION_CLASSES.contains(prop.getValueClass()); return PROPERTY_EXCEPTION_CLASSES.contains(prop);
} }
private static boolean doCheck(Block block, Set<String> regular, List<TagKey<Block>> tags) private static boolean doCheck(Block block, Set<String> regular, List<TagKey<Block>> tags)
@ -138,7 +135,7 @@ public class ListHandler {
for(String propName : props.split(",")) { for(String propName : props.split(",")) {
for (Property<?> prop : blk.defaultBlockState().getProperties()) { for (Property<?> prop : blk.defaultBlockState().getProperties()) {
if (prop.getName().equals(propName)) if (prop.getName().equals(propName))
PROPERTY_EXCEPTION_CLASSES.add(prop.getValueClass()); PROPERTY_EXCEPTION_CLASSES.add(prop);
} }
} }
} }

View File

@ -29,9 +29,7 @@ public final class Matchables
private static float getValueFromStringOrDefault(String toGetFrom, String key, float defaultVal) private static float getValueFromStringOrDefault(String toGetFrom, String key, float defaultVal)
{ {
Optional<Float> val = getValueFromString(toGetFrom, key); Optional<Float> val = getValueFromString(toGetFrom, key);
if(val.isPresent()) return val.orElse(defaultVal);
return val.get();
return defaultVal;
} }
private static Optional<Float> getValueFromString(String toGetFrom, String key) private static Optional<Float> getValueFromString(String toGetFrom, String key)
@ -240,9 +238,9 @@ public final class Matchables
int iG = cond.indexOf(">"); int iG = cond.indexOf(">");
int iL = cond.indexOf("<"); int iL = cond.indexOf("<");
if (iG == -1 ? true : iE < iG && iL == -1 ? true : iE < iL && iE != -1) if (iG == -1 || (iE < iG && iL == -1 || iE < iL && iE != -1))
numb = cond.substring(iE); numb = cond.substring(iE);
else if (iE == -1 ? true : iG < iE && iL == -1 ? true : iG < iL && iG != -1) else if (iE == -1 || (iG < iE && iL == -1 || iG < iL && iG != -1))
numb = cond.substring(iG); numb = cond.substring(iG);
else else
numb = cond.substring(iL); numb = cond.substring(iL);
@ -277,8 +275,8 @@ public final class Matchables
if (cond == null || cond.isEmpty()) if (cond == null || cond.isEmpty())
return true; return true;
BlockPos blockpos = new BlockPos(getValueFromStringOrDefault(cond, "x", 0), getValueFromStringOrDefault(cond, "y", 0), getValueFromStringOrDefault(cond, "z", 0)); BlockPos blockpos = new BlockPos((int) getValueFromStringOrDefault(cond, "x", 0), (int) getValueFromStringOrDefault(cond, "y", 0), (int) getValueFromStringOrDefault(cond, "z", 0));
BlockPos expand = new BlockPos(getValueFromStringOrDefault(cond, "dx", 0), getValueFromStringOrDefault(cond, "dy", 0), getValueFromStringOrDefault(cond, "dz", 0)); BlockPos expand = new BlockPos((int) getValueFromStringOrDefault(cond, "dx", 0), (int) getValueFromStringOrDefault(cond, "dy", 0), (int) getValueFromStringOrDefault(cond, "dz", 0));
BlockPos expanded = blockpos.offset(expand); BlockPos expanded = blockpos.offset(expand);
BlockPos pos = elem.blockPosition(); BlockPos pos = elem.blockPosition();

View File

@ -16,18 +16,26 @@ if (System.getenv('BUILD_NUMBER') != null) {
} }
repositories { repositories {
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven {
url "https://maven.siphalor.de/"
name "Siphalor's Maven"
}
} }
dependencies { dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}" minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings() mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchment_mappings_fabric}@zip")
}
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation project(":Common") implementation project(":Common")
include implementation("com.github.LlamaLad7:MixinExtras:${mixinextras_version}") modRuntimeOnly "de.siphalor:amecsapi-1.19:1.5.0+mc22w17a"
annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}") include implementation("com.github.llamalad7.mixinextras:mixinextras-fabric:${mixinextras_version}")
annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${mixinextras_version}")
} }
loom { loom {

View File

@ -0,0 +1,66 @@
package tschipp.carryon.compat;
import net.fabricmc.fabric.api.event.Event;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import tschipp.carryon.Constants;
import tschipp.carryon.platform.Services;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ArchitecturyCompat {
private static Object INVOKER_INSTANCE;
private static Method PLACE_BLOCK;
private static Method IS_FALSE;
private static void setup( ) {
try {
Class BlockEvent = Class.forName("dev.architectury.event.events.common.BlockEvent");
Field PLACE = BlockEvent.getField("PLACE");
Method invoker = Class.forName("dev.architectury.event.Event").getMethod("invoker");
INVOKER_INSTANCE = invoker.invoke(PLACE.get(BlockEvent));
Class PlaceClass = Class.forName("dev.architectury.event.events.common.BlockEvent$Place");
PLACE_BLOCK = PlaceClass.getMethod("placeBlock", Level.class, BlockPos.class, BlockState.class, Entity.class);
Class EventResult = Class.forName("dev.architectury.event.EventResult");
IS_FALSE = EventResult.getMethod("isFalse");
} catch (Exception e) {
Constants.LOG.warn("Error while initializing Architectury Compat: " + e);
}
}
public static boolean active() {
return Services.PLATFORM.isModLoaded("architectury");
}
public static boolean sendPlaceEvent(Level level, BlockPos pos, BlockState state, Player player) {
if(!active())
return true;
if(INVOKER_INSTANCE == null || PLACE_BLOCK == null)
setup();
if(INVOKER_INSTANCE != null && PLACE_BLOCK != null && IS_FALSE != null) {
try {
Object eventResult = PLACE_BLOCK.invoke(INVOKER_INSTANCE, level, pos, state, player);
boolean canceled = (boolean) IS_FALSE.invoke(eventResult);
return !canceled;
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return true;
}
}

View File

@ -31,6 +31,11 @@ public class ConfigLoaderImpl {
FileUtils.write(cfgFile, GSON.toJson(entry.getKey()), StandardCharsets.UTF_8); FileUtils.write(cfgFile, GSON.toJson(entry.getKey()), StandardCharsets.UTF_8);
} else { } else {
JsonObject cfgJson = GSON.fromJson(FileUtils.readFileToString(cfgFile, StandardCharsets.UTF_8), JsonObject.class); JsonObject cfgJson = GSON.fromJson(FileUtils.readFileToString(cfgFile, StandardCharsets.UTF_8), JsonObject.class);
if(cfgJson == null)
{
cfgPath.toFile().mkdirs();
FileUtils.write(cfgFile, GSON.toJson(entry.getKey()), StandardCharsets.UTF_8);
}
FileUtils.write(cfgFile, GSON.toJson(loadConfig(entry.getValue(), cfgJson)), StandardCharsets.UTF_8); FileUtils.write(cfgFile, GSON.toJson(loadConfig(entry.getValue(), cfgJson)), StandardCharsets.UTF_8);
} }
} }

View File

@ -19,6 +19,7 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
import tschipp.carryon.common.carry.PickupHandler; import tschipp.carryon.common.carry.PickupHandler;
import tschipp.carryon.common.carry.PlacementHandler; import tschipp.carryon.common.carry.PlacementHandler;
import tschipp.carryon.common.scripting.ScriptReloadListener; import tschipp.carryon.common.scripting.ScriptReloadListener;
import tschipp.carryon.compat.ArchitecturyCompat;
import tschipp.carryon.config.ConfigLoader; import tschipp.carryon.config.ConfigLoader;
import tschipp.carryon.scripting.IdentifiableScriptReloadListener; import tschipp.carryon.scripting.IdentifiableScriptReloadListener;
@ -42,7 +43,10 @@ public class CommonEvents {
CarryOnData carry = CarryOnDataManager.getCarryData(player); CarryOnData carry = CarryOnDataManager.getCarryData(player);
if(!carry.isCarrying()) if(!carry.isCarrying())
{ {
if (PickupHandler.tryPickUpBlock((ServerPlayer) player, pos, world, null)) if (PickupHandler.tryPickUpBlock((ServerPlayer) player, pos, world, (pState, pPos) -> {
boolean success = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(world, player, pPos, pState, world.getBlockEntity(pPos));
return success;
}))
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
return InteractionResult.PASS; return InteractionResult.PASS;
} }
@ -50,7 +54,9 @@ public class CommonEvents {
{ {
if(carry.isCarrying(CarryOnData.CarryType.BLOCK)) if(carry.isCarrying(CarryOnData.CarryType.BLOCK))
{ {
if(PlacementHandler.tryPlaceBlock((ServerPlayer) player, pos, facing, null)) if(PlacementHandler.tryPlaceBlock((ServerPlayer) player, pos, facing, (pState, pPos) -> {
return ArchitecturyCompat.sendPlaceEvent(world, pState, pPos, player);
}))
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
else else

View File

@ -30,6 +30,8 @@ if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER') version += "." + System.getenv('BUILD_NUMBER')
} }
jarJar.enable()
archivesBaseName = "${mod_id}-forge-${minecraft_version}" archivesBaseName = "${mod_id}-forge-${minecraft_version}"
mixin { mixin {
@ -100,11 +102,6 @@ minecraft {
sourceSets.main.resources.srcDir 'src/generated/resources' sourceSets.main.resources.srcDir 'src/generated/resources'
configurations {
shade
implementation.extendsFrom shade
}
repositories { repositories {
maven { maven {
url 'https://maven.blamejared.com' url 'https://maven.blamejared.com'
@ -121,7 +118,13 @@ dependencies {
compileOnly project(":Common") compileOnly project(":Common")
implementation 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") implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.2:16.1.9")
minecraftLibrary(annotationProcessor(shade(("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")))) //minecraftLibrary("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
//jarJar(group: 'com.github.LlamaLad7', name: 'MixinExtras', version: "[${mixinextras_version},)")
//annotationProcessor("com.github.LlamaLad7:MixinExtras:${mixinextras_version}")
implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}"))
implementation(jarJar("com.github.llamalad7.mixinextras:mixinextras-forge:${mixinextras_version}")) {
jarJar.ranged(it, "[${mixinextras_version},)")
}
annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor' annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
fileTree("libs").matching { fileTree("libs").matching {
@ -135,17 +138,8 @@ dependencies {
} }
} }
shadowJar {
configurations = [project.configurations.shade]
relocate 'com.llamalad7.mixinextras', 'tschipp.carryon.shaded.mixinextras'
finalizedBy 'reobfShadowJar'
archiveClassifier = ""
}
assemble.dependsOn shadowJar
reobf { reobf {
shadowJar {} jarJar {}
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {

View File

@ -1,6 +1,7 @@
package tschipp.carryon; package tschipp.carryon;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@ -20,7 +21,6 @@ public class CarryOnForge {
// This method is invoked by the Forge mod loader when it is ready // This method is invoked by the Forge mod loader when it is ready
// to load your mod. You can access Forge and Common code in this // to load your mod. You can access Forge and Common code in this
// project. // project.
// Use Forge to bootstrap the Common mod. // Use Forge to bootstrap the Common mod.
CarryOnCommon.registerConfig(); CarryOnCommon.registerConfig();

View File

@ -11,10 +11,7 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import tschipp.carryon.config.*; import tschipp.carryon.config.*;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ConfigLoaderImpl { public class ConfigLoaderImpl {
@ -95,7 +92,14 @@ public class ConfigLoaderImpl {
case BOOLEAN -> builder.define(data.getId(), data.getBoolean()); case BOOLEAN -> builder.define(data.getId(), data.getBoolean());
case INT -> builder.defineInRange(data.getId(), data.getInt(), annotationData.min(), annotationData.max()); 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 DOUBLE -> builder.defineInRange(data.getId(), data.getDouble(), annotationData.minD(), annotationData.maxD());
case STRING_ARRAY -> builder.defineList(data.getId(), Arrays.asList(data.getStringArray()), obj -> true); case STRING_ARRAY -> builder.defineListAllowEmpty(List.of(data.getId()), () -> {
try {
return Arrays.asList(data.getStringArray());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return new ArrayList<>();
}, obj -> obj instanceof String);
default -> throw new IllegalAccessException("Unknown property type."); default -> throw new IllegalAccessException("Unknown property type.");
} }
} }

View File

@ -8,11 +8,13 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.OnDatapackSyncEvent; import net.minecraftforge.event.OnDatapackSyncEvent;
import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TagsUpdatedEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.event.TickEvent.ServerTickEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
@ -37,6 +39,7 @@ import tschipp.carryon.common.carry.CarryOnDataManager;
import tschipp.carryon.common.carry.PickupHandler; import tschipp.carryon.common.carry.PickupHandler;
import tschipp.carryon.common.carry.PlacementHandler; import tschipp.carryon.common.carry.PlacementHandler;
import tschipp.carryon.common.scripting.ScriptReloadListener; import tschipp.carryon.common.scripting.ScriptReloadListener;
import tschipp.carryon.config.ConfigLoader;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
public class CommonEvents public class CommonEvents
@ -114,7 +117,6 @@ public class CommonEvents
MinecraftForge.EVENT_BUS.post(pickupEvent); MinecraftForge.EVENT_BUS.post(pickupEvent);
return !pickupEvent.isCanceled(); return !pickupEvent.isCanceled();
})) { })) {
event.setResult(Result.DENY);
event.setCancellationResult(InteractionResult.SUCCESS); event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true); event.setCanceled(true);
return; return;
@ -147,6 +149,12 @@ public class CommonEvents
ScriptReloadListener.syncScriptsWithClient(player); ScriptReloadListener.syncScriptsWithClient(player);
} }
@SubscribeEvent
public static void onTagsUpdate(TagsUpdatedEvent event)
{
ConfigLoader.onConfigLoaded();
}
@SubscribeEvent @SubscribeEvent
public static void onServerTick(ServerTickEvent event) public static void onServerTick(ServerTickEvent event)
{ {

View File

@ -5,7 +5,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.InterModComms.IMCMessage; import net.minecraftforge.fml.InterModComms.IMCMessage;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import tschipp.carryon.Constants; import tschipp.carryon.Constants;
import tschipp.carryon.client.modeloverride.ModelOverrideHandler; import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
import tschipp.carryon.common.config.ListHandler; import tschipp.carryon.common.config.ListHandler;
@ -16,7 +17,7 @@ import java.util.stream.Stream;
public class ModBusEvents { public class ModBusEvents {
@SubscribeEvent(priority = EventPriority.LOW) @SubscribeEvent(priority = EventPriority.LOW)
public void serverLoad(FMLDedicatedServerSetupEvent event) public static void serverLoad(InterModProcessEvent event)
{ {
Stream<IMCMessage> messages = InterModComms.getMessages(Constants.MOD_ID); Stream<IMCMessage> messages = InterModComms.getMessages(Constants.MOD_ID);
@ -28,6 +29,7 @@ public class ModBusEvents {
if (!(obj instanceof String str)) if (!(obj instanceof String str))
return; return;
switch (method) { switch (method) {
case "blacklistBlock": case "blacklistBlock":
ListHandler.addForbiddenTiles(str); ListHandler.addForbiddenTiles(str);

View File

@ -1,5 +1,5 @@
# Project # Project
version=2.0.4 version=2.1.2
group=tschipp.carryon group=tschipp.carryon
# Common # Common
@ -14,8 +14,9 @@ parchment_mappings=2022.11.20-1.19.2
//forge_ats_enabled=true //forge_ats_enabled=true
# Fabric # Fabric
parchment_mappings_fabric=1.19.2:2022.11.27
fabric_version=0.62.0+1.19.2 fabric_version=0.62.0+1.19.2
fabric_loader_version=0.14.9 fabric_loader_version=0.14.11
# Quilt # Quilt
quilt_loader_version=0.16.0-beta.7 quilt_loader_version=0.16.0-beta.7
@ -30,4 +31,4 @@ mod_id=carryon
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
mixinextras_version=0.2.0-beta.1 mixinextras_version=0.2.0-beta.6