diff --git a/gradle.properties b/gradle.properties index 6a296009e..b0097b068 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ parchment_version = 2021.10.31 # dependency versions registrate_version = MC1.18-1.0.21 -flywheel_version = 1.18-0.4.2-rc.25 +flywheel_version = 1.18-0.4.2-rc.26 jei_minecraft_version = 1.18 jei_version = 9.0.0.40 diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index fdae33fc3..425152021 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.base; +import org.apache.commons.lang3.ArrayUtils; + import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -23,15 +25,17 @@ import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.AxisDirection; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -@EventBusSubscriber(Dist.CLIENT) public class KineticTileEntityRenderer extends SafeTileEntityRenderer { public static final SuperByteBufferCache.Compartment KINETIC_TILE = new SuperByteBufferCache.Compartment<>(); public static boolean rainbowMode = false; + protected static final RenderType[] REVERSED_CHUNK_BUFFER_LAYERS = RenderType.chunkBufferLayers().toArray(RenderType[]::new); + static { + ArrayUtils.reverse(REVERSED_CHUNK_BUFFER_LAYERS); + } + public KineticTileEntityRenderer(BlockEntityRendererProvider.Context context) { } @@ -40,9 +44,25 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer getQuads(BlockState state, Direction side, Random rand, IModelData data) { List quads = super.getQuads(state, side, rand, data); - if (data instanceof ModelDataMap) { - ModelDataMap modelDataMap = (ModelDataMap) data; - if (modelDataMap.hasProperty(PIPE_PROPERTY)) { - quads = new ArrayList<>(quads); - addQuads(quads, state, side, rand, modelDataMap, modelDataMap.getData(PIPE_PROPERTY)); - } + if (data.hasProperty(PIPE_PROPERTY)) { + quads = new ArrayList<>(quads); + addQuads(quads, state, side, rand, data, data.getData(PIPE_PROPERTY)); } return quads; } @@ -78,7 +74,7 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData { quads.addAll(bracket.getQuads(state, side, rand, data)); } - private class PipeModelData { + private static class PipeModelData { AttachmentTypes[] rims; boolean encased; BakedModel bracket; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java index fc5f40133..a8de02eb2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java @@ -48,8 +48,8 @@ public class PumpRenderer extends KineticTileEntityRenderer { } @Override - protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); + protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { + return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, state); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java index 615224a71..579500ce7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java @@ -14,6 +14,7 @@ import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.util.StringRepresentable; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BooleanProperty; @@ -41,8 +42,8 @@ public class BracketBlock extends WrenchableDirectionalBlock { .add(TYPE)); } - public BracketBlock(Properties p_i48415_1_) { - super(p_i48415_1_); + public BracketBlock(Properties properties) { + super(properties); } public Optional getSuitableBracket(BlockState blockState, Direction direction) { @@ -63,4 +64,11 @@ public class BracketBlock extends WrenchableDirectionalBlock { .setValue(AXIS_ALONG_FIRST_COORDINATE, !alongFirst)); } + @Override + public BlockState rotate(BlockState state, Rotation rot) { + if (rot.ordinal() % 2 == 1) + state = state.cycle(AXIS_ALONG_FIRST_COORDINATE); + return super.rotate(state, rot); + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java index 8fc588c39..6b6a93dab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeTileEntity.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.contraptions.fluids.pipes; import java.util.List; import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableTE; +import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour; import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileEntityBehaviour; import com.simibubi.create.foundation.advancement.AllTriggers; @@ -15,7 +17,7 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -public class FluidPipeTileEntity extends SmartTileEntity { +public class FluidPipeTileEntity extends SmartTileEntity implements ITransformableTE { public FluidPipeTileEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); @@ -28,6 +30,14 @@ public class FluidPipeTileEntity extends SmartTileEntity { .withTrigger(state -> AllTriggers.BRACKET_APPLY_TRIGGER.constructTriggerFor(state.getBlock()))); } + @Override + public void transform(StructureTransform transform) { + BracketedTileEntityBehaviour bracketBehaviour = getBehaviour(BracketedTileEntityBehaviour.TYPE); + if (bracketBehaviour != null) { + bracketBehaviour.transformBracket(transform); + } + } + private boolean canHaveBracket(BlockState state) { return !(state.getBlock() instanceof EncasedPipeBlock); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java index 1bf7e0d43..056b6df09 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/FluidTransferRecipes.java @@ -3,8 +3,7 @@ package com.simibubi.create.content.contraptions.fluids.recipe; import java.util.ArrayList; import java.util.List; -import com.simibubi.create.foundation.utility.ISimpleReloadListener; - +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -13,7 +12,7 @@ public class FluidTransferRecipes { public static List POTION_ITEMS = new ArrayList<>(); public static List FILLED_BUCKETS = new ArrayList<>(); - public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> { + public static final ResourceManagerReloadListener LISTENER = resourceManager -> { POTION_ITEMS.clear(); FILLED_BUCKETS.clear(); }; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java index 2226bc576..0267c326e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/recipe/PotionMixingRecipeManager.java @@ -15,8 +15,8 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler import com.simibubi.create.content.contraptions.processing.HeatCondition; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.foundation.fluid.FluidIngredient; -import com.simibubi.create.foundation.utility.ISimpleReloadListener; +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.alchemy.Potion; @@ -131,7 +131,7 @@ public class PotionMixingRecipeManager { .collect(Collectors.toList()); } - public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> { + public static final ResourceManagerReloadListener LISTENER = resourceManager -> { ALL.clear(); getAllBrewingRecipes().forEach(recipe -> { for (Ingredient ingredient : recipe.getIngredients()) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java index 2876214a8..18f84e71c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.elementary; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Random; @@ -29,7 +29,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { - if (tileData == VirtualEmptyModelData.INSTANCE) + if (VirtualEmptyModelData.is(tileData)) return tileData; BracketedModelData data = new BracketedModelData(); BracketedTileEntityBehaviour attachmentBehaviour = @@ -42,27 +42,19 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public List getQuads(BlockState state, Direction side, Random rand, IModelData data) { - if (data instanceof ModelDataMap) { - List quads = new ArrayList<>(); - ModelDataMap modelDataMap = (ModelDataMap) data; - if (modelDataMap.hasProperty(BRACKET_PROPERTY)) { - quads = new ArrayList<>(quads); - addQuads(quads, state, side, rand, modelDataMap, modelDataMap.getData(BRACKET_PROPERTY)); + if (!VirtualEmptyModelData.is(data)) { + if (data.hasProperty(BRACKET_PROPERTY)) { + BracketedModelData pipeData = data.getData(BRACKET_PROPERTY); + BakedModel bracket = pipeData.getBracket(); + if (bracket != null) + return bracket.getQuads(state, side, rand, data); } - return quads; + return Collections.emptyList(); } return super.getQuads(state, side, rand, data); } - private void addQuads(List quads, BlockState state, Direction side, Random rand, IModelData data, - BracketedModelData pipeData) { - BakedModel bracket = pipeData.getBracket(); - if (bracket == null) - return; - quads.addAll(bracket.getQuads(state, side, rand, data)); - } - - private class BracketedModelData { + private static class BracketedModelData { BakedModel bracket; public void putBracket(BlockState state) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileEntity.java index bf06260ee..840c10fa7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileEntity.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.relays.elementary; import java.util.List; +import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableTE; +import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -9,7 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -public class BracketedKineticTileEntity extends SimpleKineticTileEntity { +public class BracketedKineticTileEntity extends SimpleKineticTileEntity implements ITransformableTE { public BracketedKineticTileEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); @@ -22,4 +24,12 @@ public class BracketedKineticTileEntity extends SimpleKineticTileEntity { super.addBehaviours(behaviours); } + @Override + public void transform(StructureTransform transform) { + BracketedTileEntityBehaviour bracketBehaviour = getBehaviour(BracketedTileEntityBehaviour.TYPE); + if (bracketBehaviour != null) { + bracketBehaviour.transformBracket(transform); + } + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java index ee8022775..aeda1b98d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java @@ -4,6 +4,7 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; +import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.ITriggerable; @@ -56,10 +57,12 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { tileEntity.notifyUpdate(); } - public void triggerAdvancements(Level world, Player player, BlockState state) { - if (trigger == null) - return; - AllTriggers.triggerFor(trigger.apply(state), player); + public void transformBracket(StructureTransform transform) { + if (isBracketPresent()) { + BlockState bracket = getBracket(); + BlockState transformedBracket = transform.apply(bracket); + applyBracket(transformedBracket); + } } public void removeBracket(boolean inOnReplacedContext) { @@ -75,13 +78,23 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { } public boolean isBracketPresent() { - return getBracket() != Blocks.AIR.defaultBlockState(); + return bracket.isPresent(); } public BlockState getBracket() { return bracket.orElse(Blocks.AIR.defaultBlockState()); } + public boolean canHaveBracket() { + return pred.test(tileEntity.getBlockState()); + } + + public void triggerAdvancements(Level world, Player player, BlockState state) { + if (trigger == null) + return; + AllTriggers.triggerFor(trigger.apply(state), player); + } + @Override public ItemRequirement getRequiredItems() { return ItemRequirement.of(getBracket(), null); @@ -112,8 +125,4 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { super.read(nbt, clientPacket); } - public boolean canHaveBracket() { - return pred.test(tileEntity.getBlockState()); - } - } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java index b7f423b22..0bb95a167 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java @@ -58,11 +58,10 @@ public class EncasedCogRenderer extends KineticTileEntityRenderer { } @Override - protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { + protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { return CachedBufferer.partialFacingVertical( - large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, te.getBlockState(), - Direction.fromAxisAndDirection(te.getBlockState() - .getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE)); + large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, state, + Direction.fromAxisAndDirection(state.getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE)); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java index ce0975ce2..fc7b1d87a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java @@ -40,8 +40,8 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer { } @Override - protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_SHAFT, te.getBlockState()); + protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { + return CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_SHAFT, state); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java index 2a09fc523..0a30ce607 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryHandler.java @@ -85,6 +85,7 @@ public class SymmetryHandler { public static void render(RenderLevelLastEvent event) { Minecraft mc = Minecraft.getInstance(); LocalPlayer player = mc.player; + Random random = new Random(); for (int i = 0; i < Inventory.getSelectionSize(); i++) { ItemStack stackInSlot = player.getInventory() @@ -103,8 +104,7 @@ public class SymmetryHandler { double speed = 1 / 16d; yShift = Mth.sin((float) (AnimationTickHolder.getRenderTime() * speed)) / 5f; - MultiBufferSource.BufferSource buffer = Minecraft.getInstance() - .renderBuffers() + MultiBufferSource.BufferSource buffer = mc.renderBuffers() .bufferSource(); Camera info = mc.gameRenderer.getMainCamera(); Vec3 view = info.getPosition(); @@ -122,7 +122,7 @@ public class SymmetryHandler { mc.getBlockRenderer() .getModelRenderer() .tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true, - player.level.getRandom(), Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); + random, Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); buffer.endBatch(); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index aa513be83..bf6aa581c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -31,11 +31,6 @@ public class ArmRenderer extends KineticTileEntityRenderer { super(context); } - @Override - public boolean shouldRenderOffScreen(KineticTileEntity te) { - return true; - } - @Override protected void renderSafe(KineticTileEntity te, float pt, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { @@ -187,8 +182,13 @@ public class ArmRenderer extends KineticTileEntityRenderer { } @Override - protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return CachedBufferer.partial(AllBlockPartials.ARM_COG, te.getBlockState()); + public boolean shouldRenderOffScreen(KineticTileEntity te) { + return true; + } + + @Override + protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { + return CachedBufferer.partial(AllBlockPartials.ARM_COG, state); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index 8bc3af564..e6b97b32b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -395,8 +395,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE ArmInteractionPoint.transformPos(transform, (CompoundTag) inbt); } - sendData(); - setChanged(); + notifyUpdate(); } protected void initInteractionPoints() { diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java index 0ac141c07..4650bc294 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java @@ -30,11 +30,6 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer blockstates = new LinkedList<>(); Map buffers = new HashMap<>(); PoseStack ms = new PoseStack(); + Random random = new Random(); BlockPos.betweenClosedStream(blockAccess.getBounds()) .forEach(localPos -> { @@ -104,7 +106,7 @@ public class SchematicRenderer { continue; ForgeHooksClient.setRenderType(blockRenderLayer); if (!buffers.containsKey(blockRenderLayer)) - buffers.put(blockRenderLayer, new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize())); + buffers.put(blockRenderLayer, new BufferBuilder(512)); BufferBuilder bufferBuilder = buffers.get(blockRenderLayer); if (startedBufferBuilders.add(blockRenderLayer)) @@ -113,8 +115,7 @@ public class SchematicRenderer { BlockEntity tileEntity = blockAccess.getBlockEntity(localPos); if (blockRendererDispatcher.renderBatched(state, pos, blockAccess, ms, bufferBuilder, true, - minecraft.level.random, - tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE)) { + random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE)) { usedBlockRenderLayers.add(blockRenderLayer); } blockstates.add(state); diff --git a/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java index 7674ef7e4..e64ad933d 100644 --- a/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java +++ b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java @@ -3,15 +3,14 @@ package com.simibubi.create.foundation; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.sound.SoundScapes; -import com.simibubi.create.foundation.utility.ISimpleReloadListener; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; -public class ClientResourceReloadListener implements ISimpleReloadListener { +public class ClientResourceReloadListener implements ResourceManagerReloadListener { @Override - public void onReload(ResourceManager resourceManager, ProfilerFiller profiler) { + public void onResourceManagerReload(ResourceManager resourceManager) { CreateClient.invalidateRenderers(); SoundScapes.invalidateAll(); IHaveGoggleInformation.numberFormat.update(); diff --git a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java index db0d24b93..def8bdcff 100644 --- a/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java @@ -14,8 +14,8 @@ import net.minecraft.world.level.block.state.StateDefinition.Builder; public class WrenchableDirectionalBlock extends DirectionalBlock implements IWrenchable { - public WrenchableDirectionalBlock(Properties p_i48415_1_) { - super(p_i48415_1_); + public WrenchableDirectionalBlock(Properties properties) { + super(properties); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java index fe859a516..aa8300cde 100644 --- a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java @@ -1,19 +1,12 @@ package com.simibubi.create.foundation.render; -import java.util.Random; - -import com.jozufozu.flywheel.util.VirtualEmptyModelData; +import com.jozufozu.flywheel.core.model.ModelUtil; import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.block.ModelBlockRenderer; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; public class BakedModelRenderHelper { @@ -29,22 +22,8 @@ public class BakedModelRenderHelper { } public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { - BufferBuilder builder = getBufferBuilder(model, referenceState, ms); - + BufferBuilder builder = ModelUtil.getBufferBuilder(model, referenceState, ms); return new SuperByteBuffer(builder); } - public static BufferBuilder getBufferBuilder(BakedModel model, BlockState referenceState, PoseStack ms) { - Minecraft mc = Minecraft.getInstance(); - BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); - ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); - BufferBuilder builder = new BufferBuilder(512); - - builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - blockRenderer.tesselateBlock(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, - new Random(), 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); - builder.end(); - return builder; - } - } diff --git a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java deleted file mode 100644 index fadea7379..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.foundation.utility; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - -import net.minecraft.server.packs.resources.PreparableReloadListener; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.Unit; -import net.minecraft.util.profiling.ProfilerFiller; - -// TODO 1.18: remove and replace all usages with ResourceManagerReloadListener -@FunctionalInterface -public interface ISimpleReloadListener extends PreparableReloadListener { - - @Override - default CompletableFuture reload(PreparableReloadListener.PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { - return stage.wait(Unit.INSTANCE).thenRunAsync(() -> { - onReload(resourceManager, applyProfiler); - }, applyExecutor); - } - - void onReload(ResourceManager resourceManager, ProfilerFiller profiler); - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java index 90e09b6e0..aa699fc83 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/recipe/RecipeFinder.java @@ -10,8 +10,8 @@ import javax.annotation.Nullable; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.simibubi.create.foundation.utility.ISimpleReloadListener; +import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.level.Level; @@ -56,7 +56,7 @@ public class RecipeFinder { return list; } - public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> { + public static final ResourceManagerReloadListener LISTENER = resourceManager -> { cachedSearches.invalidateAll(); };