Code style changes, entities fixes
This commit is contained in:
parent
9d604b2d25
commit
44962e18b6
377 changed files with 5038 additions and 4914 deletions
|
@ -1,7 +1,5 @@
|
|||
package ru.betterend.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -30,6 +28,8 @@ import ru.betterend.registry.EndModelProviders;
|
|||
import ru.betterend.registry.EndParticles;
|
||||
import ru.betterend.registry.EndScreens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BetterEndClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
@ -43,7 +43,7 @@ public class BetterEndClient implements ClientModInitializer {
|
|||
ClientOptions.init();
|
||||
registerRenderers();
|
||||
registerTooltips();
|
||||
|
||||
|
||||
if (BCLib.isDevEnvironment()) {
|
||||
TranslationHelper.printMissingNames(BetterEnd.MOD_ID);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ public class ClientOptions {
|
|||
private static boolean useFogDensity;
|
||||
private static boolean blendBiomeMusic;
|
||||
private static boolean sulfurWaterColor;
|
||||
|
||||
|
||||
public static void init() {
|
||||
customSky = Configs.CLENT_CONFIG.getBooleanRoot("customSky", true);
|
||||
useFogDensity = Configs.CLENT_CONFIG.getBooleanRoot("useFogDensity", true);
|
||||
|
@ -39,7 +39,7 @@ public class ClientOptions {
|
|||
public static void setBlendBiomeMusic(boolean blendBiomeMusic) {
|
||||
ClientOptions.blendBiomeMusic = blendBiomeMusic;
|
||||
}
|
||||
|
||||
|
||||
public static boolean useSulfurWaterColor() {
|
||||
return sulfurWaterColor;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package ru.betterend.client.gui;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
|
@ -20,6 +15,10 @@ import net.minecraft.world.item.crafting.Ingredient;
|
|||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent {
|
||||
private Iterator<Item> fuelIterator;
|
||||
|
@ -27,12 +26,12 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
private Slot fuelSlot;
|
||||
private Item currentItem;
|
||||
private float frameTime;
|
||||
|
||||
|
||||
@Override
|
||||
protected Set<Item> getFuelItems() {
|
||||
return EndStoneSmelterBlockEntity.availableFuels().keySet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void slotClicked(Slot slot) {
|
||||
super.slotClicked(slot);
|
||||
|
@ -40,7 +39,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.fuelSlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setupGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
this.ghostRecipe.clear();
|
||||
|
@ -49,7 +48,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.ghostRecipe.addIngredient(Ingredient.of(result), (slots.get(3)).x, (slots.get(3)).y);
|
||||
NonNullList<Ingredient> inputs = recipe.getIngredients();
|
||||
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 +66,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.fuelIterator = this.fuels.iterator();
|
||||
this.currentItem = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderGhostRecipe(PoseStack matrices, int x, int y, boolean bl, float f) {
|
||||
this.ghostRecipe.render(matrices, minecraft, x, y, bl, f);
|
||||
|
@ -80,7 +79,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
int slotY = this.fuelSlot.y + y;
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
|
||||
//TODO: test k=0
|
||||
this.minecraft.getItemRenderer().renderAndDecorateItem(minecraft.player, this.getFuel().getDefaultInstance(), slotX, slotY,0);
|
||||
this.minecraft.getItemRenderer().renderAndDecorateItem(minecraft.player, this.getFuel().getDefaultInstance(), slotX, slotY, 0);
|
||||
RenderSystem.depthFunc(516);
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583);
|
||||
RenderSystem.depthFunc(515);
|
||||
|
|
|
@ -2,7 +2,6 @@ package ru.betterend.client.gui;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
|
@ -21,15 +20,15 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
|
||||
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, Inventory inventory, Component title) {
|
||||
super(handler, inventory, title);
|
||||
recipeBook = new EndStoneSmelterRecipeBookScreen();
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
super.init();
|
||||
//TODO: test in 1.17
|
||||
|
@ -39,7 +38,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
addRenderableWidget(new ImageButton(leftPos + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
|
||||
recipeBook.initVisuals();
|
||||
recipeBook.toggleVisibility();
|
||||
leftPos = recipeBook.updateScreenPosition( width, imageWidth);
|
||||
leftPos = recipeBook.updateScreenPosition(width, imageWidth);
|
||||
((ImageButton) buttonWidget).setPosition(leftPos + 20, height / 2 - 49);
|
||||
}));
|
||||
titleLabelX = (imageWidth - font.width(title)) / 2;
|
||||
|
@ -57,7 +56,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
if (recipeBook.isVisible() && narrow) {
|
||||
renderBg(matrices, delta, mouseX, mouseY);
|
||||
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
recipeBook.renderGhostRecipe(matrices, leftPos, topPos, true, delta);
|
||||
|
@ -70,7 +70,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return narrow && recipeBook.isVisible() || super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,37 +29,37 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
|
||||
public final static MenuType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(
|
||||
BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
|
||||
|
||||
|
||||
private final Container inventory;
|
||||
private final ContainerData propertyDelegate;
|
||||
protected final Level world;
|
||||
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(4), new SimpleContainerData(4));
|
||||
}
|
||||
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate) {
|
||||
super(HANDLER_TYPE, syncId);
|
||||
this.inventory = inventory;
|
||||
this.propertyDelegate = propertyDelegate;
|
||||
this.world = playerInventory.player.level;
|
||||
|
||||
|
||||
addDataSlots(propertyDelegate);
|
||||
addSlot(new Slot(inventory, 0, 45, 17));
|
||||
addSlot(new Slot(inventory, 1, 67, 17));
|
||||
addSlot(new SmelterFuelSlot(this, inventory, 2, 56, 53));
|
||||
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) {
|
||||
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) {
|
||||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MenuType<?> getType() {
|
||||
return HANDLER_TYPE;
|
||||
|
@ -124,7 +124,7 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
public boolean isFuel(ItemStack itemStack) {
|
||||
return EndStoneSmelterBlockEntity.canUseAsFuel(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int index) {
|
||||
Slot slot = slots.get(index);
|
||||
|
@ -137,29 +137,35 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
slot.onQuickCraft(slotStack, itemStack);
|
||||
} else if (index != 2 && index != 1 && index != 0) {
|
||||
}
|
||||
else if (index != 2 && index != 1 && index != 0) {
|
||||
if (isSmeltable(slotStack)) {
|
||||
if (!moveItemStackTo(slotStack, 0, 2, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isFuel(slotStack)) {
|
||||
}
|
||||
else if (isFuel(slotStack)) {
|
||||
if (!moveItemStackTo(slotStack, 2, 3, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 31) {
|
||||
}
|
||||
else if (index < 31) {
|
||||
if (!moveItemStackTo(slotStack, 31, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 40 && !moveItemStackTo(slotStack, 4, 31, false)) {
|
||||
}
|
||||
else if (index < 40 && !moveItemStackTo(slotStack, 4, 31, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!moveItemStackTo(slotStack, 4, 40, false)) {
|
||||
}
|
||||
else if (!moveItemStackTo(slotStack, 4, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (slotStack.isEmpty()) {
|
||||
slot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
slot.setChanged();
|
||||
}
|
||||
|
||||
|
@ -171,7 +177,7 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getSmeltProgress() {
|
||||
int time = propertyDelegate.get(2);
|
||||
|
|
|
@ -9,12 +9,12 @@ import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
|
|||
public class SmelterFuelSlot extends Slot {
|
||||
|
||||
private final EndStoneSmelterScreenHandler handler;
|
||||
|
||||
|
||||
public SmelterFuelSlot(EndStoneSmelterScreenHandler handler, Container inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return this.handler.isFuel(stack) || FurnaceFuelSlot.isBucket(stack);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package ru.betterend.client.models;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -10,13 +16,6 @@ import java.util.Map.Entry;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class Patterns {
|
||||
//Block Models
|
||||
public final static ResourceLocation BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json");
|
||||
|
@ -75,7 +74,7 @@ public class Patterns {
|
|||
public final static ResourceLocation BLOCK_FURNACE_LIT = BetterEnd.makeID("patterns/block/furnace_glow.json");
|
||||
public final static ResourceLocation BLOCK_TOP_SIDE_BOTTOM = BetterEnd.makeID("patterns/block/top_side_bottom.json");
|
||||
public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json");
|
||||
|
||||
|
||||
//Item Models
|
||||
public final static ResourceLocation ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json");
|
||||
public final static ResourceLocation ITEM_FENCE = BetterEnd.makeID("patterns/item/pattern_fence.json");
|
||||
|
@ -93,25 +92,28 @@ public class Patterns {
|
|||
public static Optional<String> createBlockSimple(String name) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, name, name);
|
||||
}
|
||||
|
||||
public static Optional<String> createBlockPillar(String name) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PILLAR, name, name);
|
||||
}
|
||||
|
||||
|
||||
public static String createJson(Reader data, String parent, String block) {
|
||||
try (BufferedReader buffer = new BufferedReader(data)) {
|
||||
return buffer.lines().collect(Collectors.joining())
|
||||
.replace("%parent%", parent)
|
||||
.replace("%block%", block);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Optional<String> createJson(ResourceLocation patternId, String parent, String block) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
return Optional.ofNullable(createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +133,8 @@ public class Patterns {
|
|||
json = json.replace(texture.getKey(), texture.getValue());
|
||||
}
|
||||
return Optional.of(json);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package ru.betterend.client.render;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.geom.EntityModelSet;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
|
@ -37,7 +36,8 @@ public class ArmoredElytraLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) livingEntity;
|
||||
if (abstractClientPlayer.isElytraLoaded() && abstractClientPlayer.getElytraTextureLocation() != null) {
|
||||
wingsTexture = abstractClientPlayer.getElytraTextureLocation();
|
||||
} else if (abstractClientPlayer.isCapeLoaded() && abstractClientPlayer.getCloakTextureLocation() != null && abstractClientPlayer.isModelPartShown(PlayerModelPart.CAPE)) {
|
||||
}
|
||||
else if (abstractClientPlayer.isCapeLoaded() && abstractClientPlayer.getCloakTextureLocation() != null && abstractClientPlayer.isModelPartShown(PlayerModelPart.CAPE)) {
|
||||
wingsTexture = abstractClientPlayer.getCloakTextureLocation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
|||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
|
@ -14,26 +13,26 @@ import net.minecraft.util.Mth;
|
|||
|
||||
public class BeamRenderer {
|
||||
private static final ResourceLocation BEAM_TEXTURE = new ResourceLocation("textures/entity/end_gateway_beam.png");
|
||||
|
||||
|
||||
public static void renderLightBeam(PoseStack matrices, MultiBufferSource 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 = Mth.frac(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float fractDelta = Mth.frac(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float xIn = -beamIn;
|
||||
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(RenderType.beaconBeam(BEAM_TEXTURE, true));
|
||||
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(Vector3f.YP.rotation(-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);
|
||||
|
||||
|
||||
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);
|
||||
|
@ -43,7 +42,7 @@ public class BeamRenderer {
|
|||
private static void renderBeam(PoseStack 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) {
|
||||
PoseStack.Pose entry = matrices.last();
|
||||
Matrix4f matrix4f = entry.pose();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
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);
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
|
@ -24,7 +23,7 @@ public class EndCrystalRenderer {
|
|||
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, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
|
@ -51,18 +50,18 @@ public class EndCrystalRenderer {
|
|||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
modelPartData.addOrReplaceChild("FRAME", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
.texOffs(0, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("CORE", CubeListBuilder.create()
|
||||
.texOffs(32, 0)
|
||||
.texOffs(32, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
return LayerDefinition.create(modelData, 64, 32);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderType.entityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
RenderType.entitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
|
|
|
@ -3,7 +3,6 @@ package ru.betterend.client.render;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
|
@ -24,7 +23,7 @@ public class EternalCrystalRenderer {
|
|||
private static final RenderType RENDER_LAYER;
|
||||
private static final ModelPart[] SHARDS;
|
||||
private static final ModelPart CORE;
|
||||
|
||||
|
||||
public static void render(int age, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
|
||||
float[] colors = colors(age);
|
||||
|
@ -33,7 +32,7 @@ public class EternalCrystalRenderer {
|
|||
matrices.scale(0.6F, 0.6F, 0.6F);
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
matrices.pushPose();
|
||||
float offset = Mth.sin(rotation * 2 + i) * 0.15F;
|
||||
|
@ -41,24 +40,24 @@ public class EternalCrystalRenderer {
|
|||
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
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(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(ColorUtil.color(r, g, b));
|
||||
}
|
||||
|
||||
|
@ -66,33 +65,33 @@ public class EternalCrystalRenderer {
|
|||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
modelPartData.addOrReplaceChild("SHARDS_0", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(-5.0f, 1.0f, -3.0f, 2.0f, 8.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_1", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(3.0f, -1.0f, -1.0f, 2.0f, 8.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_2", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(-1.0f, 0.0f, -5.0f, 2.0f, 4.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_3", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(0.0f, 3.0f, 4.0f, 2.0f, 6.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("CORE", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.texOffs(0, 0)
|
||||
.addBox(-2.0f, -2.0f, -2.0f, 4.0f, 12.0f, 4.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
return LayerDefinition.create(modelData, 16, 16);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
RENDER_LAYER = RenderType.beaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
|
||||
SHARDS = new ModelPart[4];
|
||||
|
|
|
@ -2,16 +2,13 @@ package ru.betterend.client.render;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
@ -27,21 +24,21 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> implements BlockEntityRenderer<T> {
|
||||
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T blockEntity, float tickDelta, PoseStack matrices,
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
|
||||
Level world = blockEntity.getLevel();
|
||||
if (world == null || blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = world.getBlockState(blockEntity.getBlockPos());
|
||||
if (!(state.getBlock() instanceof PedestalBlock)) return;
|
||||
|
||||
|
||||
ItemStack activeItem = blockEntity.getItem(0);
|
||||
|
||||
matrices.pushPose();
|
||||
|
@ -54,23 +51,26 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> implements Bloc
|
|||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
int age = blockEntity.getAge();
|
||||
if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = EternalCrystalRenderer.colors(age);
|
||||
int y = blockEntity.getBlockPos().getY();
|
||||
|
||||
|
||||
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) {
|
||||
EndCrystalRenderer.render(age, blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
}
|
||||
else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
EternalCrystalRenderer.render(age, tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
minecraft.getItemRenderer().render(activeItem, ItemTransforms.TransformType.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue