Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -6,15 +6,15 @@ import com.google.common.collect.Maps;
|
|||
|
||||
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import net.minecraft.block.AbstractChestBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.DoubleBlockProperties;
|
||||
import net.minecraft.block.DoubleBlockProperties.PropertySource;
|
||||
import net.minecraft.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.block.enums.ChestType;
|
||||
import net.minecraft.world.level.block.AbstractChestBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.DoubleBlockProperties;
|
||||
import net.minecraft.world.level.block.DoubleBlockProperties.PropertySource;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.enums.ChestType;
|
||||
import net.minecraft.client.block.ChestAnimationProgress;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
@ -25,11 +25,11 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
|||
import net.minecraft.client.render.block.entity.LightmapCoordinatesRetriever;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.Level;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndChestBlock;
|
||||
import ru.betterend.blocks.entities.EChestBlockEntity;
|
||||
|
@ -85,11 +85,15 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlock
|
|||
this.partLeftB.pivotY = 8.0F;
|
||||
}
|
||||
|
||||
public void render(EChestBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
World world = entity.getWorld();
|
||||
public void render(EChestBlockEntity entity, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
Level world = entity.getLevel();
|
||||
boolean worldExists = world != null;
|
||||
BlockState blockState = worldExists ? entity.getCachedState() : (BlockState) Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, Direction.SOUTH);
|
||||
ChestType chestType = blockState.contains(ChestBlock.CHEST_TYPE) ? (ChestType) blockState.get(ChestBlock.CHEST_TYPE) : ChestType.SINGLE;
|
||||
BlockState blockState = worldExists ? entity.getCachedState()
|
||||
: (BlockState) Blocks.CHEST.defaultBlockState().with(ChestBlock.FACING, Direction.SOUTH);
|
||||
ChestType chestType = blockState.contains(ChestBlock.CHEST_TYPE)
|
||||
? (ChestType) blockState.get(ChestBlock.CHEST_TYPE)
|
||||
: ChestType.SINGLE;
|
||||
Block block = blockState.getBlock();
|
||||
if (block instanceof AbstractChestBlock) {
|
||||
AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block;
|
||||
|
@ -108,19 +112,23 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlock
|
|||
propertySource = DoubleBlockProperties.PropertyRetriever::getFallback;
|
||||
}
|
||||
|
||||
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.getAnimationProgressRetriever((ChestAnimationProgress) entity))).get(tickDelta);
|
||||
float pitch = ((Float2FloatFunction) propertySource
|
||||
.apply(ChestBlock.getAnimationProgressRetriever((ChestAnimationProgress) entity))).get(tickDelta);
|
||||
pitch = 1.0F - pitch;
|
||||
pitch = 1.0F - pitch * pitch * pitch;
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
int blockLight = ((Int2IntFunction) propertySource.apply(new LightmapCoordinatesRetriever())).applyAsInt(light);
|
||||
int blockLight = ((Int2IntFunction) propertySource.apply(new LightmapCoordinatesRetriever()))
|
||||
.applyAsInt(light);
|
||||
|
||||
VertexConsumer vertexConsumer = getConsumer(vertexConsumers, block, chestType);
|
||||
|
||||
if (isDouble) {
|
||||
if (chestType == ChestType.LEFT) {
|
||||
renderParts(matrices, vertexConsumer, this.partLeftA, this.partLeftB, this.partLeftC, pitch, blockLight, overlay);
|
||||
renderParts(matrices, vertexConsumer, this.partLeftA, this.partLeftB, this.partLeftC, pitch,
|
||||
blockLight, overlay);
|
||||
} else {
|
||||
renderParts(matrices, vertexConsumer, this.partRightA, this.partRightB, this.partRightC, pitch, blockLight, overlay);
|
||||
renderParts(matrices, vertexConsumer, this.partRightA, this.partRightB, this.partRightC, pitch,
|
||||
blockLight, overlay);
|
||||
}
|
||||
} else {
|
||||
renderParts(matrices, vertexConsumer, this.partA, this.partB, this.partC, pitch, blockLight, overlay);
|
||||
|
@ -130,7 +138,8 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlock
|
|||
}
|
||||
}
|
||||
|
||||
private void renderParts(MatrixStack matrices, VertexConsumer vertices, ModelPart modelPart, ModelPart modelPart2, ModelPart modelPart3, float pitch, int light, int overlay) {
|
||||
private void renderParts(MatrixStack matrices, VertexConsumer vertices, ModelPart modelPart, ModelPart modelPart2,
|
||||
ModelPart modelPart3, float pitch, int light, int overlay) {
|
||||
modelPart.pitch = -(pitch * 1.5707964F);
|
||||
modelPart2.pitch = modelPart.pitch;
|
||||
modelPart.render(matrices, vertices, light, overlay);
|
||||
|
@ -157,21 +166,21 @@ public class EndChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlock
|
|||
|
||||
static {
|
||||
defaultLayer = new RenderLayer[] {
|
||||
RenderLayer.getEntityCutout(new Identifier("textures/entity/chest/normal.png")),
|
||||
RenderLayer.getEntityCutout(new Identifier("textures/entity/chest/normal_left.png")),
|
||||
RenderLayer.getEntityCutout(new Identifier("textures/entity/chest/normal_right.png"))
|
||||
};
|
||||
|
||||
RenderLayer.getEntityCutout(new ResourceLocation("textures/entity/chest/normal.png")),
|
||||
RenderLayer.getEntityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")),
|
||||
RenderLayer.getEntityCutout(new ResourceLocation("textures/entity/chest/normal_right.png")) };
|
||||
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndChestBlock) {
|
||||
String name = Registry.BLOCK.getId(block).getPath();
|
||||
String name = Registry.BLOCK.getKey(block).getPath();
|
||||
LAYERS.put(block, new RenderLayer[] {
|
||||
RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + ".png")),
|
||||
RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_left.png")),
|
||||
RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_right.png"))
|
||||
});
|
||||
RenderLayer.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + ".png")),
|
||||
RenderLayer
|
||||
.getEntityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_left.png")),
|
||||
RenderLayer.getEntityCutout(
|
||||
BetterEnd.makeID("textures/entity/chest/" + name + "_right.png")) });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.AbstractSignBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SignBlock;
|
||||
import net.minecraft.world.level.block.AbstractSignBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.TexturedRenderLayers;
|
||||
|
@ -22,11 +22,11 @@ import net.minecraft.client.texture.NativeImage;
|
|||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.SignType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndSignBlock;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
|
@ -47,7 +47,7 @@ public class EndSignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEn
|
|||
matrixStack.push();
|
||||
|
||||
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
||||
float angle = -((float) ((Integer) state.get(SignBlock.ROTATION) * 360) / 16.0F);
|
||||
float angle = -((float) ((Integer) state.getValue(SignBlock.ROTATION) * 360) / 16.0F);
|
||||
|
||||
BlockState blockState = signBlockEntity.getCachedState();
|
||||
if (blockState.get(EndSignBlock.FLOOR)) {
|
||||
|
@ -81,7 +81,8 @@ public class EndSignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEn
|
|||
});
|
||||
if (orderedText != null) {
|
||||
float t = (float) (-textRenderer.getWidth(orderedText) / 2);
|
||||
textRenderer.draw((OrderedText) orderedText, t, (float) (s * 10 - 20), q, false, matrixStack.peek().getModel(), provider, false, 0, light);
|
||||
textRenderer.draw((OrderedText) orderedText, t, (float) (s * 10 - 20), q, false,
|
||||
matrixStack.peek().getModel(), provider, false, 0, light);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,25 +99,25 @@ public class EndSignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEn
|
|||
|
||||
return TexturedRenderLayers.getSignTextureId(signType2);
|
||||
}
|
||||
|
||||
|
||||
public static VertexConsumer getConsumer(VertexConsumerProvider provider, Block block) {
|
||||
return provider.getBuffer(LAYERS.getOrDefault(block, defaultLayer));
|
||||
}
|
||||
|
||||
static {
|
||||
defaultLayer = RenderLayer.getEntitySolid(new Identifier("textures/entity/sign/oak.png"));
|
||||
|
||||
defaultLayer = RenderLayer.getEntitySolid(new ResourceLocation("textures/entity/sign/oak.png"));
|
||||
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndSignBlock) {
|
||||
String name = Registry.BLOCK.getId(block).getPath();
|
||||
RenderLayer layer = RenderLayer.getEntitySolid(BetterEnd.makeID("textures/entity/sign/" + name + ".png"));
|
||||
String name = Registry.BLOCK.getKey(block).getPath();
|
||||
RenderLayer layer = RenderLayer
|
||||
.getEntitySolid(BetterEnd.makeID("textures/entity/sign/" + name + ".png"));
|
||||
LAYERS.put(block, layer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.blocks.entities.render;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
|
@ -11,11 +11,11 @@ import net.minecraft.client.render.model.BakedModel;
|
|||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
|
@ -27,21 +27,23 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEntityRenderer<T> {
|
||||
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T blockEntity, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
public void render(T blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||
int light, int overlay) {
|
||||
|
||||
World world = blockEntity.getWorld();
|
||||
if (world == null || blockEntity.isEmpty()) return;
|
||||
Level world = blockEntity.getLevel();
|
||||
if (world == null || blockEntity.isEmpty())
|
||||
return;
|
||||
|
||||
BlockState state = world.getBlockState(blockEntity.getPos());
|
||||
if (!(state.getBlock() instanceof PedestalBlock)) return;
|
||||
|
||||
if (!(state.getBlock() instanceof PedestalBlock))
|
||||
return;
|
||||
|
||||
ItemStack activeItem = blockEntity.getStack(0);
|
||||
|
||||
matrices.push();
|
||||
|
@ -57,12 +59,13 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEn
|
|||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
int age = blockEntity.getAge();
|
||||
if (state.isOf(EndBlocks.ETERNAL_PEDESTAL) && state.get(EternalPedestal.ACTIVATED)) {
|
||||
if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = EternalCrystalRenderer.colors(age);
|
||||
int y = blockEntity.getPos().getY();
|
||||
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, 0.16F);
|
||||
float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F,
|
||||
0.16F);
|
||||
float altitude = Mth.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
}
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
|
@ -72,7 +75,8 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEn
|
|||
} else {
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices,
|
||||
vertexConsumers, light, overlay, model);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue