diff --git a/CHANGELOG.md b/CHANGELOG.md index 07f22c8..482520d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Changes +- Added vanilla rendering mode. Accessible by turning off the automatically enabled Barricade resource pack. + ## Bugfixes - Fixed fences connecting to directional and advanced barrier blocks. - Fixed operator models not updating upon gamemode switch. diff --git a/buildSrc/src/main/kotlin/net/modgarden/barricade/gradle/Versions.kt b/buildSrc/src/main/kotlin/net/modgarden/barricade/gradle/Versions.kt index fead7d9..7ce8488 100644 --- a/buildSrc/src/main/kotlin/net/modgarden/barricade/gradle/Versions.kt +++ b/buildSrc/src/main/kotlin/net/modgarden/barricade/gradle/Versions.kt @@ -1,7 +1,7 @@ package net.modgarden.barricade.gradle object Versions { - const val MOD = "1.1.1" + const val MOD = "1.2.0" const val MINECRAFT = "1.21.1" const val PARCHMENT_MINECRAFT = "1.21" diff --git a/common/src/main/java/net/modgarden/barricade/Barricade.java b/common/src/main/java/net/modgarden/barricade/Barricade.java index 52d49f7..d475216 100644 --- a/common/src/main/java/net/modgarden/barricade/Barricade.java +++ b/common/src/main/java/net/modgarden/barricade/Barricade.java @@ -1,38 +1,22 @@ package net.modgarden.barricade; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.modgarden.barricade.client.BarricadeClient; +import net.modgarden.barricade.client.model.OperatorBakedModelAccess; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class Barricade { public static final String MOD_ID = "barricade"; public static final String MOD_NAME = "Barricade"; public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); - // The below is only added to on the client, but we don't want to call to it. - private static final List operatorModels = new ArrayList<>(); - - public static boolean isOperatorModel(Block block) { - return operatorModels.contains(block.builtInRegistryHolder().key().location()); + public static boolean isOperatorModel(BlockState state) { + return BarricadeClient.getHelper() != null && Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(state) instanceof OperatorBakedModelAccess; } - public static void addToOperatorModelCache(ResourceLocation id) { - operatorModels.add(id.withPath(s -> { - String split = s.split("/", 3)[2]; - return split.substring(0, split.length() - 5); - })); - } - - public static void removeFromOperatorModelCache(ResourceLocation id) { - operatorModels.remove(id.withPath(s -> { - String split = s.split("/", 3)[2]; - return split.substring(0, split.length() - 5); - })); - } public static ResourceLocation asResource(String path) { return ResourceLocation.fromNamespaceAndPath(MOD_ID, path); } diff --git a/common/src/main/java/net/modgarden/barricade/client/particle/AdvancedBarrierParticle.java b/common/src/main/java/net/modgarden/barricade/client/particle/AdvancedBarrierParticle.java new file mode 100644 index 0000000..735a671 --- /dev/null +++ b/common/src/main/java/net/modgarden/barricade/client/particle/AdvancedBarrierParticle.java @@ -0,0 +1,103 @@ +package net.modgarden.barricade.client.particle; + +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.ParticleRenderType; +import net.minecraft.client.particle.TextureSheetParticle; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.modgarden.barricade.Barricade; +import net.modgarden.barricade.client.util.BarrierRenderUtils; +import net.modgarden.barricade.component.BlockedDirectionsComponent; +import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; +import org.jetbrains.annotations.Nullable; +import org.joml.Quaternionf; + +import java.util.Optional; + +public class AdvancedBarrierParticle extends TextureSheetParticle { + private final BlockedDirectionsComponent blockedDirections; + private final BlockedDirectionsComponent relative; + private final ResourceLocation backTextureLocation; + private final Optional origin; + private int removeTicks = 0; + + AdvancedBarrierParticle(BlockedDirectionsComponent blockedDirections, @Nullable ResourceLocation backTextureLocation, Optional origin, ClientLevel level, double x, double y, double z) { + super(level, x, y, z); + this.gravity = 0.0F; + this.lifetime = 80; + this.hasPhysics = false; + this.blockedDirections = blockedDirections; + this.backTextureLocation = backTextureLocation; + this.origin = origin; + this.relative = origin.map(pos -> BarrierRenderUtils.relativeDirectionsComponent(blockedDirections, pos)).orElse(blockedDirections); + } + + @Override + public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) { + if (blockedDirections != null && origin.isPresent() && !blockedDirections.blocksAll() && !blockedDirections.doesNotBlock() && !relative.equals(BarrierRenderUtils.relativeDirectionsComponent(blockedDirections, origin.get()))) { + if (removeTicks > 4) { + remove(); + } + removeTicks++; + return; + } + removeTicks = 0; + + Quaternionf quaternionf = new Quaternionf(); + this.getFacingCameraMode().setRotation(quaternionf, renderInfo, partialTicks); + if (this.roll != 0.0F) { + quaternionf.rotateZ(Mth.lerp(partialTicks, this.oRoll, this.roll)); + } + + if (!relative.blocksAll()) { + this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(Barricade.asResource("item/barricade/no_barrier"))); + this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); + } + if (backTextureLocation != null) { + try { + this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(backTextureLocation)); + } catch (IllegalStateException ex) { + this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(ResourceLocation.withDefaultNamespace("missingno"))); + } + this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); + } + if (!relative.blocksAll()) { + for (Direction direction : relative.directions()) { + this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(Barricade.asResource("item/barricade/direction/" + direction.getName()))); + this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); + } + } + + if (relative.blocksAll()) { + this.setSprite(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(ResourceLocation.withDefaultNamespace("item/barrier"))); + this.renderRotatedQuad(buffer, renderInfo, quaternionf, partialTicks); + } + } + + @Override + public ParticleRenderType getRenderType() { + return ParticleRenderType.TERRAIN_SHEET; + } + + @Override + public float getQuadSize(float scaleFactor) { + return 0.5F; + } + + public static class Provider implements ParticleProvider { + + @Override + public @Nullable Particle createParticle(AdvancedBarrierParticleOptions type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { + + return new AdvancedBarrierParticle(type.blockedDirections(), type.backTextureLocation(), type.origin(), level, x, y, z); + } + } +} diff --git a/common/src/main/java/net/modgarden/barricade/client/platform/BarricadeClientPlatformHelper.java b/common/src/main/java/net/modgarden/barricade/client/platform/BarricadeClientPlatformHelper.java index 00413e7..6b33d9e 100644 --- a/common/src/main/java/net/modgarden/barricade/client/platform/BarricadeClientPlatformHelper.java +++ b/common/src/main/java/net/modgarden/barricade/client/platform/BarricadeClientPlatformHelper.java @@ -25,4 +25,5 @@ public interface BarricadeClientPlatformHelper { BakedModel createCreativeOnlyModel(BakedModel model, Either> requiredItem); + String getPackName(String name); } diff --git a/common/src/main/java/net/modgarden/barricade/client/renderer/block/AdvancedBarrierBlockRenderer.java b/common/src/main/java/net/modgarden/barricade/client/renderer/block/AdvancedBarrierBlockRenderer.java index 9ca130a..904ef2a 100644 --- a/common/src/main/java/net/modgarden/barricade/client/renderer/block/AdvancedBarrierBlockRenderer.java +++ b/common/src/main/java/net/modgarden/barricade/client/renderer/block/AdvancedBarrierBlockRenderer.java @@ -15,6 +15,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.GameType; +import net.minecraft.world.level.block.Blocks; import net.modgarden.barricade.Barricade; import net.modgarden.barricade.block.entity.AdvancedBarrierBlockEntity; import net.modgarden.barricade.client.BarricadeClient; @@ -31,7 +32,7 @@ public class AdvancedBarrierBlockRenderer implements BlockEntityRenderer stack.is(BarricadeTags.ItemTags.BARRIERS))) + if (!Barricade.isOperatorModel(Blocks.BARRIER.defaultBlockState()) || !Minecraft.getInstance().player.canUseGameMasterBlocks() || !Minecraft.getInstance().player.isHolding(stack -> stack.is(BarricadeTags.ItemTags.BARRIERS))) return; AdvancedBarrierComponents components = new AdvancedBarrierComponents(blockEntity.getBlockedEntities(), blockEntity.getBlockedDirections()); @@ -55,8 +56,6 @@ private static BakedModel createModel(AdvancedBarrierComponents components) { variant = components.blockedEntities().backTextureLocation() + "," + String.join(",", components.blockedEntities().entities().stream().map(either -> either.map(tagKey -> "#" + tagKey.location(), holder -> holder.unwrapKey().map(ResourceKey::location).orElse(ResourceLocation.withDefaultNamespace("null")).toString())).toList()); if (components.blockedDirections() != null && !components.blockedDirections().doesNotBlock()) { - if (!variant.isEmpty()) - variant = variant + ","; variant = String.join(",", components.blockedDirections().directions().stream().map(Direction::getName).toList()); } BlockModel blockModel = new AdvancedBarrierBlockUnbakedModel(components.blockedDirections(), components.blockedEntities()); diff --git a/common/src/main/java/net/modgarden/barricade/client/util/BarrierRenderUtils.java b/common/src/main/java/net/modgarden/barricade/client/util/BarrierRenderUtils.java index b19e3a9..2256b25 100644 --- a/common/src/main/java/net/modgarden/barricade/client/util/BarrierRenderUtils.java +++ b/common/src/main/java/net/modgarden/barricade/client/util/BarrierRenderUtils.java @@ -4,28 +4,39 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.core.SectionPos; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.world.item.component.BlockItemStateProperties; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.lighting.LightEngine; +import net.minecraft.world.phys.Vec3; import net.modgarden.barricade.Barricade; import net.modgarden.barricade.client.model.OperatorBakedModelAccess; +import net.modgarden.barricade.component.BlockedDirectionsComponent; import net.modgarden.barricade.item.AdvancedBarrierBlockItem; import net.modgarden.barricade.mixin.client.ClientChunkCacheAccessor; import net.modgarden.barricade.mixin.client.ClientChunkCacheStorageAccessor; import net.modgarden.barricade.mixin.client.LevelRendererInvoker; +import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; import org.jetbrains.annotations.Nullable; +import java.util.EnumSet; import java.util.HashSet; +import java.util.Optional; import java.util.Set; +import java.util.function.Consumer; public class BarrierRenderUtils { public static void refreshOperatorBlocks(ItemStack stack, ItemStack previousStack, ItemStack otherHandStack) { @@ -128,4 +139,111 @@ public static boolean isLightBlockId(ResourceLocation location) { } return false; } + + public static void createAdvancedParticle(BlockedDirectionsComponent directions, @Nullable ResourceLocation backTexture, Consumer optionsConsumer, BlockPos pos) { + if (directions.doesNotBlock()) + optionsConsumer.accept(new AdvancedBarrierParticleOptions(new BlockedDirectionsComponent(EnumSet.noneOf(Direction.class)), null, Optional.of(pos))); + else if (directions.blocksAll()) + optionsConsumer.accept(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState())); + else { + optionsConsumer.accept(new AdvancedBarrierParticleOptions(directions, backTexture, Optional.of(pos))); + } + } + + public static BlockedDirectionsComponent relativeDirectionsComponent(BlockedDirectionsComponent directions, BlockPos pos) { + Set directionSet = new HashSet<>(); + Direction relativeHorizontal = getRelativeHorizontalDirectionToPlayer(); + Direction relativeVertical = getRelativeVerticalDirectionToPlayer(pos); + + Direction relativeNorth; + Direction relativeSouth; + Direction relativeWest; + Direction relativeEast; + Direction relativeUp; + Direction relativeDown; + + switch (relativeHorizontal) { + case SOUTH -> { + relativeSouth = Direction.NORTH; + relativeNorth = Direction.SOUTH; + relativeWest = Direction.EAST; + relativeEast = Direction.WEST; + } + case WEST -> { + relativeSouth = Direction.EAST; + relativeNorth = Direction.WEST; + relativeWest = Direction.SOUTH; + relativeEast = Direction.NORTH; + } + case EAST -> { + relativeSouth = Direction.WEST; + relativeNorth = Direction.EAST; + relativeWest = Direction.NORTH; + relativeEast = Direction.SOUTH; + } + default -> { + relativeSouth = Direction.SOUTH; + relativeNorth = Direction.NORTH; + relativeWest = Direction.WEST; + relativeEast = Direction.EAST; + } + } + + switch (relativeVertical) { + case UP -> { + relativeSouth = Direction.UP; + relativeNorth = Direction.DOWN; + relativeUp = Direction.SOUTH; + relativeDown = Direction.NORTH; + } + case DOWN -> { + relativeSouth = Direction.DOWN; + relativeNorth = Direction.UP; + relativeUp = Direction.NORTH; + relativeDown = Direction.SOUTH; + } + case null, default -> { + relativeUp = Direction.UP; + relativeDown = Direction.DOWN; + } + } + + if (directions.blocks(Direction.NORTH)) + directionSet.add(relativeNorth); + if (directions.blocks(Direction.SOUTH)) + directionSet.add(relativeSouth); + if (directions.blocks(Direction.WEST)) + directionSet.add(relativeWest); + if (directions.blocks(Direction.EAST)) + directionSet.add(relativeEast); + if (directions.blocks(Direction.UP)) + directionSet.add(relativeUp); + if (directions.blocks(Direction.DOWN)) + directionSet.add(relativeDown); + + return BlockedDirectionsComponent.of(directionSet.toArray(Direction[]::new)); + } + + private static Direction getRelativeHorizontalDirectionToPlayer() { + Player player = Minecraft.getInstance().player; + return player.getDirection(); + } + + private static Direction getRelativeVerticalDirectionToPlayer(BlockPos pos) { + Player player = Minecraft.getInstance().player; + + if (player == null) + return null; + + Vec3 direction = new Vec3(0, 1, 0); + double dot = direction.dot(player.position().subtract(pos.getCenter())); + + if (dot >= (0.5 * (player.position().subtract(pos.getCenter()).length()))) + return Direction.UP; + + if (dot <= (-0.9 * (player.position().subtract(pos.getCenter()).length()))) + return Direction.DOWN; + + return null; + } } diff --git a/common/src/main/java/net/modgarden/barricade/component/BlockedDirectionsComponent.java b/common/src/main/java/net/modgarden/barricade/component/BlockedDirectionsComponent.java index 3cb096c..c046248 100644 --- a/common/src/main/java/net/modgarden/barricade/component/BlockedDirectionsComponent.java +++ b/common/src/main/java/net/modgarden/barricade/component/BlockedDirectionsComponent.java @@ -15,17 +15,18 @@ import net.minecraft.world.phys.shapes.Shapes; import java.util.Arrays; +import java.util.EnumSet; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; -public record BlockedDirectionsComponent(Set directions) { - public static final Codec CODEC = StringRepresentable.fromEnum(Direction::values).listOf().flatXmap(directions -> DataResult.success(new BlockedDirectionsComponent(Set.copyOf(directions))), component -> DataResult.success(List.copyOf(component.directions))); +public record BlockedDirectionsComponent(EnumSet directions) { + public static final Codec CODEC = StringRepresentable.fromEnum(Direction::values).listOf().flatXmap(directions -> DataResult.success(BlockedDirectionsComponent.of(directions.toArray(Direction[]::new))), component -> DataResult.success(List.copyOf(component.directions))); public static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodec(CODEC); public static BlockedDirectionsComponent of(Direction... directions) { - return new BlockedDirectionsComponent(Arrays.stream(directions).collect(Collectors.toUnmodifiableSet())); + return new BlockedDirectionsComponent(EnumSet.copyOf(Arrays.stream(directions).toList())); } public Direction blockingDirection(BlockPos pos, CollisionContext context) { @@ -70,10 +71,13 @@ public boolean blocks(Direction direction) { } @Override - public boolean equals(Object other) { - if (!(other instanceof BlockedDirectionsComponent component)) + public boolean equals(Object obj) { + if (obj == this) + return true; + if (!(obj instanceof BlockedDirectionsComponent other)) return false; - return component.directions.equals(directions); + // Why do I have to do this?... + return other.directions.size() == directions.size() && other.directions.containsAll(directions); } @Override diff --git a/common/src/main/java/net/modgarden/barricade/mixin/BlockBehaviourBlockStateBaseMixin.java b/common/src/main/java/net/modgarden/barricade/mixin/BlockBehaviourBlockStateBaseMixin.java index 5ce6e30..562ca44 100644 --- a/common/src/main/java/net/modgarden/barricade/mixin/BlockBehaviourBlockStateBaseMixin.java +++ b/common/src/main/java/net/modgarden/barricade/mixin/BlockBehaviourBlockStateBaseMixin.java @@ -1,9 +1,6 @@ package net.modgarden.barricade.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.BarrierBlock; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; @@ -19,8 +16,15 @@ public abstract class BlockBehaviourBlockStateBaseMixin { @ModifyReturnValue(method = "getRenderShape", at = @At("RETURN")) private RenderShape barricade$setRenderShapeDependingOnModel(RenderShape original) { - if (Barricade.isOperatorModel(asState().getBlock())) + if (Barricade.isOperatorModel(asState())) return RenderShape.MODEL; return original; } + + @ModifyReturnValue(method = "shouldSpawnTerrainParticles", at = @At("RETURN")) + private boolean barricade$setRenderShapeDependingOnModel(boolean original) { + if (Barricade.isOperatorModel(asState())) + return false; + return original; + } } diff --git a/common/src/main/java/net/modgarden/barricade/mixin/client/ClientLevelMixin.java b/common/src/main/java/net/modgarden/barricade/mixin/client/ClientLevelMixin.java index fdafcb2..9149011 100644 --- a/common/src/main/java/net/modgarden/barricade/mixin/client/ClientLevelMixin.java +++ b/common/src/main/java/net/modgarden/barricade/mixin/client/ClientLevelMixin.java @@ -1,20 +1,96 @@ package net.modgarden.barricade.mixin.client; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.item.BlockItem; +import net.minecraft.client.multiplayer.prediction.BlockStatePredictionHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.BlockParticleOption; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; -import net.modgarden.barricade.registry.BarricadeTags; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.modgarden.barricade.Barricade; +import net.modgarden.barricade.block.AdvancedBarrierBlock; +import net.modgarden.barricade.block.DirectionalBarrierBlock; +import net.modgarden.barricade.block.entity.AdvancedBarrierBlockEntity; +import net.modgarden.barricade.client.particle.AdvancedBarrierParticle; +import net.modgarden.barricade.client.util.BarrierRenderUtils; +import net.modgarden.barricade.client.util.OperatorItemPseudoTag; +import net.modgarden.barricade.component.BlockedDirectionsComponent; +import net.modgarden.barricade.registry.BarricadeItems; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.HashSet; +import java.util.Set; @Mixin(ClientLevel.class) public class ClientLevelMixin { + @Mutable + @Shadow @Final private static Set MARKER_PARTICLE_ITEMS; + + @Inject(method = "", at = @At("TAIL")) + private static void barricade$addToMarkerParticles(CallbackInfo ci) { + Set set = new HashSet<>(MARKER_PARTICLE_ITEMS); + set.add(BarricadeItems.ADVANCED_BARRIER); + set.add(BarricadeItems.UP_BARRIER); + set.add(BarricadeItems.DOWN_BARRIER); + set.add(BarricadeItems.NORTH_BARRIER); + set.add(BarricadeItems.SOUTH_BARRIER); + set.add(BarricadeItems.WEST_BARRIER); + set.add(BarricadeItems.EAST_BARRIER); + set.add(BarricadeItems.HORIZONTAL_BARRIER); + set.add(BarricadeItems.VERTICAL_BARRIER); + set.add(BarricadeItems.PLAYER_BARRIER); + set.add(BarricadeItems.MOB_BARRIER); + set.add(BarricadeItems.PASSIVE_BARRIER); + set.add(BarricadeItems.HOSTILE_BARRIER); + MARKER_PARTICLE_ITEMS = Set.copyOf(set); + } + @ModifyReturnValue(method = "getMarkerParticleTarget", at = @At(value = "RETURN", ordinal = 0)) private Block barricade$setMarkerParticleTarget(Block original, @Local ItemStack itemStack, @Local Item item) { - return null; + if (Barricade.isOperatorModel(original.defaultBlockState()) || (original instanceof AdvancedBarrierBlock && Barricade.isOperatorModel(Blocks.BARRIER.defaultBlockState()))) + return null; + if (OperatorItemPseudoTag.Registry.get(Barricade.asResource("barriers")).contains(item.builtInRegistryHolder())) + return Blocks.BARRIER; + return original; + } + + @ModifyExpressionValue(method = "doAnimateTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;", ordinal = 1)) + private Block barricade$trickGameIntoRendering(Block original) { + if (OperatorItemPseudoTag.Registry.get(Barricade.asResource("barriers")).contains(original.asItem().builtInRegistryHolder())) + return Blocks.BARRIER; + return original; + } + + @WrapOperation(method = "doAnimateTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;addParticle(Lnet/minecraft/core/particles/ParticleOptions;DDDDDD)V")) + private void barricade$renderVanillaStyle(ClientLevel instance, ParticleOptions particleData, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, Operation original, @Local(argsOnly = true) Block block, @Local(argsOnly = true) BlockPos.MutableBlockPos blockPos, @Local BlockState blockState) { + if (block != blockState.getBlock() && OperatorItemPseudoTag.Registry.get(Barricade.asResource("barriers")).contains(blockState.getBlock().asItem().builtInRegistryHolder())) { + if (blockState.getBlock() instanceof DirectionalBarrierBlock directionalBarrierBlock) { + BarrierRenderUtils.createAdvancedParticle(directionalBarrierBlock.directions(), null, particleOptions -> original.call(instance, particleOptions, x, y, z, xSpeed, ySpeed, zSpeed), blockPos.immutable()); + return; + } else if (instance.getBlockEntity(blockPos.immutable()) instanceof AdvancedBarrierBlockEntity blockEntity) { + BarrierRenderUtils.createAdvancedParticle(blockEntity.getBlockedDirections() == null ? BlockedDirectionsComponent.of(Direction.values()) : blockEntity.getBlockedDirections(), blockEntity.getBlockedEntities() == null ? null : blockEntity.getBlockedEntities().backTextureLocation(), particleOptions -> original.call(instance, particleOptions, x, y, z, xSpeed, ySpeed, zSpeed), blockPos.immutable()); + return; + } + original.call(instance, new BlockParticleOption(ParticleTypes.BLOCK_MARKER, blockState), x, y, z, xSpeed, ySpeed, zSpeed); + return; + } + original.call(instance, particleData, x, y, z, xSpeed, ySpeed, zSpeed); } } diff --git a/common/src/main/java/net/modgarden/barricade/mixin/client/ModelManagerMixin.java b/common/src/main/java/net/modgarden/barricade/mixin/client/ModelManagerMixin.java index b185fc4..d3d8fc3 100644 --- a/common/src/main/java/net/modgarden/barricade/mixin/client/ModelManagerMixin.java +++ b/common/src/main/java/net/modgarden/barricade/mixin/client/ModelManagerMixin.java @@ -1,36 +1,17 @@ package net.modgarden.barricade.mixin.client; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.stream.JsonReader; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.datafixers.util.Pair; import net.minecraft.client.resources.model.AtlasSet; -import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.util.GsonHelper; import net.minecraft.util.profiling.ProfilerFiller; -import net.modgarden.barricade.Barricade; import net.modgarden.barricade.client.BarricadeClient; -import net.modgarden.barricade.client.model.OperatorBakedModelAccess; -import net.modgarden.barricade.client.model.OperatorUnbakedModel; -import net.modgarden.barricade.client.util.BarrierRenderUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.io.Reader; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; @Mixin(ModelManager.class) public class ModelManagerMixin { @@ -38,20 +19,4 @@ public class ModelManagerMixin { private void barricade$captureModelBakery(ProfilerFiller profilerFiller, Map atlasPreparations, ModelBakery modelBakery, CallbackInfoReturnable cir) { BarricadeClient.setModelBakery(modelBakery); } - - @ModifyExpressionValue(method = { "method_45899", "lambda$loadBlockModels$10" }, at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) - private static Set> barricade$fuckOffAxiom(Set> value) { - return value.stream().filter(entry -> !BarrierRenderUtils.isLightBlockId(entry.getKey()) || !entry.getValue().sourcePackId().equals("axiom")).collect(Collectors.toSet()); - } - - @Inject(method = { "method_45898", "lambda$loadBlockModels$8" }, at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/util/Pair;of(Ljava/lang/Object;Ljava/lang/Object;)Lcom/mojang/datafixers/util/Pair;")) - private static void barricade$addToModelCache(Map.Entry entry, CallbackInfoReturnable cir) { - try { - JsonElement element = JsonParser.parseReader(entry.getValue().openAsReader()); - if (element.isJsonObject() && GsonHelper.getAsString(element.getAsJsonObject(), "loader").equals(OperatorUnbakedModel.Deserializer.ID.toString())) - Barricade.addToOperatorModelCache(entry.getKey()); - else - Barricade.removeFromOperatorModelCache(entry.getKey()); - } catch (Exception ignored) {} - } } diff --git a/common/src/main/java/net/modgarden/barricade/particle/AdvancedBarrierParticleOptions.java b/common/src/main/java/net/modgarden/barricade/particle/AdvancedBarrierParticleOptions.java new file mode 100644 index 0000000..f1f0fba --- /dev/null +++ b/common/src/main/java/net/modgarden/barricade/particle/AdvancedBarrierParticleOptions.java @@ -0,0 +1,60 @@ +package net.modgarden.barricade.particle; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.modgarden.barricade.component.BlockedDirectionsComponent; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public record AdvancedBarrierParticleOptions(BlockedDirectionsComponent blockedDirections, + ResourceLocation backTextureLocation, + Optional origin) implements ParticleOptions { + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> inst.group( + BlockedDirectionsComponent.CODEC.fieldOf("blocked_directions").forGetter(AdvancedBarrierParticleOptions::blockedDirections), + ResourceLocation.CODEC.fieldOf("back_texture_location").forGetter(AdvancedBarrierParticleOptions::backTextureLocation), + BlockPos.CODEC.optionalFieldOf("origin").forGetter(AdvancedBarrierParticleOptions::origin) + ).apply(inst, AdvancedBarrierParticleOptions::new)); + private static final StreamCodec STREAM_CODEC = StreamCodec.composite( + BlockedDirectionsComponent.STREAM_CODEC, AdvancedBarrierParticleOptions::blockedDirections, + ResourceLocation.STREAM_CODEC, AdvancedBarrierParticleOptions::backTextureLocation, + ByteBufCodecs.optional(BlockPos.STREAM_CODEC), AdvancedBarrierParticleOptions::origin, + AdvancedBarrierParticleOptions::new + ); + + public AdvancedBarrierParticleOptions(BlockedDirectionsComponent blockedDirections, @Nullable ResourceLocation backTextureLocation, Optional origin) { + this.blockedDirections = blockedDirections; + this.backTextureLocation = backTextureLocation; + this.origin = origin; + } + + @Override + public ParticleType getType() { + return Type.INSTANCE; + } + + public static class Type extends ParticleType { + public static final Type INSTANCE = new Type(); + + protected Type() { + super(true); + } + + @Override + public MapCodec codec() { + return CODEC; + } + + @Override + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + } +} \ No newline at end of file diff --git a/common/src/main/java/net/modgarden/barricade/platform/BarricadePlatform.java b/common/src/main/java/net/modgarden/barricade/platform/BarricadePlatform.java new file mode 100644 index 0000000..e74db81 --- /dev/null +++ b/common/src/main/java/net/modgarden/barricade/platform/BarricadePlatform.java @@ -0,0 +1,6 @@ +package net.modgarden.barricade.platform; + +public enum BarricadePlatform { + FABRIC, + NEOFORGE +} diff --git a/common/src/main/java/net/modgarden/barricade/registry/BarricadeParticleTypes.java b/common/src/main/java/net/modgarden/barricade/registry/BarricadeParticleTypes.java new file mode 100644 index 0000000..23523da --- /dev/null +++ b/common/src/main/java/net/modgarden/barricade/registry/BarricadeParticleTypes.java @@ -0,0 +1,14 @@ +package net.modgarden.barricade.registry; + +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.registries.BuiltInRegistries; +import net.modgarden.barricade.Barricade; +import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; +import net.modgarden.barricade.registry.internal.RegistrationCallback; + +public class BarricadeParticleTypes { + + public static void registerAll(RegistrationCallback> callback) { + callback.register(BuiltInRegistries.PARTICLE_TYPE, Barricade.asResource("directional_barrier"), AdvancedBarrierParticleOptions.Type.INSTANCE); + } +} diff --git a/common/src/main/resources/assets/barricade/lang/en_us.json b/common/src/main/resources/assets/barricade/lang/en_us.json index 9c4d005..2ab3f17 100644 --- a/common/src/main/resources/assets/barricade/lang/en_us.json +++ b/common/src/main/resources/assets/barricade/lang/en_us.json @@ -12,5 +12,8 @@ "block.barricade.mob_barrier": "Mob Barrier", "block.barricade.passive_barrier": "Passive Barrier", "block.barricade.hostile_barrier": "Hostile Barrier", - "tag.item.barricade.barriers": "Barriers" + "tag.item.barricade.barriers": "Barriers", + "resourcePack.barricade.modded_rendering.name": "Modded Rendering", + "resourcePack.barricade.modded_rendering.description": "Enables Barricade's alternative barrier rendering.", + "pack.barricade.builtin": "%s (built-in: Barricade)" } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/down_barrier.json b/common/src/main/resources/assets/barricade/models/block/down_barrier.json index 873e896..4f6d6c5 100644 --- a/common/src/main/resources/assets/barricade/models/block/down_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/down_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "down": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/down_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/east_barrier.json b/common/src/main/resources/assets/barricade/models/block/east_barrier.json index fc358aa..f28ba30 100644 --- a/common/src/main/resources/assets/barricade/models/block/east_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/east_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "east": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/east_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/horizontal_barrier.json b/common/src/main/resources/assets/barricade/models/block/horizontal_barrier.json index d1cdc8f..7c1441a 100644 --- a/common/src/main/resources/assets/barricade/models/block/horizontal_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/horizontal_barrier.json @@ -1,33 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "south"}, - "east": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "west"}, - "south": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "north"}, - "west": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "east"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "north": {"uv": [16, 0, 0, 16], "texture": "#all"}, - "east": {"uv": [16, 0, 0, 16], "texture": "#all"}, - "south": {"uv": [16, 0, 0, 16], "texture": "#all"}, - "west": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/horizontal_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/hostile_barrier.json b/common/src/main/resources/assets/barricade/models/block/hostile_barrier.json index fcb1fe4..a245e42 100644 --- a/common/src/main/resources/assets/barricade/models/block/hostile_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/hostile_barrier.json @@ -1,12 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "barricade:block/entity_barrier", - "textures": { - "all": "barricade:block/barrier", - "inner": "barricade:item/barricade/entity/creeper" - }, - "render_type": "cutout" + "textures": { + "particle": "barricade:item/hostile_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/mob_barrier.json b/common/src/main/resources/assets/barricade/models/block/mob_barrier.json index bf97d32..d00427a 100644 --- a/common/src/main/resources/assets/barricade/models/block/mob_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/mob_barrier.json @@ -1,12 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "barricade:block/entity_barrier", - "textures": { - "all": "barricade:block/barrier", - "inner": "barricade:item/barricade/entity/pig" - }, - "render_type": "cutout" + "textures": { + "particle": "barricade:item/mob_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/north_barrier.json b/common/src/main/resources/assets/barricade/models/block/north_barrier.json index c045318..2d2a41e 100644 --- a/common/src/main/resources/assets/barricade/models/block/north_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/north_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "north": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/north_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/passive_barrier.json b/common/src/main/resources/assets/barricade/models/block/passive_barrier.json index 819f695..e768002 100644 --- a/common/src/main/resources/assets/barricade/models/block/passive_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/passive_barrier.json @@ -1,12 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "barricade:block/entity_barrier", - "textures": { - "all": "barricade:block/barrier", - "inner": "barricade:item/barricade/entity/parrot" - }, - "render_type": "cutout" + "textures": { + "particle": "barricade:item/passive_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/player_barrier.json b/common/src/main/resources/assets/barricade/models/block/player_barrier.json index f590ff1..f0afb43 100644 --- a/common/src/main/resources/assets/barricade/models/block/player_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/player_barrier.json @@ -1,12 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "barricade:block/entity_barrier", - "textures": { - "all": "barricade:block/barrier", - "inner": "barricade:item/barricade/entity/player" - }, - "render_type": "cutout" + "textures": { + "particle": "barricade:item/player_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/south_barrier.json b/common/src/main/resources/assets/barricade/models/block/south_barrier.json index 1b87786..213ea8d 100644 --- a/common/src/main/resources/assets/barricade/models/block/south_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/south_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "south": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/south_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/up_barrier.json b/common/src/main/resources/assets/barricade/models/block/up_barrier.json index 7bff171..68df5b7 100644 --- a/common/src/main/resources/assets/barricade/models/block/up_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/up_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "up": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/up_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/vertical_barrier.json b/common/src/main/resources/assets/barricade/models/block/vertical_barrier.json index 1da5c8e..74c8d1a 100644 --- a/common/src/main/resources/assets/barricade/models/block/vertical_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/vertical_barrier.json @@ -1,29 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "up": {"uv": [16, 0, 0, 16], "texture": "#all"}, - "down": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/vertical_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/west_barrier.json b/common/src/main/resources/assets/barricade/models/block/west_barrier.json index 2e474a7..ab69c9e 100644 --- a/common/src/main/resources/assets/barricade/models/block/west_barrier.json +++ b/common/src/main/resources/assets/barricade/models/block/west_barrier.json @@ -1,27 +1,5 @@ { - "loader": "barricade:operator", - "required_item": "#barricade:barriers", - "model": { - "parent": "minecraft:block/cube_all", - "textures": { - "all": "barricade:block/barrier" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 16, 16], - "faces": { - "west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"} - } - }, - { - "from": [15.998, 0.002, 0.002], - "to": [0.002, 15.998, 15.998], - "faces": { - "west": {"uv": [16, 0, 0, 16], "texture": "#all"} - } - } - ], - "render_type": "cutout" + "textures": { + "particle": "barricade:item/west_barrier" } } \ No newline at end of file diff --git a/common/src/main/resources/barricade.cfg b/common/src/main/resources/barricade.cfg index 5f12c94..111c9f1 100644 --- a/common/src/main/resources/barricade.cfg +++ b/common/src/main/resources/barricade.cfg @@ -4,4 +4,6 @@ public net.minecraft.client.resources.model.ModelBakery$ModelBakerImpl (Ln public net.minecraft.client.resources.model.ModelManager$ReloadState public net.minecraft.client.resources.model.ModelManager$ReloadState (Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/resources/model/BakedModel;Ljava/util/Map;Ljava/util/Map;Ljava/util/concurrent/CompletableFuture;)V public net.minecraft.world.level.block.entity.BlockEntityType$BlockEntitySupplier -public net.minecraft.world.level.block.entity.BlockEntityType$BlockEntitySupplier create(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/entity/BlockEntity; \ No newline at end of file +public net.minecraft.world.level.block.entity.BlockEntityType$BlockEntitySupplier create(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/entity/BlockEntity; +public net.minecraft.server.packs.resources.FallbackResourceManager$PackEntry +public net.minecraft.server.packs.resources.FallbackResourceManager$PackEntry (Ljava/lang/String;Lnet/minecraft/server/packs/PackResources;Ljava/util/function/Predicate;)V \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/advanced_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/advanced_barrier.json new file mode 100644 index 0000000..333e006 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/advanced_barrier.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "minecraft:item/no_barrier" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/down_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/down_barrier.json new file mode 100644 index 0000000..873e896 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/down_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "down": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/east_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/east_barrier.json new file mode 100644 index 0000000..fc358aa --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/east_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "east": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/barricade/models/block/entity_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/entity_barrier.json similarity index 100% rename from common/src/main/resources/assets/barricade/models/block/entity_barrier.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/entity_barrier.json diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/horizontal_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/horizontal_barrier.json new file mode 100644 index 0000000..d1cdc8f --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/horizontal_barrier.json @@ -0,0 +1,33 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "south"}, + "east": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "west"}, + "south": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "north"}, + "west": {"uv": [16, 0, 0, 16], "texture": "#all", "cullface": "east"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "north": {"uv": [16, 0, 0, 16], "texture": "#all"}, + "east": {"uv": [16, 0, 0, 16], "texture": "#all"}, + "south": {"uv": [16, 0, 0, 16], "texture": "#all"}, + "west": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/hostile_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/hostile_barrier.json new file mode 100644 index 0000000..fcb1fe4 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/hostile_barrier.json @@ -0,0 +1,12 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "barricade:block/entity_barrier", + "textures": { + "all": "barricade:block/barrier", + "inner": "barricade:item/barricade/entity/creeper" + }, + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/mob_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/mob_barrier.json new file mode 100644 index 0000000..bf97d32 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/mob_barrier.json @@ -0,0 +1,12 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "barricade:block/entity_barrier", + "textures": { + "all": "barricade:block/barrier", + "inner": "barricade:item/barricade/entity/pig" + }, + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/north_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/north_barrier.json new file mode 100644 index 0000000..c045318 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/north_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "north": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/passive_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/passive_barrier.json new file mode 100644 index 0000000..819f695 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/passive_barrier.json @@ -0,0 +1,12 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "barricade:block/entity_barrier", + "textures": { + "all": "barricade:block/barrier", + "inner": "barricade:item/barricade/entity/parrot" + }, + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/player_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/player_barrier.json new file mode 100644 index 0000000..f590ff1 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/player_barrier.json @@ -0,0 +1,12 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "barricade:block/entity_barrier", + "textures": { + "all": "barricade:block/barrier", + "inner": "barricade:item/barricade/entity/player" + }, + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/south_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/south_barrier.json new file mode 100644 index 0000000..1b87786 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/south_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "south": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/up_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/up_barrier.json new file mode 100644 index 0000000..7bff171 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/up_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "up": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/vertical_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/vertical_barrier.json new file mode 100644 index 0000000..1da5c8e --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/vertical_barrier.json @@ -0,0 +1,29 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "up": {"uv": [16, 0, 0, 16], "texture": "#all"}, + "down": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/west_barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/west_barrier.json new file mode 100644 index 0000000..2e474a7 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/assets/barricade/models/block/west_barrier.json @@ -0,0 +1,27 @@ +{ + "loader": "barricade:operator", + "required_item": "#barricade:barriers", + "model": { + "parent": "minecraft:block/cube_all", + "textures": { + "all": "barricade:block/barrier" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"} + } + }, + { + "from": [15.998, 0.002, 0.002], + "to": [0.002, 15.998, 15.998], + "faces": { + "west": {"uv": [16, 0, 0, 16], "texture": "#all"} + } + } + ], + "render_type": "cutout" + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/minecraft/models/block/barrier.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/barrier.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/barrier.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/barrier.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_00.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_00.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_00.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_00.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_01.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_01.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_01.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_01.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_02.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_02.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_02.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_02.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_03.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_03.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_03.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_03.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_04.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_04.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_04.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_04.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_05.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_05.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_05.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_05.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_06.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_06.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_06.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_06.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_07.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_07.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_07.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_07.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_08.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_08.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_08.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_08.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_09.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_09.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_09.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_09.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_10.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_10.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_10.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_10.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_11.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_11.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_11.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_11.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_12.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_12.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_12.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_12.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_13.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_13.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_13.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_13.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_14.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_14.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_14.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_14.json diff --git a/common/src/main/resources/assets/minecraft/models/block/light_15.json b/common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_15.json similarity index 100% rename from common/src/main/resources/assets/minecraft/models/block/light_15.json rename to common/src/main/resources/resourcepacks/modded_rendering/assets/minecraft/models/block/light_15.json diff --git a/common/src/main/resources/resourcepacks/modded_rendering/pack.mcmeta b/common/src/main/resources/resourcepacks/modded_rendering/pack.mcmeta new file mode 100644 index 0000000..2bf7158 --- /dev/null +++ b/common/src/main/resources/resourcepacks/modded_rendering/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": { + "translate": "resourcePack.barricade.modded_rendering.description" + }, + "pack_format": 34 + } +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/modded_rendering/pack.png b/common/src/main/resources/resourcepacks/modded_rendering/pack.png new file mode 100644 index 0000000..79306f3 Binary files /dev/null and b/common/src/main/resources/resourcepacks/modded_rendering/pack.png differ diff --git a/fabric/src/main/java/net/modgarden/barricade/fabric/BarricadeFabric.java b/fabric/src/main/java/net/modgarden/barricade/fabric/BarricadeFabric.java index 82fa12b..7321ad8 100644 --- a/fabric/src/main/java/net/modgarden/barricade/fabric/BarricadeFabric.java +++ b/fabric/src/main/java/net/modgarden/barricade/fabric/BarricadeFabric.java @@ -2,9 +2,14 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.fabricmc.fabric.api.resource.ResourcePackActivationType; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Items; +import net.modgarden.barricade.Barricade; import net.modgarden.barricade.registry.BarricadeBlockEntityTypes; import net.modgarden.barricade.registry.BarricadeBlocks; import net.modgarden.barricade.registry.BarricadeComponents; @@ -18,6 +23,10 @@ public void onInitialize() { BarricadeComponents.registerAll(Registry::register); BarricadeItems.registerAll(Registry::register); + FabricLoader.getInstance().getModContainer(Barricade.MOD_ID).ifPresent(modContainer -> { + ResourceManagerHelper.registerBuiltinResourcePack(Barricade.asResource("modded_rendering"), modContainer, Component.translatable("resourcePack.barricade.modded_rendering.name"), ResourcePackActivationType.NORMAL); + }); + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.OP_BLOCKS).register(entries -> { if (!entries.shouldShowOpRestrictedItems()) return; diff --git a/fabric/src/main/java/net/modgarden/barricade/fabric/client/BarricadeFabricClient.java b/fabric/src/main/java/net/modgarden/barricade/fabric/client/BarricadeFabricClient.java index 6055edd..813eb14 100644 --- a/fabric/src/main/java/net/modgarden/barricade/fabric/client/BarricadeFabricClient.java +++ b/fabric/src/main/java/net/modgarden/barricade/fabric/client/BarricadeFabricClient.java @@ -11,6 +11,8 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientWorldEvents; import net.fabricmc.fabric.api.client.model.loading.v1.PreparableModelLoadingPlugin; +import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; +import net.fabricmc.fabric.api.client.particle.v1.ParticleRenderEvents; import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; @@ -33,15 +35,18 @@ import net.modgarden.barricade.Barricade; import net.modgarden.barricade.client.BarricadeClient; import net.modgarden.barricade.client.model.OperatorUnbakedModel; +import net.modgarden.barricade.client.particle.AdvancedBarrierParticle; import net.modgarden.barricade.client.util.BarrierRenderUtils; import net.modgarden.barricade.client.util.OperatorItemPseudoTag; import net.modgarden.barricade.fabric.BarricadeFabric; import net.modgarden.barricade.fabric.client.platform.BarricadeClientPlatformHelperFabric; import net.modgarden.barricade.client.renderer.block.AdvancedBarrierBlockRenderer; import net.modgarden.barricade.client.renderer.item.AdvancedBarrierItemRenderer; +import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; import net.modgarden.barricade.registry.BarricadeBlockEntityTypes; import net.modgarden.barricade.registry.BarricadeBlocks; import net.modgarden.barricade.registry.BarricadeItems; +import net.modgarden.barricade.registry.BarricadeParticleTypes; import java.io.Reader; import java.util.ArrayList; @@ -66,6 +71,8 @@ public void onInitializeClient() { BlockEntityRenderers.register(BarricadeBlockEntityTypes.ADVANCED_BARRIER, context -> new AdvancedBarrierBlockRenderer()); BuiltinItemRendererRegistry.INSTANCE.register(BarricadeItems.ADVANCED_BARRIER, AdvancedBarrierItemRenderer::renderItem); + ParticleFactoryRegistry.getInstance().register(AdvancedBarrierParticleOptions.Type.INSTANCE, new AdvancedBarrierParticle.Provider()); + PreparableModelLoadingPlugin.register(BarricadeFabricClient::getCreativeUnbakedModels, (data, pluginContext) -> { pluginContext.resolveModel().register((context) -> { if (data.containsKey(context.id())) diff --git a/fabric/src/main/java/net/modgarden/barricade/fabric/client/platform/BarricadeClientPlatformHelperFabric.java b/fabric/src/main/java/net/modgarden/barricade/fabric/client/platform/BarricadeClientPlatformHelperFabric.java index c5f7e66..a6d8537 100644 --- a/fabric/src/main/java/net/modgarden/barricade/fabric/client/platform/BarricadeClientPlatformHelperFabric.java +++ b/fabric/src/main/java/net/modgarden/barricade/fabric/client/platform/BarricadeClientPlatformHelperFabric.java @@ -49,4 +49,9 @@ public BakedModel createCreativeOnlyModel(BakedModel model, Either (Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/resources/model/ModelBakery$TextureGetter;Lnet/minecraft/client/resources/model/ModelResourceLocation;)V accessible class net/minecraft/client/resources/model/ModelManager$ReloadState +accessible class net/minecraft/server/packs/resources/FallbackResourceManager$PackEntry \ No newline at end of file diff --git a/neoforge/src/main/java/net/modgarden/barricade/neoforge/BarricadeNeoForge.java b/neoforge/src/main/java/net/modgarden/barricade/neoforge/BarricadeNeoForge.java index 5dbf17a..ef1905a 100644 --- a/neoforge/src/main/java/net/modgarden/barricade/neoforge/BarricadeNeoForge.java +++ b/neoforge/src/main/java/net/modgarden/barricade/neoforge/BarricadeNeoForge.java @@ -1,5 +1,9 @@ package net.modgarden.barricade.neoforge; +import net.minecraft.network.chat.Component; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.PackSource; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; @@ -15,6 +19,7 @@ import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.event.AddPackFindersEvent; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; import net.neoforged.neoforge.registries.RegisterEvent; @@ -76,5 +81,26 @@ public static void buildCreativeModeTabs(BuildCreativeModeTabContentsEvent event } } } + + @SubscribeEvent + public static void addPackFinders(AddPackFindersEvent event) { + if (event.getPackType() == PackType.CLIENT_RESOURCES) { + event.addPackFinders(Barricade.asResource("resourcepacks/modded_rendering"), PackType.CLIENT_RESOURCES, Component.translatable("resourcePack.barricade.modded_rendering.name"), createSource(true), false, Pack.Position.TOP); + } + } + + private static PackSource createSource(boolean enabledByDefault) { + return new PackSource() { + @Override + public Component decorate(Component component) { + return Component.translatable("pack.barricade.builtin", component); + } + + @Override + public boolean shouldAddAutomatically() { + return enabledByDefault; + } + }; + } } } \ No newline at end of file diff --git a/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/BarricadeNeoForgeClient.java b/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/BarricadeNeoForgeClient.java index 45b89b8..8c5e45c 100644 --- a/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/BarricadeNeoForgeClient.java +++ b/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/BarricadeNeoForgeClient.java @@ -10,12 +10,14 @@ import net.modgarden.barricade.Barricade; import net.modgarden.barricade.client.BarricadeClient; import net.modgarden.barricade.client.model.OperatorUnbakedModel; +import net.modgarden.barricade.client.particle.AdvancedBarrierParticle; import net.modgarden.barricade.client.util.BarrierRenderUtils; import net.modgarden.barricade.client.util.OperatorItemPseudoTag; import net.modgarden.barricade.neoforge.client.bewlr.BarricadeBEWLR; import net.modgarden.barricade.client.renderer.block.AdvancedBarrierBlockRenderer; import net.modgarden.barricade.neoforge.client.model.CreativeOnlyUnbakedModelGeometry; import net.modgarden.barricade.neoforge.client.platform.BarricadeClientPlatformHelperNeoForge; +import net.modgarden.barricade.particle.AdvancedBarrierParticleOptions; import net.modgarden.barricade.registry.BarricadeBlockEntityTypes; import net.modgarden.barricade.registry.BarricadeItems; import net.neoforged.api.distmarker.Dist; @@ -26,6 +28,7 @@ import net.neoforged.neoforge.client.event.EntityRenderersEvent; import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent; import net.neoforged.neoforge.client.event.RenderLevelStageEvent; import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent; @@ -92,6 +95,11 @@ public BlockEntityWithoutLevelRenderer getCustomRenderer() { } }, BarricadeItems.ADVANCED_BARRIER); } + + @SubscribeEvent + public static void registerParticleProviders(RegisterParticleProvidersEvent event) { + event.registerSpecial(AdvancedBarrierParticleOptions.Type.INSTANCE, new AdvancedBarrierParticle.Provider()); + } } public static class CreativeOnlyDeserializer implements IGeometryLoader { diff --git a/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/platform/BarricadeClientPlatformHelperNeoForge.java b/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/platform/BarricadeClientPlatformHelperNeoForge.java index 36d08ea..397f50d 100644 --- a/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/platform/BarricadeClientPlatformHelperNeoForge.java +++ b/neoforge/src/main/java/net/modgarden/barricade/neoforge/client/platform/BarricadeClientPlatformHelperNeoForge.java @@ -53,4 +53,9 @@ public BakedModel createCreativeOnlyModel(BakedModel model, Either