Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -3,7 +3,7 @@ package ru.betterend.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
@ -24,7 +24,7 @@ public class BetterEndClient implements ClientModInitializer {
EndEntitiesRenders.register();
EndModelProviders.register();
ClientOptions.init();
if (BetterEnd.isDevEnvironment()) {
TranslationHelper.printMissingNames();
}

View file

@ -7,7 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
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.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;

View file

@ -12,10 +12,10 @@ import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.collection.DefaultedList;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
@ -27,12 +27,12 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
private Slot fuelSlot;
private Item currentItem;
private float frameTime;
@Override
protected Set<Item> getAllowedFuels() {
return EndStoneSmelterBlockEntity.availableFuels().keySet();
}
@Override
public void slotClicked(Slot slot) {
super.slotClicked(slot);
@ -40,7 +40,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
this.fuelSlot = null;
}
}
@Override
public void showGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
this.ghostSlots.reset();
@ -49,7 +49,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
this.ghostSlots.addSlot(Ingredient.ofStacks(result), (slots.get(3)).x, (slots.get(3)).y);
DefaultedList<Ingredient> inputs = recipe.getPreviewInputs();
Iterator<Ingredient> iterator = inputs.iterator();
for(int i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
if (!iterator.hasNext()) {
return;
}
@ -67,7 +67,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
this.fuelIterator = this.fuels.iterator();
this.currentItem = null;
}
@Override
public void drawGhostSlots(MatrixStack matrices, int x, int y, boolean bl, float f) {
this.ghostSlots.draw(matrices, client, x, y, bl, f);
@ -79,7 +79,8 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
int slotX = this.fuelSlot.x + x;
int slotY = this.fuelSlot.y + y;
DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
this.client.getItemRenderer().renderInGuiWithOverrides(client.player, this.getItem().getDefaultStack(), slotX, slotY);
this.client.getItemRenderer().renderInGuiWithOverrides(client.player, this.getItem().getDefaultStack(),
slotX, slotY);
RenderSystem.depthFunc(516);
DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583);
RenderSystem.depthFunc(515);

View file

@ -9,40 +9,42 @@ import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.world.entity.player.PlayerInventory;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.BetterEnd;
@Environment(EnvType.CLIENT)
public class EndStoneSmelterScreen extends HandledScreen<EndStoneSmelterScreenHandler> implements RecipeBookProvider {
private final static Identifier RECIPE_BUTTON_TEXTURE = new Identifier("textures/gui/recipe_button.png");
private final static Identifier BACKGROUND_TEXTURE = BetterEnd.makeID("textures/gui/smelter_gui.png");
private final static ResourceLocation RECIPE_BUTTON_TEXTURE = new ResourceLocation(
"textures/gui/recipe_button.png");
private final static ResourceLocation BACKGROUND_TEXTURE = BetterEnd.makeID("textures/gui/smelter_gui.png");
public final EndStoneSmelterRecipeBookScreen recipeBook;
private boolean narrow;
public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
this.recipeBook = new EndStoneSmelterRecipeBookScreen();
}
public void init() {
super.init();
this.narrow = this.width < 379;
this.recipeBook.initialize(width, height, client, narrow, handler);
this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth);
this.addButton(new TexturedButtonWidget(x + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
this.recipeBook.reset(narrow);
this.recipeBook.toggleOpen();
this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth);
((TexturedButtonWidget) buttonWidget).setPos(this.x + 20, height / 2 - 49);
}));
this.titleX = (this.backgroundWidth - this.textRenderer.getWidth((StringVisitable)this.title)) / 2;
this.addButton(new TexturedButtonWidget(x + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE,
(buttonWidget) -> {
this.recipeBook.reset(narrow);
this.recipeBook.toggleOpen();
this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth);
((TexturedButtonWidget) buttonWidget).setPos(this.x + 20, height / 2 - 49);
}));
this.titleX = (this.backgroundWidth - this.textRenderer.getWidth((StringVisitable) this.title)) / 2;
}
@Override
@ -84,13 +86,16 @@ public class EndStoneSmelterScreen extends HandledScreen<EndStoneSmelterScreenHa
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return this.recipeBook.keyPressed(keyCode, scanCode, modifiers) ? false : super.keyPressed(keyCode, scanCode, modifiers);
return this.recipeBook.keyPressed(keyCode, scanCode, modifiers) ? false
: super.keyPressed(keyCode, scanCode, modifiers);
}
@Override
protected boolean isClickOutsideBounds(double mouseX, double mouseY, int left, int top, int button) {
boolean isMouseOut = mouseX < left || mouseY < top || mouseX >= (left + backgroundWidth) || mouseY >= (top + backgroundHeight);
return this.recipeBook.isClickOutsideBounds(mouseX, mouseY, x, y, backgroundWidth, backgroundHeight, button) && isMouseOut;
boolean isMouseOut = mouseX < left || mouseY < top || mouseX >= (left + backgroundWidth)
|| mouseY >= (top + backgroundHeight);
return this.recipeBook.isClickOutsideBounds(mouseX, mouseY, x, y, backgroundWidth, backgroundHeight, button)
&& isMouseOut;
}
@Override

View file

@ -3,21 +3,21 @@ package ru.betterend.client.gui;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeFinder;
import net.minecraft.recipe.RecipeInputProvider;
import net.minecraft.recipe.book.RecipeBookCategory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeFinder;
import net.minecraft.world.item.crafting.RecipeInputProvider;
import net.minecraft.world.item.crafting.book.RecipeBookCategory;
import net.minecraft.screen.AbstractRecipeScreenHandler;
import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
@ -27,39 +27,40 @@ import ru.betterend.recipe.builders.AlloyingRecipe;
public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler<Inventory> {
public final static ScreenHandlerType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(
BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
public final static ScreenHandlerType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry
.registerSimple(BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
private final Inventory inventory;
private final PropertyDelegate propertyDelegate;
protected final World world;
protected final Level world;
public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory) {
this(syncId, playerInventory, new SimpleInventory(4), new ArrayPropertyDelegate(4));
}
public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate propertyDelegate) {
public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory,
PropertyDelegate propertyDelegate) {
super(HANDLER_TYPE, syncId);
this.inventory = inventory;
this.propertyDelegate = propertyDelegate;
this.world = playerInventory.player.world;
this.addProperties(propertyDelegate);
this.addSlot(new Slot(inventory, 0, 45, 17));
this.addSlot(new Slot(inventory, 1, 67, 17));
this.addSlot(new SmelterFuelSlot(this, inventory, 2, 56, 53));
this.addSlot(new SmelterOutputSlot(playerInventory.player, inventory, 3, 129, 35));
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 9; ++j) {
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(int i = 0; i < 9; ++i) {
for (int i = 0; i < 9; ++i) {
this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
}
}
@Override
public ScreenHandlerType<?> getType() {
return HANDLER_TYPE;
@ -113,13 +114,14 @@ public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler<In
}
protected boolean isSmeltable(ItemStack itemStack) {
return this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, new SimpleInventory(itemStack), this.world).isPresent();
return this.world.getRecipeManager()
.getFirstMatch(AlloyingRecipe.TYPE, new SimpleInventory(itemStack), this.world).isPresent();
}
public boolean isFuel(ItemStack itemStack) {
return EndStoneSmelterBlockEntity.canUseAsFuel(itemStack);
}
@Override
public ItemStack transferSlot(PlayerEntity player, int index) {
ItemStack itemStack = ItemStack.EMPTY;
@ -167,7 +169,7 @@ public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler<In
return itemStack;
}
@Environment(EnvType.CLIENT)
public int getSmeltProgress() {
int time = this.propertyDelegate.get(2);

View file

@ -1,7 +1,7 @@
package ru.betterend.client.gui.slot;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
import net.minecraft.screen.slot.FurnaceFuelSlot;
import net.minecraft.screen.slot.Slot;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
@ -9,12 +9,12 @@ import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
public class SmelterFuelSlot extends Slot {
private final EndStoneSmelterScreenHandler handler;
public SmelterFuelSlot(EndStoneSmelterScreenHandler handler, Inventory inventory, int index, int x, int y) {
super(inventory, index, x, y);
this.handler = handler;
}
public boolean canInsert(ItemStack stack) {
return this.handler.isFuel(stack) || FurnaceFuelSlot.isBucket(stack);
}

View file

@ -1,8 +1,8 @@
package ru.betterend.client.gui.slot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
import net.minecraft.screen.slot.Slot;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
@ -41,7 +41,7 @@ public class SmelterOutputSlot extends Slot {
protected void onCrafted(ItemStack stack) {
stack.onCraft(this.player.world, this.player, this.amount);
if (!this.player.world.isClient && this.inventory instanceof EndStoneSmelterBlockEntity) {
if (!this.player.world.isClientSide && this.inventory instanceof EndStoneSmelterBlockEntity) {
((EndStoneSmelterBlockEntity) this.inventory).dropExperience(player);
}
this.amount = 0;

View file

@ -6,57 +6,70 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.util.math.Matrix4f;
public class BeamRenderer {
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
public static void renderLightBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int age, float tick, int minY, int maxY, float[] colors, float alpha, float beamIn, float beamOut) {
private static final ResourceLocation BEAM_TEXTURE = new ResourceLocation("textures/entity/end_gateway_beam.png");
public static void renderLightBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int age,
float tick, int minY, int maxY, float[] colors, float alpha, float beamIn, float beamOut) {
float red = colors[0];
float green = colors[1];
float blue = colors[2];
int maxBY = minY + maxY;
float delta = maxY < 0 ? tick : -tick;
float fractDelta = MathHelper.fractionalPart(delta * 0.2F - (float) MathHelper.floor(delta * 0.1F));
float fractDelta = Mth.fractionalPart(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
float xIn = -beamIn;
float minV = MathHelper.clamp(fractDelta - 1.0F, 0.0F, 1.0F);
float minV = Mth.clamp(fractDelta - 1.0F, 0.0F, 1.0F);
float maxV = (float) maxY * (0.5F / beamIn) + minV;
float rotation = (age + tick) / 25.0F + 6.0F;
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
matrices.push();
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(-rotation));
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, beamIn, 0.0F, 0.0F, beamIn, 0.0F, xIn, xIn, 0.0F, 0.0F, 1.0F, minV, maxV);
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, beamIn, 0.0F, 0.0F, beamIn, 0.0F,
xIn, xIn, 0.0F, 0.0F, 1.0F, minV, maxV);
float xOut = -beamOut;
maxV = (float) maxY + minV;
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, xOut, xOut, beamOut, xOut, xOut, beamOut, beamOut, beamOut, 0.0F, 1.0F, minV, maxV);
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, xOut, xOut, beamOut, xOut, xOut,
beamOut, beamOut, beamOut, 0.0F, 1.0F, minV, maxV);
matrices.pop();
}
private static void renderBeam(MatrixStack matrices, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int minY, int maxY, float x1, float d1, float x2, float d2, float x3, float d3, float x4, float d4, float minU, float maxU, float minV, float maxV) {
private static void renderBeam(MatrixStack matrices, VertexConsumer vertexConsumer, float red, float green,
float blue, float alpha, int minY, int maxY, float x1, float d1, float x2, float d2, float x3, float d3,
float x4, float d4, float minU, float maxU, float minV, float maxV) {
MatrixStack.Entry entry = matrices.peek();
Matrix4f matrix4f = entry.getModel();
Matrix3f matrix3f = entry.getNormal();
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x1, d1, x2, d2, minU, maxU, minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x4, d4, x3, d3, minU, maxU, minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x2, d2, x4, d4, minU, maxU, minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x3, d3, x1, d1, minU, maxU, minV, maxV);
Matrix3f matrix3f = entry.getNormal();
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x1, d1, x2, d2, minU, maxU,
minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x4, d4, x3, d3, minU, maxU,
minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x2, d2, x4, d4, minU, maxU,
minV, maxV);
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x3, d3, x1, d1, minU, maxU,
minV, maxV);
}
private static void renderBeam(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int minY, int maxY, float minX, float minD, float maxX, float maxD, float minU, float maxU, float minV, float maxV) {
private static void renderBeam(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red,
float green, float blue, float alpha, int minY, int maxY, float minX, float minD, float maxX, float maxD,
float minU, float maxU, float minV, float maxV) {
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxX, minY, maxD, maxU, minV);
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxX, maxY, maxD, maxU, maxV);
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, minX, maxY, minD, minU, maxV);
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, minX, minY, minD, minU, minV);
}
private static void addVertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, float x, float y, float d, float u, float v) {
vertexConsumer.vertex(matrix4f, x, y, d).color(red, green, blue, alpha).texture(u, v).overlay(OverlayTexture.DEFAULT_UV).light(15728880).normal(matrix3f, 0.0F, 1.0F, 0.0F).next();
private static void addVertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red,
float green, float blue, float alpha, float x, float y, float d, float u, float v) {
vertexConsumer.vertex(matrix4f, x, y, d).color(red, green, blue, alpha).texture(u, v)
.overlay(OverlayTexture.DEFAULT_UV).light(15728880).normal(matrix3f, 0.0F, 1.0F, 0.0F).next();
}
}

View file

@ -7,24 +7,27 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Quaternion;
public class EndCrystalRenderer {
private static final Identifier CRYSTAL_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal.png");
private static final Identifier CRYSTAL_BEAM_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal_beam.png");
private static final ResourceLocation CRYSTAL_TEXTURE = new ResourceLocation(
"textures/entity/end_crystal/end_crystal.png");
private static final ResourceLocation CRYSTAL_BEAM_TEXTURE = new ResourceLocation(
"textures/entity/end_crystal/end_crystal_beam.png");
private static final RenderLayer CRYSTAL_BEAM_LAYER;
private static final RenderLayer END_CRYSTAL;
private static final ModelPart CORE;
private static final ModelPart FRAME;
private static final int AGE_CYCLE = 240;
private static final float SINE_45_DEGREES;
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices,
VertexConsumerProvider vertexConsumerProvider, int light) {
float k = (float) AGE_CYCLE / maxAge;
float rotation = (age * k + tickDelta) * 3.0F;
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
@ -45,20 +48,23 @@ public class EndCrystalRenderer {
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
matrices.pop();
}
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices,
VertexConsumerProvider vertexConsumers, int light) {
float dx = start.getX() - end.getX() + 1.0F;
float dy = start.getY() - end.getY() + 1.0F;
float dz = start.getZ() - end.getZ() + 1.0F;
float f = MathHelper.sqrt(dx * dx + dz * dz);
float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
float f = Mth.sqrt(dx * dx + dz * dz);
float g = Mth.sqrt(dx * dx + dy * dy + dz * dz);
matrices.push();
matrices.translate(0.0D, 2.0D, 0.0D);
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float)(-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float)(-Math.atan2((double) f, (double) dy)) - 1.5707964F));
matrices.multiply(
Vector3f.POSITIVE_Y.getRadialQuaternion((float) (-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
matrices.multiply(
Vector3f.POSITIVE_X.getRadialQuaternion((float) (-Math.atan2((double) f, (double) dy)) - 1.5707964F));
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
float h = 0.0F - ((float) age + tickDelta) * 0.01F;
float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float) age + tickDelta) * 0.01F;
float i = Mth.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float) age + tickDelta) * 0.01F;
float k = 0.0F;
float l = 0.75F;
float m = 0.0F;
@ -66,22 +72,26 @@ public class EndCrystalRenderer {
Matrix4f matrix4f = entry.getModel();
Matrix3f matrix3f = entry.getNormal();
for(int n = 1; n <= 8; ++n) {
float o = MathHelper.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
float p = MathHelper.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
float q = (float) n / 8.0F;
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
k = o;
l = p;
m = q;
for (int n = 1; n <= 8; ++n) {
float o = Mth.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
float p = Mth.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
float q = (float) n / 8.0F;
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h)
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i)
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i)
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h)
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
k = o;
l = p;
m = q;
}
matrices.pop();
}
static {
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);

View file

@ -7,8 +7,8 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.Mth;
import net.minecraft.core.Vec3i;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.util.ColorUtil;
@ -18,44 +18,47 @@ public class EternalCrystalRenderer {
private static final RenderLayer RENDER_LAYER;
private static final ModelPart[] SHARDS;
private static final ModelPart CORE;
public static void render(int age, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
public static void render(int age, float tickDelta, MatrixStack matrices,
VertexConsumerProvider vertexConsumerProvider, int light) {
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
float[] colors = colors(age);
float rotation = (age + tickDelta) / 25.0F + 6.0F;
matrices.push();
matrices.scale(0.6F, 0.6F, 0.6F);
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1], colors[2], colors[3]);
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1], colors[2],
colors[3]);
for (int i = 0; i < 4; i++) {
matrices.push();
float offset = MathHelper.sin(rotation * 2 + i) * 0.15F;
float offset = Mth.sin(rotation * 2 + i) * 0.15F;
matrices.translate(0, offset, 0);
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1], colors[2], colors[3]);
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1],
colors[2], colors[3]);
matrices.pop();
}
matrices.pop();
}
public static float[] colors(int age) {
double delta = age * 0.01;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = AuroraCrystalBlock.COLORS[index];
Vec3i color2 = AuroraCrystalBlock.COLORS[index2];
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return ColorUtil.toFloatArray(MHelper.color(r, g, b));
}
static {
RENDER_LAYER = RenderLayer.getBeaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
SHARDS = new ModelPart[4];