Merge remote-tracking branch 'origin/mc1.18/dev' into mc1.18/dev

This commit is contained in:
reidbhuntley 2021-12-21 17:08:20 -05:00
commit 9897666249
29 changed files with 146 additions and 158 deletions

View file

@ -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

View file

@ -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<KineticTileEntity> {
public static final SuperByteBufferCache.Compartment<BlockState> 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<KineticTil
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
for (RenderType type : RenderType.chunkBufferLayers())
if (ItemBlockRenderTypes.canRenderInLayer(te.getBlockState(), type))
renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(type), light);
BlockState state = getRenderedBlockState(te);
RenderType type = getRenderType(te, state);
if (type != null)
renderRotatingBuffer(te, getRotatedModel(te, state), ms, buffer.getBuffer(type), light);
}
protected BlockState getRenderedBlockState(KineticTileEntity te) {
return te.getBlockState();
}
protected RenderType getRenderType(KineticTileEntity te, BlockState state) {
for (RenderType type : REVERSED_CHUNK_BUFFER_LAYERS)
if (ItemBlockRenderTypes.canRenderInLayer(state, type))
return type;
return null;
}
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.block(KINETIC_TILE, state);
}
public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, PoseStack ms,
@ -112,12 +132,4 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
.getBlock()).getRotationAxis(te.getBlockState());
}
protected BlockState getRenderedBlockState(KineticTileEntity te) {
return te.getBlockState();
}
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.block(KINETIC_TILE, getRenderedBlockState(te));
}
}

View file

@ -26,8 +26,8 @@ public class DrillRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.partialFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState());
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partialFacing(AllBlockPartials.DRILL_HEAD, state);
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,

View file

@ -90,12 +90,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return transform(AllBlockPartials.SHAFT_HALF, te);
}
private SuperByteBuffer transform(PartialModel partial, KineticTileEntity te) {
return CachedBufferer.partialFacing(partial, te.getBlockState(), te.getBlockState()
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state, state
.getValue(CuckooClockBlock.HORIZONTAL_FACING)
.getOpposite());
}

View file

@ -85,8 +85,8 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state, state
.getValue(BlockStateProperties.HORIZONTAL_FACING)
.getOpposite());
}

View file

@ -7,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.level.block.state.BlockState;
public class MillstoneRenderer extends KineticTileEntityRenderer {
@ -15,8 +16,8 @@ public class MillstoneRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, te.getBlockState());
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, state);
}
}

View file

@ -7,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.level.block.state.BlockState;
public class CreativeMotorRenderer extends KineticTileEntityRenderer {
@ -15,8 +16,8 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState());
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state);
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class BearingRenderer extends KineticTileEntityRenderer {
@ -49,8 +50,8 @@ public class BearingRenderer extends KineticTileEntityRenderer {
}
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) {
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state, state
.getValue(BearingBlock.FACING)
.getOpposite());
}

View file

@ -21,7 +21,6 @@ import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelDataMap.Builder;
import net.minecraftforge.client.model.data.ModelProperty;
@ -52,12 +51,9 @@ public class PipeAttachmentModel extends BakedModelWrapperWithData {
@Override
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData data) {
List<BakedQuad> quads = super.getQuads(state, side, rand, data);
if (data instanceof ModelDataMap) {
ModelDataMap modelDataMap = (ModelDataMap) data;
if (modelDataMap.hasProperty(PIPE_PROPERTY)) {
if (data.hasProperty(PIPE_PROPERTY)) {
quads = new ArrayList<>(quads);
addQuads(quads, state, side, rand, modelDataMap, modelDataMap.getData(PIPE_PROPERTY));
}
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;

View file

@ -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);
}
}

View file

@ -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<BlockState> 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);
}
}

View file

@ -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);
}

View file

@ -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<ItemStack> POTION_ITEMS = new ArrayList<>();
public static List<Item> FILLED_BUCKETS = new ArrayList<>();
public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> {
public static final ResourceManagerReloadListener LISTENER = resourceManager -> {
POTION_ITEMS.clear();
FILLED_BUCKETS.clear();
};

View file

@ -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()) {

View file

@ -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<BakedModel> {
@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<BakedModel> {
@Override
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData data) {
if (data instanceof ModelDataMap) {
List<BakedQuad> 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<BakedQuad> 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) {

View file

@ -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);
}
}
}

View file

@ -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());
}
}

View file

@ -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));
}
}

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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);
}
}

View file

@ -395,8 +395,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
ArmInteractionPoint.transformPos(transform, (CompoundTag) inbt);
}
sendData();
setChanged();
notifyUpdate();
}
protected void initInteractionPoints() {

View file

@ -30,11 +30,6 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
public SchematicannonRenderer(BlockEntityRendererProvider.Context context) {}
@Override
public boolean shouldRenderOffScreen(SchematicannonTileEntity tileEntity) {
return true;
}
@Override
protected void renderSafe(SchematicannonTileEntity tileEntity, float partialTicks, PoseStack ms,
MultiBufferSource buffer, int light, int overlay) {
@ -212,6 +207,11 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
}
}
@Override
public boolean shouldRenderOffScreen(SchematicannonTileEntity tileEntity) {
return true;
}
@Override
public int getViewDistance() {
return 128;

View file

@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import com.jozufozu.flywheel.util.transform.TransformStack;
@ -90,6 +91,7 @@ public class SchematicRenderer {
List<BlockState> blockstates = new LinkedList<>();
Map<RenderType, BufferBuilder> 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);

View file

@ -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();

View file

@ -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

View file

@ -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;
}
}

View file

@ -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<Void> 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);
}

View file

@ -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();
};