From bcfd0aed88cae857ff09e8e7e531324b04e016d0 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Mon, 20 Dec 2021 20:44:21 -0500 Subject: [PATCH 1/4] Exempt critical issues from being marked as stale --- .github/workflows/close_issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close_issues.yml b/.github/workflows/close_issues.yml index 5af15afcc..ccabc70e8 100644 --- a/.github/workflows/close_issues.yml +++ b/.github/workflows/close_issues.yml @@ -15,7 +15,7 @@ jobs: days-before-issue-stale: 21 days-before-issue-close: 21 stale-issue-label: "stale" - exempt-issue-labels: "timeless, suggestion" + exempt-issue-labels: "timeless, suggestion, critical" stale-issue-message: "This issue has been marked as stale because it has been inactive for 3 weeks. It will be closed if it remains inactive for another 3 weeks." close-issue-message: "This issue has been closed since it has been inactive for 3 weeks since it was marked as stale." days-before-pr-stale: -1 From 848eb904f587a21e8aea9d9673e34fc58dbbbb5a Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 20 Dec 2021 21:51:21 -0800 Subject: [PATCH 2/4] Fluid#isSame is asymmetric - Fixes #2490 --- .../com/simibubi/create/events/ClientEvents.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index ed817e63b..25824347d 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -257,13 +257,13 @@ public class ClientEvents { Fluid fluid = fluidstate.getType(); - if (fluid.isSame(AllFluids.CHOCOLATE.get())) { + if (AllFluids.CHOCOLATE.get().isSame(fluid)) { event.setDensity(5f); event.setCanceled(true); return; } - if (fluid.isSame(AllFluids.HONEY.get())) { + if (AllFluids.HONEY.get().isSame(fluid)) { event.setDensity(1.5f); event.setCanceled(true); return; @@ -283,18 +283,18 @@ public class ClientEvents { Level level = Minecraft.getInstance().level; BlockPos blockPos = info.getBlockPosition(); FluidState fluidstate = level.getFluidState(blockPos); - if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) + if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) return; - + Fluid fluid = fluidstate.getType(); - if (fluid.isSame(AllFluids.CHOCOLATE.get())) { + if (AllFluids.CHOCOLATE.get().isSame(fluid)) { event.setRed(98 / 256f); event.setGreen(32 / 256f); event.setBlue(32 / 256f); } - if (fluid.isSame(AllFluids.HONEY.get())) { + if (AllFluids.HONEY.get().isSame(fluid)) { event.setRed(234 / 256f); event.setGreen(174 / 256f); event.setBlue(47 / 256f); From 0a9c10a13d2c79ead5ed77861737c049a32c60d5 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Tue, 21 Dec 2021 12:22:49 -0500 Subject: [PATCH 3/4] Fix Schematicannon rail placement crash --- .../foundation/utility/BlockHelper.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index a0e3049e6..92a1c50fb 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.components.actors.SeatBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Registry; +import net.minecraft.core.SectionPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -194,17 +195,19 @@ public class BlockHelper { } private static void placeRailWithoutUpdate(Level world, BlockState state, BlockPos target) { - int i = target.getX() & 15; - int j = target.getY(); - int k = target.getZ() & 15; LevelChunk chunk = world.getChunkAt(target); - LevelChunkSection chunksection = chunk.getSections()[j >> 4]; + int idx = chunk.getSectionIndex(target.getY()); + LevelChunkSection chunksection = chunk.getSection(idx); if (chunksection == null) { - chunksection = new LevelChunkSection(j >> 4 << 4, world.registryAccess() - .registryOrThrow(Registry.BIOME_REGISTRY)); - chunk.getSections()[j >> 4] = chunksection; + chunksection = new LevelChunkSection(chunk.getSectionYFromSectionIndex(idx), + world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)); + chunk.getSections()[idx] = chunksection; } - BlockState old = chunksection.setBlockState(i, j & 15, k, state); + BlockState old = chunksection.setBlockState( + SectionPos.sectionRelative(target.getX()), + SectionPos.sectionRelative(target.getY()), + SectionPos.sectionRelative(target.getZ()), + state); chunk.setUnsaved(true); world.markAndNotifyBlock(target, chunk, old, state, 82, 512); From 7942b570f0c45f1fd165f0e700338a9e42808f42 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 21 Dec 2021 13:44:00 -0800 Subject: [PATCH 4/4] Brackets, models, and reload listeners - Fix bracket contraption rotation; Fix #1856 - Make sure KineticTileEntityRenderer only renders once - Make use of new ModelUtil method in BakedModelRenderHelper - Clear up BracketedKineticBlockModel and PipeAttachmentModel logic - Replace ISimpleReloadListener usage with ResourceManagerReloadListener --- gradle.properties | 2 +- .../base/KineticTileEntityRenderer.java | 40 ++++++++++++------- .../components/actors/DrillRenderer.java | 4 +- .../components/clock/CuckooClockRenderer.java | 8 +--- .../components/flywheel/FlywheelRenderer.java | 4 +- .../millstone/MillstoneRenderer.java | 5 ++- .../motor/CreativeMotorRenderer.java | 5 ++- .../bearing/BearingRenderer.java | 5 ++- .../fluids/PipeAttachmentModel.java | 12 ++---- .../contraptions/fluids/PumpRenderer.java | 4 +- .../fluids/pipes/BracketBlock.java | 12 +++++- .../fluids/pipes/FluidPipeTileEntity.java | 12 +++++- .../fluids/recipe/FluidTransferRecipes.java | 5 +-- .../recipe/PotionMixingRecipeManager.java | 4 +- .../BracketedKineticBlockModel.java | 28 +++++-------- .../BracketedKineticTileEntity.java | 12 +++++- .../BracketedTileEntityBehaviour.java | 27 ++++++++----- .../relays/encased/EncasedCogRenderer.java | 7 ++-- .../armor/CopperBacktankRenderer.java | 4 +- .../curiosities/symmetry/SymmetryHandler.java | 6 +-- .../block/mechanicalArm/ArmRenderer.java | 14 +++---- .../block/mechanicalArm/ArmTileEntity.java | 3 +- .../block/SchematicannonRenderer.java | 10 ++--- .../schematics/client/SchematicRenderer.java | 7 ++-- .../ClientResourceReloadListener.java | 7 ++-- .../block/WrenchableDirectionalBlock.java | 4 +- .../render/BakedModelRenderHelper.java | 25 +----------- .../utility/ISimpleReloadListener.java | 24 ----------- .../utility/recipe/RecipeFinder.java | 4 +- 29 files changed, 146 insertions(+), 158 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java 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(); };