1.17: RebornCore compiles, big thanks to @petabyteboy

Co-authored-by: Milan Pässler <milan@petabyte.dev>
This commit is contained in:
modmuss50 2021-05-29 12:49:17 +01:00
parent 9520a3e607
commit c661de5254
46 changed files with 412 additions and 454 deletions

View file

@ -109,7 +109,7 @@ public class RebornCore implements ModInitializer {
RebornCoreTags.WATER_EXPLOSION_ITEM.toString();
/* register UnloadHandler */
ServerBlockEntityEvents.BLOCK_ENTITY_UNLOAD.register((blockEntity, world) -> {
ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> {
if (blockEntity instanceof UnloadHandler) ((UnloadHandler) blockEntity).onUnload();
});

View file

@ -50,7 +50,7 @@ public class RebornCoreClient implements ClientModInitializer {
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
/* register UnloadHandler */
ClientBlockEntityEvents.BLOCK_ENTITY_UNLOAD.register((blockEntity, world) -> {
ClientBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> {
if (blockEntity instanceof UnloadHandler) ((UnloadHandler) blockEntity).onUnload();
});
}

View file

@ -27,7 +27,7 @@ package reborncore.api.items;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
public interface ArmorTickable {
public interface ArmorBlockEntityTicker {
void tickArmor(ItemStack stack, PlayerEntity playerEntity);
}

View file

@ -28,10 +28,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import reborncore.common.chunkloading.ChunkLoaderManager;
@ -72,9 +69,12 @@ public class ClientChunkManager {
final MinecraftClient minecraftClient = MinecraftClient.getInstance();
RenderSystem.enableDepthTest();
RenderSystem.shadeModel(7425);
// FIXME 1.17
/*RenderSystem.shadeModel(7425);
RenderSystem.enableAlphaTest();
RenderSystem.defaultAlphaFunc();
RenderSystem.defaultAlphaFunc();*/
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder bufferBuilder = tessellator.getBuffer();
@ -83,7 +83,7 @@ public class ClientChunkManager {
RenderSystem.disableBlend();
RenderSystem.lineWidth(5.0F);
bufferBuilder.begin(3, VertexFormats.POSITION_COLOR);
bufferBuilder.begin(VertexFormat.DrawMode.LINE_STRIP, VertexFormats.POSITION_COLOR);
loadedChunks.stream()
.filter(loadedChunk -> loadedChunk.getWorld().equals(ChunkLoaderManager.getWorldName(minecraftClient.world)))

View file

@ -24,8 +24,8 @@
package reborncore.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
@ -35,9 +35,9 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import reborncore.common.RebornCoreConfig;
import reborncore.common.util.CalenderUtils;
@ -48,7 +48,7 @@ public class HolidayRenderManager {
public static void setupClient() {
if (CalenderUtils.christmas && RebornCoreConfig.easterEggs) {
LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper) -> {
LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> {
if (entityRenderer.getModel() instanceof PlayerEntityModel) {
registrationHelper.register(new LayerRender(entityRenderer));
}
@ -67,12 +67,12 @@ public class HolidayRenderManager {
@Override
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T player, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
MinecraftClient.getInstance().getTextureManager().bindTexture(TEXTURE);
RenderSystem.setShaderTexture(0, TEXTURE);
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(TEXTURE));
matrixStack.push();
float yaw = player.prevYaw + (player.yaw - player.prevYaw) * tickDelta - (player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw) * tickDelta);
float pitch = player.prevPitch + (player.pitch - player.prevPitch) * tickDelta;
float yaw = player.prevYaw + (player.getYaw() - player.prevYaw) * tickDelta - (player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw) * tickDelta);
float pitch = player.prevPitch + (player.getPitch() - player.prevPitch) * tickDelta;
matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(yaw));
matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(pitch));

View file

@ -30,7 +30,9 @@ import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.SimpleFramebuffer;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
@ -41,6 +43,7 @@ import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.registry.Registry;
import org.apache.commons.io.FileUtils;
import org.lwjgl.opengl.GL11;
@ -60,12 +63,12 @@ public class ItemStackRenderer implements HudRenderCallback {
MinecraftClient.getInstance().textRenderer.draw(matrixStack, "Rendering " + ItemStackRenderManager.RENDER_QUEUE.size() + " items left", 5, 5, -1);
ItemStack itemStack = ItemStackRenderManager.RENDER_QUEUE.poll();
export(itemStack, 512, Registry.ITEM.getId(itemStack.getItem()));
export(matrixStack, itemStack, 512, Registry.ITEM.getId(itemStack.getItem()));
}
}
private void export(ItemStack stack, int size, Identifier identifier) {
File dir = new File(FabricLoader.getInstance().getGameDirectory(), "item_renderer/" + identifier.getNamespace());
private void export(MatrixStack matrixStack, ItemStack stack, int size, Identifier identifier) {
File dir = new File(FabricLoader.getInstance().getGameDir().toFile(), "item_renderer/" + identifier.getNamespace());
if (!dir.exists()) {
dir.mkdir();
}
@ -81,38 +84,36 @@ public class ItemStackRenderer implements HudRenderCallback {
return;
}
final Framebuffer framebuffer = new Framebuffer(size, size, true, MinecraftClient.IS_SYSTEM_MAC);
final Framebuffer framebuffer = new SimpleFramebuffer(size, size, true, true);
framebuffer.setClearColor(0.0F, 0.0F, 0.0F, 0.0F);
framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
framebuffer.beginWrite(true);
final ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
final BakedModel model = itemRenderer.getHeldItemModel(stack, minecraft.world, minecraft.player);
final BakedModel model = itemRenderer.getHeldItemModel(stack, minecraft.world, minecraft.player, 0);
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.pushMatrix();
RenderSystem.loadIdentity();
RenderSystem.ortho(-1, 1, 1, -1, -100.0, 100.0);
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.pushMatrix();
RenderSystem.loadIdentity();
// FIXME 1.17
Matrix4f matrix4f = Matrix4f.projectionMatrix(-1, 1, 1, -1, -100.0F, -100.0F); // ortho
RenderSystem.backupProjectionMatrix();
RenderSystem.setProjectionMatrix(matrix4f);
matrixStack.push();
matrixStack.loadIdentity();
RenderSystem.applyModelViewMatrix();
{
minecraft.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
minecraft.getTextureManager().getTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE).setFilter(false, false);
RenderSystem.setShaderTexture(0, SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();
RenderSystem.defaultAlphaFunc();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
MatrixStack matrixStack = new MatrixStack();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
MatrixStack matrixStack2 = new MatrixStack();
matrixStack.scale(2F, -2F, 1F);
matrixStack2.scale(2F, -2F, 1F);
boolean frontLit = !model.isSideLit();
if (frontLit) {
@ -120,7 +121,7 @@ public class ItemStackRenderer implements HudRenderCallback {
}
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
itemRenderer.renderItem(stack, ModelTransformation.Mode.GUI, false, matrixStack, immediate, 15728880, OverlayTexture.DEFAULT_UV, model);
itemRenderer.renderItem(stack, ModelTransformation.Mode.GUI, false, matrixStack2, immediate, 15728880, OverlayTexture.DEFAULT_UV, model);
immediate.draw();
RenderSystem.enableDepthTest();
@ -128,21 +129,17 @@ public class ItemStackRenderer implements HudRenderCallback {
if (frontLit) {
DiffuseLighting.enableGuiDepthLighting();
}
RenderSystem.disableAlphaTest();
RenderSystem.disableRescaleNormal();
}
RenderSystem.popMatrix();
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.popMatrix();
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
matrixStack.pop();
RenderSystem.applyModelViewMatrix();
RenderSystem.restoreProjectionMatrix();
framebuffer.endWrite();
try (NativeImage nativeImage = new NativeImage(size, size, false)) {
GlStateManager.bindTexture(framebuffer.getColorAttachment());
// FIXME 1.17
//GlStateManager.bindTexture(framebuffer.getColorAttachment());
nativeImage.loadFromTextureImage(0, false);
nativeImage.mirrorVertically();

View file

@ -36,6 +36,9 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import java.util.Arrays;
import java.util.Collections;
public class ModelSantaHat extends EntityModel<AbstractClientPlayerEntity> {
private final ModelPart hatband1;
private final ModelPart hatband2;
@ -57,116 +60,130 @@ public class ModelSantaHat extends EntityModel<AbstractClientPlayerEntity> {
private final ModelPart hatball6;
public ModelSantaHat() {
textureWidth = 64;
textureHeight = 64;
hatband1 = new ModelPart(this, 0, 32);
hatband1.addCuboid(-4F, -8F, -5F, 8, 1, 1);
ModelPart.Cuboid[] hatband1Cuboids = {
new ModelPart.Cuboid(0, 32, -4F, -8F, -5F, 8F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband1 = new ModelPart(Arrays.asList(hatband1Cuboids), Collections.emptyMap());
hatband1.setPivot(0F, 0F, 0F);
hatband1.setTextureSize(64, 64);
hatband1.mirror = true;
setRotation(hatband1, 0F, 0F, 0F);
hatband2 = new ModelPart(this, 0, 32);
hatband2.addCuboid(-4F, -8F, 4F, 8, 1, 1);
ModelPart.Cuboid[] hatband2Cuboids = {
new ModelPart.Cuboid(0, 32, -4F, -8F, 4F, 8F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband2 = new ModelPart(Arrays.asList(hatband2Cuboids), Collections.emptyMap());
hatband2.setPivot(0F, 0F, 0F);
hatband2.setTextureSize(64, 64);
hatband2.mirror = true;
setRotation(hatband2, 0F, 0F, 0F);
hatband3 = new ModelPart(this, 0, 34);
hatband3.addCuboid(-5F, -8F, -4F, 1, 1, 8);
ModelPart.Cuboid[] hatband3Cuboids = {
new ModelPart.Cuboid(0, 34, -5F, -8F, -4F, 1F, 1F, 8F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband3 = new ModelPart(Arrays.asList(hatband3Cuboids), Collections.emptyMap());
hatband3.setPivot(0F, 0F, 0F);
hatband3.setTextureSize(64, 64);
hatband3.mirror = true;
setRotation(hatband3, 0F, 0F, 0F);
hatband4 = new ModelPart(this, 0, 34);
hatband4.addCuboid(4F, -8F, -4F, 1, 1, 8);
ModelPart.Cuboid[] hatband4Cuboids = {
new ModelPart.Cuboid(0, 34, 4F, -8F, -4F, 1F, 1F, 8F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband4 = new ModelPart(Arrays.asList(hatband4Cuboids), Collections.emptyMap());
hatband4.setPivot(0F, 0F, 0F);
hatband4.setTextureSize(64, 64);
hatband4.mirror = true;
setRotation(hatband4, 0F, 0F, 0F);
hatbase1 = new ModelPart(this, 0, 43);
hatbase1.addCuboid(-4F, -9F, -4F, 8, 1, 8);
ModelPart.Cuboid[] hatbase1Cuboids = {
new ModelPart.Cuboid(0, 43, -4F, -9F, -4F, 8F, 1F, 8F, 0F, 0F, 0F, true, 64F, 64F)
};
hatbase1 = new ModelPart(Arrays.asList(hatbase1Cuboids), Collections.emptyMap());
hatbase1.setPivot(0F, 0F, 0F);
hatbase1.setTextureSize(64, 64);
hatbase1.mirror = true;
setRotation(hatbase1, 0F, 0F, 0F);
hatband5 = new ModelPart(this, 18, 41);
hatband5.addCuboid(0F, -7F, -5F, 4, 1, 1);
ModelPart.Cuboid[] hatband5Cuboids = {
new ModelPart.Cuboid(18, 41, 0F, -7F, -5F, 4F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband5 = new ModelPart(Arrays.asList(hatband5Cuboids), Collections.emptyMap());
hatband5.setPivot(0F, 0F, 0F);
hatband5.setTextureSize(64, 64);
hatband5.mirror = true;
setRotation(hatband5, 0F, 0F, 0F);
hatband6 = new ModelPart(this, 18, 41);
hatband6.addCuboid(-4F, -7F, 0F, 4, 1, 1);
ModelPart.Cuboid[] hatband6Cuboids = {
new ModelPart.Cuboid(18, 41, -4F, -7F, 0F, 4F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatband6 = new ModelPart(Arrays.asList(hatband6Cuboids), Collections.emptyMap());
hatband6.setPivot(0F, 0F, 4F);
hatband6.setTextureSize(64, 64);
hatband6.mirror = true;
setRotation(hatband6, 0F, 0F, 0F);
hatbase2 = new ModelPart(this, 18, 34);
hatbase2.addCuboid(-3F, -10F, -3F, 6, 1, 6);
ModelPart.Cuboid[] hatbase2Cuboids = {
new ModelPart.Cuboid(18, 34, -3F, -10F, -3F, 6F, 1F, 6F, 0F, 0F, 0F, true, 64F, 64F)
};
hatbase2 = new ModelPart(Arrays.asList(hatbase2Cuboids), Collections.emptyMap());
hatbase2.setPivot(0F, 0F, 0F);
hatbase2.setTextureSize(64, 64);
hatbase2.mirror = true;
setRotation(hatbase2, 0F, 0.1115358F, 0F);
hatextension1 = new ModelPart(this, 0, 52);
hatextension1.addCuboid(-3F, -11F, -2F, 4, 2, 4);
ModelPart.Cuboid[] hatextension1Cuboids = {
new ModelPart.Cuboid(0, 52, -3F, -11F, -2F, 4F, 2F, 4F, 0F, 0F, 0F, true, 64F, 64F)
};
hatextension1 = new ModelPart(Arrays.asList(hatextension1Cuboids), Collections.emptyMap());
hatextension1.setPivot(0F, 0F, 0F);
hatextension1.setTextureSize(64, 64);
hatextension1.mirror = true;
setRotation(hatextension1, 0F, -0.0371786F, 0.0743572F);
hatextension2 = new ModelPart(this, 16, 52);
hatextension2.addCuboid(-2.4F, -12F, -1.5F, 3, 2, 3);
ModelPart.Cuboid[] hatextension2Cuboids = {
new ModelPart.Cuboid(16, 52, -2.4F, -12F, -1.5F, 3F, 2F, 3F, 0F, 0F, 0F, true, 64F, 64F)
};
hatextension2 = new ModelPart(Arrays.asList(hatextension2Cuboids), Collections.emptyMap());
hatextension2.setPivot(0F, 0F, 0F);
hatextension2.setTextureSize(64, 64);
hatextension2.mirror = true;
setRotation(hatextension2, 0F, 0.0743572F, 0.0743572F);
hatextension3 = new ModelPart(this, 28, 52);
hatextension3.addCuboid(-3.5F, -13F, -1F, 2, 2, 2);
ModelPart.Cuboid[] hatextension3Cuboids = {
new ModelPart.Cuboid(28, 52, -3.5F, -13F, -1F, 2F, 2F, 2F, 0F, 0F, 0F, true, 64F, 64F)
};
hatextension3 = new ModelPart(Arrays.asList(hatextension3Cuboids), Collections.emptyMap());
hatextension3.setPivot(0F, 0F, 0F);
hatextension3.setTextureSize(64, 64);
hatextension3.mirror = true;
setRotation(hatextension3, 0F, 0F, 0.2230717F);
hatextension4 = new ModelPart(this, 0, 58);
hatextension4.addCuboid(-13F, -6.6F, -1F, 2, 3, 2);
ModelPart.Cuboid[] hatextension4Cuboids = {
new ModelPart.Cuboid(0, 58, -13F, -6.6F, -1F, 2F, 3F, 2F, 0F, 0F, 0F, true, 64F, 64F)
};
hatextension4 = new ModelPart(Arrays.asList(hatextension4Cuboids), Collections.emptyMap());
hatextension4.setPivot(0F, 0F, 0F);
hatextension4.setTextureSize(64, 64);
hatextension4.mirror = true;
setRotation(hatextension4, 0F, 0F, 1.264073F);
hatball1 = new ModelPart(this, 8, 58);
hatball1.addCuboid(2F, -14.4F, -1.001F, 2, 2, 2);
ModelPart.Cuboid[] hatball1Cuboids = {
new ModelPart.Cuboid(8, 58, 2F, -14.4F, -1.001F, 2F, 2F, 2F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball1 = new ModelPart(Arrays.asList(hatball1Cuboids), Collections.emptyMap());
hatball1.setPivot(0F, 0F, 0F);
hatball1.setTextureSize(64, 64);
hatball1.mirror = true;
setRotation(hatball1, 0F, 0F, 0F);
hatball2 = new ModelPart(this, 16, 57);
hatball2.addCuboid(2.5F, -14.8F, -0.5F, 1, 1, 1);
ModelPart.Cuboid[] hatball2Cuboids = {
new ModelPart.Cuboid(16, 57, 2.5F, -14.8F, -0.5F, 1F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball2 = new ModelPart(Arrays.asList(hatball2Cuboids), Collections.emptyMap());
hatball2.setPivot(0F, 0F, 0F);
hatball2.setTextureSize(64, 64);
hatball2.mirror = true;
setRotation(hatball2, 0F, 0F, 0F);
hatball3 = new ModelPart(this, 16, 57);
hatball3.addCuboid(2.5F, -13F, -0.5F, 1, 1, 1);
ModelPart.Cuboid[] hatball3Cuboids = {
new ModelPart.Cuboid(16, 57, 2.5F, -13F, -0.5F, 1F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball3 = new ModelPart(Arrays.asList(hatball3Cuboids), Collections.emptyMap());
hatball3.setPivot(0F, 0F, 0F);
hatball3.setTextureSize(64, 64);
hatball3.mirror = true;
setRotation(hatball3, 0F, 0F, 0F);
hatball4 = new ModelPart(this, 16, 57);
hatball4.addCuboid(3.4F, -14F, -0.5F, 1, 1, 1);
ModelPart.Cuboid[] hatball4Cuboids = {
new ModelPart.Cuboid(16, 57, 3.4F, -14F, -0.5F, 1F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball4 = new ModelPart(Arrays.asList(hatball4Cuboids), Collections.emptyMap());
hatball4.setPivot(0F, 0F, 0F);
hatball4.setTextureSize(64, 64);
hatball4.mirror = true;
setRotation(hatball4, 0F, 0F, 0F);
hatball5 = new ModelPart(this, 16, 57);
hatball5.addCuboid(2.5F, -14F, 0.4F, 1, 1, 1);
ModelPart.Cuboid[] hatball5Cuboids = {
new ModelPart.Cuboid(16, 57, 2.5F, -14F, 0.4F, 1F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball5 = new ModelPart(Arrays.asList(hatball5Cuboids), Collections.emptyMap());
hatball5.setPivot(0F, 0F, 0F);
hatball5.setTextureSize(64, 64);
hatball5.mirror = true;
setRotation(hatball5, 0F, 0F, 0F);
hatball6 = new ModelPart(this, 16, 57);
hatball6.addCuboid(2.5F, -14F, -1.4F, 1, 1, 1);
ModelPart.Cuboid[] hatball6Cuboids = {
new ModelPart.Cuboid(16, 57, 2.5F, -14F, -1.4F, 1F, 1F, 1F, 0F, 0F, 0F, true, 64F, 64F)
};
hatball6 = new ModelPart(Arrays.asList(hatball6Cuboids), Collections.emptyMap());
hatball6.setPivot(0F, 0F, 0F);
hatball6.setTextureSize(64, 64);
hatball6.mirror = true;
setRotation(hatball6, 0F, 0F, 0F);
}
@ -203,9 +220,4 @@ public class ModelSantaHat extends EntityModel<AbstractClientPlayerEntity> {
model.roll = z;
}
@Override
public void accept(ModelPart modelPart) {
}
}

View file

@ -29,16 +29,16 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.*;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluid;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.opengl.GL11;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.Tank;
@ -54,7 +54,7 @@ public class RenderUtil {
}
public static void bindBlockTexture() {
engine().bindTexture(BLOCK_TEX);
RenderSystem.setShaderTexture(0, BLOCK_TEX);
}
public static Sprite getStillTexture(FluidInstance fluid) {
@ -96,7 +96,8 @@ public class RenderUtil {
RenderUtil.bindBlockTexture();
int color = 0;
GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF));
// FIXME 1.17 what is the input range of the shader? 255.0F or 1.0F?
RenderSystem.setShaderColor((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), 1.0F);
RenderSystem.enableBlend();
for (int i = 0; i < width; i += 16) {
@ -114,7 +115,7 @@ public class RenderUtil {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder tes = tessellator.getBuffer();
tes.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
tes.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
tes.vertex(drawX, drawY + drawHeight, 0).texture(minU, minV + (maxV - minV) * drawHeight / 16F).next();
tes.vertex(drawX + drawWidth, drawY + drawHeight, 0)
.texture(minU + (maxU - minU) * drawWidth / 16F, minV + (maxV - minV) * drawHeight / 16F)
@ -127,31 +128,33 @@ public class RenderUtil {
RenderSystem.disableBlend();
}
public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
float f = (float) (startColor >> 24 & 255) / 255.0F;
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
float f3 = (float) (startColor & 255) / 255.0F;
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
float f7 = (float) (endColor & 255) / 255.0F;
public static void drawGradientRect(MatrixStack matrices, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.disableAlphaTest();
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
RenderSystem.shadeModel(7425);
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(7, VertexFormats.POSITION_COLOR);
vertexbuffer.vertex(right, top, 0).color(f1, f2, f3, f).next();
vertexbuffer.vertex(left, top, 0).color(f1, f2, f3, f).next();
vertexbuffer.vertex(left, bottom, 0).color(f5, f6, f7, f4).next();
vertexbuffer.vertex(right, bottom, 0).color(f5, f6, f7, f4).next();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
float f = (startColor >> 24 & 0xFF) / 255.0F;
float g = (startColor >> 16 & 0xFF) / 255.0F;
float h = (startColor >> 8 & 0xFF) / 255.0F;
float i = (startColor & 0xFF) / 255.0F;
float j = (endColor >> 24 & 0xFF) / 255.0F;
float k = (endColor >> 16 & 0xFF) / 255.0F;
float l = (endColor >> 8 & 0xFF) / 255.0F;
float m = (endColor & 0xFF) / 255.0F;
bufferBuilder.vertex(matrices.peek().getModel(), right, top, zLevel).color(g, h, i, f).next();
bufferBuilder.vertex(matrices.peek().getModel(), left, top, zLevel).color(g, h, i, f).next();
bufferBuilder.vertex(matrices.peek().getModel(), left, bottom, zLevel).color(k, l, m, j).next();
bufferBuilder.vertex(matrices.peek().getModel(), right, bottom, zLevel).color(k, l, m, j).next();
tessellator.draw();
RenderSystem.shadeModel(7424);
RenderSystem.disableBlend();
RenderSystem.enableAlphaTest();
RenderSystem.enableTexture();
}

View file

@ -27,6 +27,7 @@ package reborncore.client;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
@ -39,6 +40,7 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import reborncore.RebornCore;
import reborncore.api.IListInfoProvider;
import reborncore.common.BaseBlockEntityProvider;
@ -69,7 +71,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
tooltipLines.add(1, line1);
if (Screen.hasShiftDown()) {
int percentage = percentage(Energy.of(itemStack).getEnergy(), Energy.of(itemStack).getMaxStored());
int percentage = percentage(Energy.of(itemStack).getMaxStored(), Energy.of(itemStack).getEnergy());
MutableText line2 = StringUtils.getPercentageText(percentage);
line2.append(" ");
line2.formatted(Formatting.GRAY);
@ -106,12 +108,12 @@ public class StackToolTipHandler implements ItemTooltipCallback {
else {
try {
if ((block instanceof BaseBlockEntityProvider)) {
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world);
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(BlockPos.ORIGIN, block.getDefaultState());
boolean hasData = false;
if (itemStack.hasTag() && itemStack.getOrCreateTag().contains("blockEntity_data")) {
NbtCompound blockEntityData = itemStack.getOrCreateTag().getCompound("blockEntity_data");
if (blockEntity != null) {
blockEntity.readNbt(block.getDefaultState(), blockEntityData);
blockEntity.readNbt(blockEntityData);
hasData = true;
tooltipLines.add(new LiteralText(I18n.translate("reborncore.tooltip.has_data")).formatted(Formatting.DARK_GREEN));
}

View file

@ -24,15 +24,14 @@
package reborncore.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
import reborncore.common.util.Color;
public class GuiButtonCustomTexture extends ButtonWidget {
@ -69,35 +68,32 @@ public class GuiButtonCustomTexture extends ButtonWidget {
if (this.visible) {
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
&& mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(WIDGETS_TEXTURE);
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
int u = textureU;
int v = textureV;
if (flag) {
u += width;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
matrixStack.push();
RenderSystem.setShaderColor(0f, 0f, 0f, 1f);
this.drawTexture(matrixStack, this.x, this.y, u, v, width, height);
GL11.glPopMatrix();
matrixStack.pop();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826);
DiffuseLighting.enable();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
renderImage(matrixStack, this.x, this.y);
this.drawTextWithShadow(matrixStack, mc.textRenderer, this.name, this.x + 20, this.y + 3,
drawTextWithShadow(matrixStack, mc.textRenderer, this.name, this.x + 20, this.y + 3,
Color.WHITE.getColor());
}
}
public void renderImage(MatrixStack matrixStack, int offsetX, int offsetY) {
TextureManager render = MinecraftClient.getInstance().getTextureManager();
render.bindTexture(new Identifier(imageprefix + this.texturename + ".png"));
RenderSystem.setShaderTexture(0, new Identifier(imageprefix + this.texturename + ".png"));
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
drawTexture(matrixStack, offsetX, offsetY, this.buttonU, this.buttonV, this.textureW, this.textureH);
GL11.glDisable(GL11.GL_BLEND);
RenderSystem.disableBlend();
}
}

View file

@ -24,15 +24,14 @@
package reborncore.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import org.lwjgl.opengl.GL11;
import reborncore.common.util.Color;
public class GuiButtonItemTexture extends ButtonWidget {
@ -59,20 +58,20 @@ public class GuiButtonItemTexture extends ButtonWidget {
MinecraftClient mc = MinecraftClient.getInstance();
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
&& mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(WIDGETS_TEXTURE);
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
int u = textureU;
int v = textureV;
if (flag) {
u += mc.textRenderer.getWidth(this.NAME) + 25;
v += mc.textRenderer.getWidth(this.NAME) + 25;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
matrixStack.push();
RenderSystem.setShaderColor(0f, 0f, 0f, 1f);
this.drawTexture(matrixStack, this.x, this.y, u, v, mc.textRenderer.getWidth(this.NAME) + 25, height);
GL11.glPopMatrix();
matrixStack.pop();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826);
DiffuseLighting.enable();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
//GL11.glEnable(32826); RESCALE_NORMAL_EXT
// DiffuseLighting.enable(); FIXME 1.17
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
itemRenderer.renderGuiItemIcon(itemstack, this.x, this.y);
this.drawTextWithShadow(matrixStack, mc.textRenderer, this.NAME, this.x + 20, this.y + 3,

View file

@ -24,27 +24,28 @@
package reborncore.client.gui;
import net.minecraft.client.util.math.MatrixStack;
import reborncore.client.RenderUtil;
public class GuiUtil {
public static void drawTooltipBox(int x, int y, int w, int h) {
public static void drawTooltipBox(MatrixStack matrices, int x, int y, int w, int h) {
int bg = 0xf0100010;
drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);// center
drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
drawGradientRect(matrices, x + 1, y, w - 1, 1, bg, bg);
drawGradientRect(matrices, x + 1, y + h, w - 1, 1, bg, bg);
drawGradientRect(matrices, x + 1, y + 1, w - 1, h - 1, bg, bg);// center
drawGradientRect(matrices, x, y + 1, 1, h - 1, bg, bg);
drawGradientRect(matrices, x + w, y + 1, 1, h - 1, bg, bg);
int grad1 = 0x505000ff;
int grad2 = 0x5028007F;
drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
drawGradientRect(matrices, x + 1, y + 2, 1, h - 3, grad1, grad2);
drawGradientRect(matrices, x + w - 1, y + 2, 1, h - 3, grad1, grad2);
drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
drawGradientRect(matrices, x + 1, y + 1, w - 1, 1, grad1, grad1);
drawGradientRect(matrices, x + 1, y + h - 1, w - 1, 1, grad2, grad2);
}
public static void drawGradientRect(int x, int y, int w, int h, int colour1, int colour2) {
RenderUtil.drawGradientRect(0, x, y, x + w, y + h, colour1, colour2);
public static void drawGradientRect(MatrixStack matrices, int x, int y, int w, int h, int colour1, int colour2) {
RenderUtil.drawGradientRect(matrices, 0, x, y, x + w, y + h, colour1, colour2);
}
}

View file

@ -30,7 +30,9 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
@ -57,6 +59,8 @@ import reborncore.client.screen.builder.slot.PlayerInventorySlot;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import org.jetbrains.annotations.Nullable;
import reborncore.mixin.client.ScreenAccessor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -135,7 +139,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
public boolean upgrades;
public GuiBase(PlayerEntity player, BlockEntity blockEntity, T screenHandler) {
super(screenHandler, player.inventory, new LiteralText(I18n.translate(blockEntity.getCachedState().getBlock().getTranslationKey())));
super(screenHandler, player.getInventory(), new LiteralText(I18n.translate(blockEntity.getCachedState().getBlock().getTranslationKey())));
this.be = blockEntity;
this.builtScreenHandler = (BuiltScreenHandler) screenHandler;
selectedTab = null;
@ -201,7 +205,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
@Override
protected void drawBackground(MatrixStack matrixStack, float lastFrameDuration, int mouseX, int mouseY) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
renderBackground(matrixStack);
boolean drawPlayerSlots = selectedTab == null && drawPlayerSlots();
updateSlotDraw(drawPlayerSlots);
@ -277,12 +281,16 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
offset += 24;
}
for (ClickableWidget abstractButtonWidget : buttons) {
if (abstractButtonWidget.isHovered()) {
abstractButtonWidget.renderToolTip(matrixStack, mouseX, mouseY);
ScreenAccessor screenAccessor = (ScreenAccessor)this;
for (Selectable selectable : screenAccessor.getSelectables()) {
if (selectable instanceof ClickableWidget clickable) {
if (clickable.isHovered()) {
clickable.renderToolTip(matrixStack, mouseX, mouseY);
break;
}
}
}
super.drawMouseoverTooltip(matrixStack, mouseX, mouseY);
}
@ -306,13 +314,13 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
factorY = this.y;
}
getTextRenderer().draw(matrixStack, text, x + factorX, y + factorY, colour);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}
public GuiButtonHologram addHologramButton(int x, int y, int id, Layer layer) {
GuiButtonHologram buttonHologram = new GuiButtonHologram(x + this.x, y + this.y, this, layer, var1 -> {
});
addButton(buttonHologram);
addSelectableChild(buttonHologram);
return buttonHologram;
}

View file

@ -58,7 +58,7 @@ public class RedstoneConfigGui {
boolean hovered = withinBounds(guiBase, mouseX, mouseY, x + 92, y + (i * spread) - 2, 63, 15);
int color = hovered ? 0xFF8b8b8b : 0x668b8b8b;
RenderUtil.drawGradientRect(0, x + 91, y + (i * spread) - 2, x + 93 + 65, y + (i * spread) + 10, color, color);
RenderUtil.drawGradientRect(matrixStack, 0, x + 91, y + (i * spread) - 2, x + 93 + 65, y + (i * spread) + 10, color, color);
Text name = new TranslatableText("reborncore.gui.fluidconfig." + configuration.getState(element).name().toLowerCase(Locale.ROOT));
guiBase.drawCentredText(matrixStack, name, y + (i * spread), -1, x + 37, GuiBase.Layer.FOREGROUND);

View file

@ -81,10 +81,10 @@ public class SlotConfigGui {
if (guiBase.be != slot.inventory) {
continue;
}
RenderSystem.color3f(255, 0, 0);
RenderSystem.setShaderColor(1.0F, 0, 0, 1.0F);
Color color = new Color(255, 0, 0, 128);
GuiUtil.drawGradientRect(slot.x - 1, slot.y - 1, 18, 18, color.getColor(), color.getColor());
RenderSystem.color3f(255, 255, 255);
GuiUtil.drawGradientRect(matrixStack, slot.x - 1, slot.y - 1, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
if (selectedSlot != -1) {

View file

@ -118,7 +118,6 @@ public class ConfigSlotElement extends ElementBase {
renderItem.renderInGuiWithOverrides(stack, xPos, yPos);
renderItem.renderGuiItemOverlay(gui.getTextRenderer(), stack, xPos, yPos, null);
RenderSystem.disableDepthTest();
RenderSystem.disableLighting();
matrixStack.pop();
if (isHovering) {
drawSprite(matrixStack, gui, type.getButtonHoverOverlay(), x, y);

View file

@ -263,14 +263,14 @@ public class ElementBase {
void update(GuiBase<?> gui, ElementBase element);
}
public void drawRect(GuiBase<?> gui, int x, int y, int width, int height, int colour) {
drawGradientRect(gui, x, y, width, height, colour, colour);
public void drawRect(MatrixStack matrices, GuiBase<?> gui, int x, int y, int width, int height, int colour) {
drawGradientRect(matrices, gui, x, y, width, height, colour, colour);
}
/*
Taken from Gui
*/
public void drawGradientRect(GuiBase<?> gui, int x, int y, int width, int height, int startColor, int endColor) {
public void drawGradientRect(MatrixStack matrices, GuiBase<?> gui, int x, int y, int width, int height, int startColor, int endColor) {
x = adjustX(gui, x);
y = adjustY(gui, y);
@ -279,7 +279,7 @@ public class ElementBase {
int right = x + width;
int bottom = y + height;
RenderUtil.drawGradientRect(0, left, top, right, bottom, startColor, endColor);
RenderUtil.drawGradientRect(matrices, 0, left, top, right, bottom, startColor, endColor);
}
public int adjustX(GuiBase<?> gui, int x) {
@ -301,27 +301,26 @@ public class ElementBase {
}
public void setTextureSheet(Identifier textureLocation) {
MinecraftClient.getInstance().getTextureManager().bindTexture(textureLocation);
RenderSystem.setShaderTexture(0, textureLocation);
}
public void drawSprite(MatrixStack matrixStack, GuiBase<?> gui, ISprite iSprite, int x, int y) {
Sprite sprite = iSprite.getSprite(gui.getMachine());
if (sprite != null) {
if (sprite.hasTextureInfo()) {
RenderSystem.color3f(1F, 1F, 1F);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
setTextureSheet(sprite.textureLocation);
gui.drawTexture(matrixStack, x + gui.getGuiLeft(), y + gui.getGuiTop(), sprite.x, sprite.y, sprite.width, sprite.height);
}
if (sprite.hasStack()) {
RenderSystem.pushMatrix();
matrixStack.push();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
itemRenderer.renderInGuiWithOverrides(sprite.itemStack, x + gui.getGuiLeft(), y + gui.getGuiTop());
RenderSystem.disableLighting();
RenderSystem.popMatrix();
matrixStack.pop();
}
}
}
@ -338,8 +337,8 @@ public class ElementBase {
}
public void drawDefaultBackground(MatrixStack matrixStack, Screen gui, int x, int y, int width, int height) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
gui.drawTexture(matrixStack, x, y, 0, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);

View file

@ -83,12 +83,12 @@ public class FluidConfigPopupElement extends ElementBase {
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
drawSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui);
drawSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), 22, 37, gui);
drawSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), 41, 18, gui);
drawSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), 41, 37, gui);
drawSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), 3, 18, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), 22, 37, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), 41, 18, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.BACK.getFacing(machine), 41, 37, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), 3, 18, gui);
}
@Override
@ -143,7 +143,7 @@ public class FluidConfigPopupElement extends ElementBase {
return super.onHover(provider, gui, mouseX, mouseY);
}
private void drawSateColor(MachineBaseBlockEntity machineBase, Direction side, int inx, int iny, GuiBase<?> gui) {
private void drawSateColor(MatrixStack matrices, MachineBaseBlockEntity machineBase, Direction side, int inx, int iny, GuiBase<?> gui) {
iny += 4;
int sx = inx + getX() + gui.getGuiLeft();
int sy = iny + getY() + gui.getGuiTop();
@ -171,9 +171,9 @@ public class FluidConfigPopupElement extends ElementBase {
color = new Color(0, 0, 0, 0);
break;
}
RenderSystem.color3f(255, 255, 255);
GuiUtil.drawGradientRect(sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.color3f(255, 255, 255);
RenderSystem.setShaderColor(1, 1, 1, 1);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1, 1, 1, 1);
}
private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, double pointX, double pointY, GuiBase<?> guiBase) {

View file

@ -87,12 +87,12 @@ public class SlotConfigPopupElement extends ElementBase {
drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, Vec3f.POSITIVE_Y.getDegreesQuaternion(90F)); //right
drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, Vec3f.POSITIVE_Y.getDegreesQuaternion(180F)); //back
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
}
@Override
@ -149,7 +149,7 @@ public class SlotConfigPopupElement extends ElementBase {
NetworkManager.sendToServer(packetSlotSave);
}
private void drawSlotSateColor(MachineBaseBlockEntity machineBase, Direction side, int slotID, int inx, int iny, GuiBase<?> gui) {
private void drawSlotSateColor(MatrixStack matrices, MachineBaseBlockEntity machineBase, Direction side, int slotID, int inx, int iny, GuiBase<?> gui) {
iny += 4;
int sx = inx + getX() + gui.getGuiLeft();
int sy = iny + getY() + gui.getGuiTop();
@ -161,9 +161,6 @@ public class SlotConfigPopupElement extends ElementBase {
SlotConfiguration.SlotConfig slotConfig = slotConfigHolder.getSideDetail(side);
Color color;
switch (slotConfig.getSlotIO().getIoConfig()) {
case NONE:
color = new Color(0, 0, 0, 0);
break;
case INPUT:
color = new Color(0, 0, 255, 128);
break;
@ -174,9 +171,9 @@ public class SlotConfigPopupElement extends ElementBase {
color = new Color(0, 0, 0, 0);
break;
}
RenderSystem.color3f(255, 255, 255);
GuiUtil.drawGradientRect(sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.color3f(255, 255, 255);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}

View file

@ -24,6 +24,7 @@
package reborncore.client.gui.builder.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
@ -46,7 +47,7 @@ public class GuiButtonUpDown extends GuiButtonExtended {
@Override
public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (gui.hideGuiElements()) return;
gui.getMinecraft().getTextureManager().bindTexture(gui.builder.getResourceLocation());
RenderSystem.setShaderTexture(0, gui.builder.getResourceLocation());
switch (type) {
case FASTFORWARD:
gui.drawTexture(matrixStack, x, y, 174, 74, 12, 12);

View file

@ -24,13 +24,13 @@
package reborncore.client.gui.componets;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import org.lwjgl.opengl.GL11;
public class GuiHiddenButton extends ButtonWidget {
@ -48,13 +48,13 @@ public class GuiHiddenButton extends ButtonWidget {
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
TextRenderer fontrenderer = MinecraftClient.getInstance().textRenderer;
MinecraftClient.getInstance().getTextureManager().bindTexture(WIDGETS_TEXTURE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height;
GL11.glEnable(GL11.GL_BLEND);
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
int l = 14737632;
if (!this.active) {

View file

@ -31,9 +31,11 @@ import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
@ -81,8 +83,8 @@ public class GuiBuilder {
}
public void drawDefaultBackground(MatrixStack matrixStack, Screen gui, int x, int y, int width, int height) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
MinecraftClient.getInstance().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 0, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
@ -91,7 +93,7 @@ public class GuiBuilder {
}
public void drawPlayerSlots(MatrixStack matrixStack, Screen gui, int posX, int posY, boolean center) {
MinecraftClient.getInstance().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
if (center) {
posX -= 81;
@ -109,7 +111,7 @@ public class GuiBuilder {
}
public void drawSlot(MatrixStack matrixStack, Screen gui, int posX, int posY) {
MinecraftClient.getInstance().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, posX, posY, 150, 0, 18, 18);
}
@ -118,7 +120,7 @@ public class GuiBuilder {
}
public void drawProgressBar(MatrixStack matrixStack, GuiBase<?> gui, double progress, int x, int y) {
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 18, 22, 15);
int j = (int) (progress);
if (j > 0) {
@ -127,7 +129,7 @@ public class GuiBuilder {
}
public void drawOutputSlot(MatrixStack matrixStack, GuiBase<?> gui, int x, int y) {
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 174, 0, 26, 26);
}
@ -146,7 +148,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 202, 0, 12, 12);
}
}
@ -168,7 +170,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 174, 26 + (locked ? 12 : 0), 20, 12);
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
@ -177,9 +179,9 @@ public class GuiBuilder {
} else {
list.add(new TranslatableText("reborncore.gui.tooltip.lock_items"));
}
RenderSystem.pushMatrix();
matrixStack.push();
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.popMatrix();
matrixStack.pop();
}
}
@ -199,7 +201,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
if (gui.getMachine().renderMultiblock) {
gui.drawTexture(matrixStack, x, y, 174, 62, 20, 12);
} else {
@ -208,13 +210,13 @@ public class GuiBuilder {
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
list.add(new TranslatableText("reborncore.gui.tooltip.hologram"));
RenderSystem.pushMatrix();
matrixStack.push();
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.popMatrix();
matrixStack.pop();
}
}
@ -234,7 +236,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 26, 218, 114, 18);
if (value != 0) {
int j = (int) ((double) value / (double) max * 106);
@ -271,7 +273,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
int j = (int) ((double) value / (double) max * 106);
if (j < 0) {
j = 0;
@ -324,8 +326,8 @@ public class GuiBuilder {
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.disableLighting();
RenderSystem.color4f(1, 1, 1, 1);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
@ -352,12 +354,12 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
RenderSystem.disableLighting();
//RenderSystem.disableLighting();
RenderSystem.enableDepthTest();
RenderSystem.colorMask(true, true, true, false);
RenderUtil.drawGradientRect(0, x, y, x + 176, y + 20, 0x000000, 0xC0000000);
RenderUtil.drawGradientRect(0, x, y + 20, x + 176, y + 20 + 48, 0xC0000000, 0xC0000000);
RenderUtil.drawGradientRect(0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
RenderUtil.drawGradientRect(matrixStack, 0, x, y, x + 176, y + 20, 0x000000, 0xC0000000);
RenderUtil.drawGradientRect(matrixStack, 0, x, y + 20, x + 176, y + 20 + 48, 0xC0000000, 0xC0000000);
RenderUtil.drawGradientRect(matrixStack, 0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
RenderSystem.colorMask(true, true, true, true);
RenderSystem.disableDepthTest();
gui.drawCentredText(matrixStack, new TranslatableText("reborncore.gui.missingmultiblock"), 43, 0xFFFFFF, layer);
@ -372,7 +374,7 @@ public class GuiBuilder {
* @param y int Top left corner where to place slots
*/
public void drawUpgrades(MatrixStack matrixStack, GuiBase<?> gui, int x, int y) {
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 217, 0, 24, 81);
}
@ -385,7 +387,7 @@ public class GuiBuilder {
* @param stack ItemStack Item to show as tab icon
*/
public void drawSlotTab(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, ItemStack stack) {
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 217, 82, 24, 24);
gui.getMinecraft().getItemRenderer().renderInGuiWithOverrides(stack, x + 5, y + 4);
}
@ -408,7 +410,7 @@ public class GuiBuilder {
TipsListWidget explanation = new TipsListWidget(gui, gui.getScreenWidth() - 14, 54, y, y + 76, 9 + 2, tips);
explanation.setLeftPos(x - 81);
explanation.render(matrixStack, mouseX, mouseY, 1.0f);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -435,9 +437,9 @@ public class GuiBuilder {
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
this.client.getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
RenderSystem.setShaderTexture(0, DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
bufferBuilder.vertex(this.left, this.bottom, 0.0D).texture((float) this.left / 32.0F, (float) (this.bottom + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).next();
bufferBuilder.vertex(this.right, this.bottom, 0.0D).texture((float) this.right / 32.0F, (float) (this.bottom + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).next();
bufferBuilder.vertex(this.right, this.top, 0.0D).texture((float) this.right / 32.0F, (float) (this.top + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).next();
@ -447,6 +449,11 @@ public class GuiBuilder {
super.renderList(matrices, this.getRowLeft(), this.top, mouseX, mouseY, delta);
}
@Override
public void appendNarrations(NarrationMessageBuilder builder) {
}
private class TipsListEntry extends EntryListWidget.Entry<TipsListWidget.TipsListEntry> {
private final Text tip;
@ -484,7 +491,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 91, 16, 16);
}
@ -508,7 +515,7 @@ public class GuiBuilder {
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, direction.x, direction.y, direction.width, direction.height);
int j = (int) ((double) progress / (double) maxProgress * 16);
if (j < 0) {
@ -545,8 +552,8 @@ public class GuiBuilder {
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.disableLighting();
RenderSystem.color4f(1, 1, 1, 1);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
@ -572,7 +579,7 @@ public class GuiBuilder {
}
EnergySystem displayPower = PowerSystem.getDisplayPower();
MinecraftClient.getInstance().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, displayPower.xBar - 15, displayPower.yBar - 1, 14, 50);
int draw = (int) ((double) energyStored / (double) maxEnergyStored * (48));
if (energyStored > maxEnergyStored) {
@ -626,8 +633,8 @@ public class GuiBuilder {
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.disableLighting();
RenderSystem.color4f(1, 1, 1, 1);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
@ -657,7 +664,7 @@ public class GuiBuilder {
amount = fluid.getAmount();
percentage = percentage(maxCapacity.getRawValue(), amount.getRawValue());
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 194, 26, 22, 56);
if (!isTankEmpty) {
drawFluid(matrixStack, gui, fluid, x + 4, y + 4, 14, 48, maxCapacity.getRawValue());
@ -689,8 +696,8 @@ public class GuiBuilder {
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.disableLighting();
RenderSystem.color4f(1, 1, 1, 1);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
@ -709,7 +716,7 @@ public class GuiBuilder {
if (fluid.getFluid() == Fluids.EMPTY) {
return;
}
gui.getMinecraft().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
RenderSystem.setShaderTexture(0, SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
y += height;
final Sprite sprite = FluidRenderHandlerRegistry.INSTANCE.get(fluid.getFluid()).getFluidSprites(gui.getMachine().getWorld(), gui.getMachine().getPos(), fluid.getFluid().getDefaultState())[0];
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid.getFluid()).getFluidColor(gui.getMachine().getWorld(), gui.getMachine().getPos(), fluid.getFluid().getDefaultState());
@ -718,7 +725,7 @@ public class GuiBuilder {
final int iconHeight = sprite.getHeight();
int offsetHeight = drawHeight;
RenderSystem.color3f((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F);
RenderSystem.setShaderColor((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F, 1F);
int iteration = 0;
while (offsetHeight != 0) {
@ -731,9 +738,9 @@ public class GuiBuilder {
break;
}
}
RenderSystem.color3f(1F, 1F, 1F);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
}
/**
@ -754,7 +761,7 @@ public class GuiBuilder {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.getMinecraft().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 64, 13, 13);
int j = 13 - (int) ((double) progress / (double) maxProgress * 13);
if (j > 0) {
@ -770,8 +777,8 @@ public class GuiBuilder {
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.disableLighting();
RenderSystem.color4f(1, 1, 1, 1);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
@ -784,7 +791,7 @@ public class GuiBuilder {
* @param count int Number of output slots
*/
public void drawOutputSlotBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int count) {
MinecraftClient.getInstance().getTextureManager().bindTexture(resourceLocation);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 122, 3, 26);
x += 3;
for (int i = 1; i <= count; i++) {

View file

@ -24,17 +24,19 @@
package reborncore.client.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blockentity.MultiblockWriter;
public class MultiblockRenderer<T extends MachineBaseBlockEntity> extends BlockEntityRenderer<T> {
public class MultiblockRenderer<T extends MachineBaseBlockEntity> implements BlockEntityRenderer<T> {
public MultiblockRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
public MultiblockRenderer(BlockEntityRendererFactory.Context ctx) {
}
@Override

View file

@ -1,96 +0,0 @@
/*
* This file is part of RebornCore, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 TeamReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package reborncore.client.texture;
import net.minecraft.client.texture.AbstractTexture;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.TextureUtil;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.metadata.ResourceMetadataReader;
import net.minecraft.util.Identifier;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
/**
* Created by modmuss50 on 23/05/2016.
*/
public class InputStreamTexture extends AbstractTexture {
protected final InputStream textureLocation;
NativeImage image;
String name;
public InputStreamTexture(InputStream textureResourceLocation, String name) {
this.textureLocation = textureResourceLocation;
this.name = name;
}
@Override
public void load(ResourceManager resourceManager) throws IOException {
this.clearGlId();
if (image == null) {
Resource iresource = null;
try {
iresource = new Resource() {
@Override
public Identifier getId() {
return new Identifier("reborncore:loaded/" + name);
}
@Override
public InputStream getInputStream() {
return textureLocation;
}
@Nullable
@Override
public <T> T getMetadata(ResourceMetadataReader<T> iMetadataSectionSerializer) {
return null;
}
@Override
public String getResourcePackName() {
return "reborncore";
}
@Override
public void close() {
}
};
image = NativeImage.read(iresource.getInputStream());
} finally {
IOUtils.closeQuietly(iresource);
}
}
this.bindTexture();
TextureUtil.allocate(this.getGlId(), 0, image.getWidth(), image.getHeight());
image.upload(0, 0, 0, true);
}
}

View file

@ -27,7 +27,10 @@ package reborncore.common;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
@ -63,11 +66,19 @@ public abstract class BaseBlockEntityProvider extends Block implements BlockEnti
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
NbtCompound nbt = stack.getTag().getCompound("blockEntity_data");
injectLocationData(nbt, pos);
blockEntity.readNbt(state, nbt);
blockEntity.readNbt(nbt);
blockEntity.markDirty();
}
}
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return (world1, pos, state1, blockEntity) -> {
if (blockEntity instanceof BlockEntityTicker) {
((BlockEntityTicker) blockEntity).tick(world1, pos, state1, blockEntity);
}
};
}
private void stripLocationData(NbtCompound compound) {
compound.remove("x");
compound.remove("y");

View file

@ -159,7 +159,7 @@ public class RebornCoreCommands {
private static int flySpeed(CommandContext<ServerCommandSource> ctx, Collection<ServerPlayerEntity> players) {
final int speed = getInteger(ctx, "speed");
players.stream()
.peek(player -> player.abilities.setFlySpeed(speed / 20F))
.peek(player -> player.getAbilities().setFlySpeed(speed / 20F))
.forEach(ServerPlayerEntity::sendAbilitiesUpdate);
return Command.SINGLE_SUCCESS;
@ -187,7 +187,7 @@ public class RebornCoreCommands {
private static int handRenderer(CommandContext<ServerCommandSource> ctx) {
try {
queueRender(Collections.singletonList(ctx.getSource().getPlayer().inventory.getMainHandStack()));
queueRender(Collections.singletonList(ctx.getSource().getPlayer().getInventory().getMainHandStack()));
} catch (CommandSyntaxException e) {
e.printStackTrace();
return 0;

View file

@ -41,7 +41,7 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Formatting;
import net.minecraft.util.Tickable;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@ -69,7 +69,7 @@ import java.util.Optional;
/**
* Created by modmuss50 on 04/11/2016.
*/
public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUpgradeable, IUpgradeHandler, IListInfoProvider, Inventory, SidedInventory {
public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTicker<MachineBaseBlockEntity>, IUpgradeable, IUpgradeHandler, IListInfoProvider, Inventory, SidedInventory {
public RebornInventory<MachineBaseBlockEntity> upgradeInventory = new RebornInventory<>(getUpgradeSlotCount(), "upgrades", 1, this, (slotID, stack, face, direction, blockEntity) -> true);
private SlotConfiguration slotConfiguration;
@ -94,8 +94,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
*/
double powerMultiplier = 1;
public MachineBaseBlockEntity(BlockEntityType<?> blockEntityTypeIn) {
super(blockEntityTypeIn);
public MachineBaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
redstoneConfiguration = new RedstoneConfiguration(this);
}
@ -140,7 +140,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
}
@Override
public void tick() {
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (ticktime == 0) {
onLoad();
}
@ -232,8 +232,8 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
}
@Override
public void readNbt(BlockState blockState, NbtCompound tagCompound) {
super.readNbt(blockState, tagCompound);
public void readNbt(NbtCompound tagCompound) {
super.readNbt(tagCompound);
if (getOptionalInventory().isPresent()) {
getOptionalInventory().get().read(tagCompound);
}
@ -306,11 +306,6 @@ public class MachineBaseBlockEntity extends BlockEntity implements Tickable, IUp
return getFacingEnum();
}
@Override
public void applyRotation(BlockRotation rotationIn) {
setFacing(rotationIn.rotate(getFacing()));
}
@Override
public void resetSpeedMulti() {
speedMultiplier = 0;

View file

@ -272,7 +272,7 @@ public interface MultiblockWriter {
if (state.getBlock() instanceof FluidBlock) {
FluidState fluidState = ((FluidBlock) state.getBlock()).getFluidState(state);
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(fluidState.getFluid().getBucketItem()), ModelTransformation.Mode.FIXED, 15728880, OverlayTexture.DEFAULT_UV, matrix, vertexConsumerProvider);
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(fluidState.getFluid().getBucketItem()), ModelTransformation.Mode.FIXED, 15728880, OverlayTexture.DEFAULT_UV, matrix, vertexConsumerProvider, 0);
} else {
matrix.translate(-0.5, -0.5, -0.5);
VertexConsumer consumer = vertexConsumerProvider.getBuffer(RenderLayers.getBlockLayer(state));

View file

@ -127,7 +127,7 @@ public abstract class BlockMachineBase extends BaseBlockEntityProvider implement
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return null;
}

View file

@ -39,6 +39,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.PersistentState;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
@ -57,25 +58,27 @@ public class ChunkLoaderManager extends PersistentState {
private static final String KEY = "reborncore_chunk_loader";
public ChunkLoaderManager() {
super(KEY);
}
public static ChunkLoaderManager get(World world) {
ServerWorld serverWorld = (ServerWorld) world;
return serverWorld.getPersistentStateManager().getOrCreate(ChunkLoaderManager::new, KEY);
return serverWorld.getPersistentStateManager().getOrCreate(ChunkLoaderManager::fromTag, ChunkLoaderManager::new, KEY);
}
private final List<LoadedChunk> loadedChunks = new ArrayList<>();
@Override
public void fromNbt(NbtCompound tag) {
loadedChunks.clear();
public static ChunkLoaderManager fromTag(NbtCompound tag) {
ChunkLoaderManager chunkLoaderManager = new ChunkLoaderManager();
chunkLoaderManager.loadedChunks.clear();
List<LoadedChunk> chunks = CODEC.parse(NbtOps.INSTANCE, tag.getCompound("loadedchunks"))
.result()
.orElse(Collections.emptyList());
loadedChunks.addAll(chunks);
chunkLoaderManager.loadedChunks.addAll(chunks);
return chunkLoaderManager;
}
@Override

View file

@ -26,15 +26,20 @@ package reborncore.common.crafting.ingredient;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import net.minecraft.client.MinecraftClient;
import net.minecraft.data.server.ItemTagsProvider;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.tag.RequiredTagList;
import net.minecraft.tag.RequiredTagListRegistry;
import net.minecraft.tag.ServerTagManagerHolder;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import org.apache.commons.lang3.Validate;
import java.util.ArrayList;
@ -60,7 +65,7 @@ public class TagIngredient extends RebornIngredient {
if (count.isPresent() && count.get() > itemStack.getCount()) {
return false;
}
return itemStack.getItem().isIn(tag);
return tag.contains(itemStack.getItem());
}
@Override
@ -92,7 +97,8 @@ public class TagIngredient extends RebornIngredient {
}
Identifier identifier = new Identifier(JsonHelper.getString(json, "tag"));
Tag<Item> tag = ServerTagManagerHolder.getTagManager().getItems().getTag(identifier);
Tag<Item> tag = ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY).getTag(identifier);
if (tag == null) {
throw new JsonSyntaxException("Unknown item tag '" + identifier + "'");
}

View file

@ -43,8 +43,8 @@ import java.util.Set;
public abstract class IMultiblockPart extends BlockEntity {
public static final int INVALID_DISTANCE = Integer.MAX_VALUE;
public IMultiblockPart(BlockEntityType<?> blockEntityTypeIn) {
super(blockEntityTypeIn);
public IMultiblockPart(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
/**

View file

@ -29,7 +29,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.util.Tickable;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import reborncore.RebornCore;
@ -45,7 +45,7 @@ import java.util.Set;
* machines should derive from this and implement their game logic in certain
* abstract methods.
*/
public abstract class MultiblockBlockEntityBase extends IMultiblockPart implements Tickable, UnloadHandler {
public abstract class MultiblockBlockEntityBase extends IMultiblockPart implements BlockEntityTicker, UnloadHandler {
private MultiblockControllerBase controller;
private boolean visited;
@ -53,8 +53,8 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
private NbtCompound cachedMultiblockData;
//private boolean paused;
public MultiblockBlockEntityBase(BlockEntityType<?> tBlockEntityType) {
super(tBlockEntityType);
public MultiblockBlockEntityBase(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
controller = null;
visited = false;
saveMultiblockData = false;
@ -112,8 +112,8 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
// /// Overrides from base BlockEntity methods
@Override
public void readNbt(BlockState blockState, NbtCompound data) {
super.readNbt(blockState, data);
public void readNbt(NbtCompound data) {
super.readNbt(data);
// We can't directly initialize a multiblock controller yet, so we cache
// the data here until
@ -332,7 +332,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
@Override
public void onOrphaned(MultiblockControllerBase controller, int oldSize, int newSize) {
this.markDirty();
getWorld().markDirty(getPos(), this);
getWorld().markDirty(getPos());
}
// // Helper functions for notifying neighboring blocks

View file

@ -1072,8 +1072,7 @@ public abstract class MultiblockControllerBase {
return;
}
BlockEntity saveTe = worldObj.getBlockEntity(referenceCoord);
worldObj.markDirty(referenceCoord, saveTe);
worldObj.markDirty(referenceCoord);
}
}

View file

@ -24,6 +24,7 @@
package reborncore.common.multiblock.rectangular;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -36,8 +37,8 @@ public abstract class RectangularMultiblockBlockEntityBase extends MultiblockBlo
PartPosition position;
Direction outwards;
public RectangularMultiblockBlockEntityBase(BlockEntityType<?> blockEntityType) {
super(blockEntityType);
public RectangularMultiblockBlockEntityBase(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
position = PartPosition.Unknown;
outwards = null;

View file

@ -57,7 +57,7 @@ public class ClientBoundPacketHandlers {
if (world.isChunkLoaded(pos)) {
BlockEntity blockentity = world.getBlockEntity(pos);
if (blockentity != null && tagCompound != null) {
blockentity.readNbt(blockentity.getCachedState(), tagCompound);
blockentity.readNbt(tagCompound);
}
}
});

View file

@ -32,8 +32,10 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IListInfoProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
@ -58,8 +60,8 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
public double powerLastTick;
public boolean checkOverfill = true; // Set to false to disable the overfill check.
public PowerAcceptorBlockEntity(BlockEntityType<?> blockEntityType) {
super(blockEntityType);
public PowerAcceptorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
checkTier();
}
@ -302,8 +304,8 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
// MachineBaseBlockEntity
@Override
public void tick() {
super.tick();
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity2) {
super.tick(world, pos, state, blockEntity2);
if (world == null || world.isClient) {
return;
}
@ -330,8 +332,8 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
}
@Override
public void readNbt(BlockState blockState, NbtCompound tag) {
super.readNbt(blockState, tag);
public void readNbt(NbtCompound tag) {
super.readNbt(tag);
NbtCompound data = tag.getCompound("PowerAcceptor");
if (shouldHandleEnergyNBT()) {
this.setStored(data.getDouble("energy"));

View file

@ -222,8 +222,8 @@ public class ItemUtils {
return;
}
for (int i = 0; i < player.inventory.size(); i++) {
ItemStack invStack = player.inventory.getStack(i);
for (int i = 0; i < player.getInventory().size(); i++) {
ItemStack invStack = player.getInventory().getStack(i);
if (invStack.isEmpty() || !filter.test(invStack)) {
continue;

View file

@ -41,8 +41,8 @@ public class TorchHelper {
return ActionResult.FAIL;
}
for (int i = 0; i < player.inventory.main.size(); i++) {
ItemStack torchStack = player.inventory.getStack(i);
for (int i = 0; i < player.getInventory().main.size(); i++) {
ItemStack torchStack = player.getInventory().getStack(i);
if (torchStack.isEmpty() || !torchStack.getTranslationKey().toLowerCase(Locale.ROOT).contains("torch")) {
continue;
}
@ -56,7 +56,7 @@ public class TorchHelper {
if (player.isCreative()) {
torchStack.setCount(oldSize);
} else if (torchStack.getCount() <= 0) {
player.inventory.setStack(i, ItemStack.EMPTY);
player.getInventory().setStack(i, ItemStack.EMPTY);
}
if (result == ActionResult.SUCCESS) {
return ActionResult.SUCCESS;

View file

@ -24,8 +24,8 @@
package reborncore.mixin.client;
import net.minecraft.client.item.ModelPredicateProvider;
import net.minecraft.client.item.ModelPredicateProviderRegistry;
import net.minecraft.client.item.UnclampedModelPredicateProvider;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
@ -34,7 +34,7 @@ import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(ModelPredicateProviderRegistry.class)
public interface AccessorModelPredicateProviderRegistry {
@Invoker
static void callRegister(Item item, Identifier id, ModelPredicateProvider provider) {
static void callRegister(Item item, Identifier id, UnclampedModelPredicateProvider provider) {
throw new RuntimeException("nope");
}
}

View file

@ -55,7 +55,7 @@ public abstract class MixinItemRenderer {
}
RenderSystem.disableDepthTest();
RenderSystem.disableTexture();
RenderSystem.disableAlphaTest();
//RenderSystem.disableAlphaTest(); FIXME 1.17
RenderSystem.disableBlend();
Tessellator tessellator = Tessellator.getInstance();
@ -68,7 +68,7 @@ public abstract class MixinItemRenderer {
this.renderGuiQuad(bufferBuilder, x + 2, y + 13, durability, 1, color >> 16 & 255, color >> 8 & 255, color & 255, 255);
RenderSystem.enableBlend();
RenderSystem.enableAlphaTest();
//RenderSystem.enableAlphaTest();
RenderSystem.enableTexture();
RenderSystem.enableDepthTest();
}

View file

@ -0,0 +1,14 @@
package reborncore.mixin.client;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
@Mixin(Screen.class)
public interface ScreenAccessor {
@Accessor
List<Selectable> getSelectables();
}

View file

@ -49,9 +49,9 @@ public abstract class MixinItemEntity extends Entity {
@Inject(method = "tick", at = @At("RETURN"))
public void tick(CallbackInfo info) {
if (!world.isClient && isTouchingWater() && !getStack().isEmpty()) {
if (getStack().getItem().isIn(RebornCoreTags.WATER_EXPLOSION_ITEM)) {
if (RebornCoreTags.WATER_EXPLOSION_ITEM.contains(getStack().getItem())) {
world.createExplosion(this, getX(), getY(), getZ(), 2F, Explosion.DestructionType.BREAK);
this.remove();
this.remove(RemovalReason.KILLED);
}
}
}

View file

@ -36,7 +36,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorTickable;
import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.common.util.ItemUtils;
@Mixin(PlayerEntity.class)
@ -64,8 +64,8 @@ public abstract class MixinPlayerEntity extends LivingEntity {
}
i++;
if (!stack.isEmpty() && stack.getItem() instanceof ArmorTickable) {
((ArmorTickable) stack.getItem()).tickArmor(stack, (PlayerEntity) (Object) this);
if (!stack.isEmpty() && stack.getItem() instanceof ArmorBlockEntityTicker) {
((ArmorBlockEntityTicker) stack.getItem()).tickArmor(stack, (PlayerEntity) (Object) this);
}
}
}

View file

@ -1,7 +1,7 @@
{
"required": true,
"package": "reborncore.mixin.client",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_8",
"client": [
"MixinGameRenderer",
"MixinItemRenderer",

View file

@ -1,7 +1,7 @@
{
"required": true,
"package": "reborncore.mixin.common",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_8",
"mixins": [
"AccessorFluidBlock",
"AccessorFoliagePlacerType",