Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing up BigDoors in Malisis doors also adding some framework to add more multiblock doors if we want. #16

Merged
merged 14 commits into from
Sep 25, 2024
Merged
13 changes: 12 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ accessTransformersFile = malisisdoors_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false

# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false

Expand Down Expand Up @@ -117,9 +122,15 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
}


8 changes: 7 additions & 1 deletion src/main/java/net/malisis/core/block/MalisisBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
}

@Override
public AxisAlignedBB[] getBoundingBox(IBlockAccess world, int x, int y, int z, BoundingBoxType type) {
return new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ) };
}
Expand All @@ -85,9 +84,16 @@ public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAligne

@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 src, Vec3 dest) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return new RaytraceBlock(world, src, dest, x, y, z).trace();
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z) {
this.setBlockBoundsBasedOnState(worldIn, x, y, z);
return super.getCollisionBoundingBoxFromPool(worldIn, x, y, z);
}

@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
AxisAlignedBB[] aabbs = getBoundingBox(world, x, y, z, BoundingBoxType.SELECTION);
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/net/malisis/core/client/gui/GuiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
Expand Down Expand Up @@ -294,9 +295,9 @@ public void drawRectangle(float x, float y, float z, float width, float height,
*/
public void drawTooltip(UITooltip tooltip) {
if (tooltip != null) {
t.startDrawingQuads();
this.tessellator.startDrawingQuads();
tooltip.draw(this, mouseX, mouseY, partialTick);
t.draw();
this.tessellator.draw();
}
}

Expand Down Expand Up @@ -445,7 +446,7 @@ public void drawItemStack(ItemStack itemStack, int x, int y, String label, EnumC
if (label == null) label = "";
if (format != null) label = format + label;

t.draw();
this.tessellator.draw();
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);

Expand All @@ -471,7 +472,7 @@ public void drawItemStack(ItemStack itemStack, int x, int y, String label, EnumC

currentTexture = null;
bindDefaultTexture();
t.startDrawingQuads();
this.tessellator.startDrawingQuads();
}

/**
Expand All @@ -481,17 +482,17 @@ public void drawItemStack(ItemStack itemStack, int x, int y, String label, EnumC
*/
public void renderPickedItemStack(ItemStack itemStack) {
if (itemStack == null) return;

this.tessellator = Tessellator.instance;
itemRenderer.zLevel = 100;
t.startDrawingQuads();
this.tessellator.startDrawingQuads();
drawItemStack(
itemStack,
mouseX - 8,
mouseY - 8,
null,
itemStack.stackSize == 0 ? EnumChatFormatting.YELLOW : null,
false);
t.draw();
this.tessellator.draw();
itemRenderer.zLevel = 0;
}

Expand Down
70 changes: 41 additions & 29 deletions src/main/java/net/malisis/core/renderer/MalisisRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.malisis.core.renderer.font.FontRenderOptions;
import net.malisis.core.renderer.font.MalisisFont;
import net.malisis.core.renderer.icon.MalisisIcon;
import net.malisis.doors.door.tileentity.DoorTileEntity;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
Expand Down Expand Up @@ -78,7 +79,7 @@ public class MalisisRenderer extends TileEntitySpecialRenderer
/** Id of this {@link MalisisRenderer}. */
protected int renderId = -1;
/** Tessellator reference. */
protected Tessellator t = Tessellator.instance;
protected Tessellator tessellator = Tessellator.instance;
/** Current world reference (ISBRH/TESR/IRWL). */
protected IBlockAccess world;
/** RenderBlocks reference (ISBRH). */
Expand Down Expand Up @@ -131,7 +132,6 @@ public class MalisisRenderer extends TileEntitySpecialRenderer
*/
public MalisisRenderer() {
this.renderId = RenderingRegistry.getNextAvailableRenderId();
this.t = Tessellator.instance;
}

/**
Expand Down Expand Up @@ -264,6 +264,7 @@ public void set(ItemRenderType type, ItemStack itemStack) {
*/
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
this.tessellator = Tessellator.instance;
set(block, metadata);
renderBlocks = renderer;
prepare(RenderType.ISBRH_INVENTORY);
Expand All @@ -286,6 +287,7 @@ public void renderInventoryBlock(Block block, int metadata, int modelId, RenderB
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
this.tessellator = Tessellator.instance;
set(world, block, x, y, z, world.getBlockMetadata(x, y, z));
tileEntity = world.getTileEntity(x, y, z);
renderBlocks = renderer;
Expand Down Expand Up @@ -347,6 +349,7 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe
*/
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
this.tessellator = Tessellator.instance;
set(type, item);
prepare(RenderType.ITEM_INVENTORY);
render();
Expand All @@ -367,26 +370,30 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
*/
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
set(te, partialTick);
prepare(RenderType.TESR_WORLD, x, y, z);
render();
if (getBlockDamage) {
destroyBlockProgress = getBlockDestroyProgress();
if (destroyBlockProgress != null) {
next();

GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);

t.disableColor();
renderDestroyProgress();
next();
GL11.glDisable(GL11.GL_BLEND);
if (te instanceof DoorTileEntity && ((DoorTileEntity) te).shouldRender()) {
this.tessellator = Tessellator.instance;
set(te, partialTick);
prepare(RenderType.TESR_WORLD, x, y, z);
render();
if (getBlockDamage) {
destroyBlockProgress = getBlockDestroyProgress();
if (destroyBlockProgress != null) {

next();

GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);

this.tessellator.disableColor();
renderDestroyProgress();
next();
GL11.glDisable(GL11.GL_BLEND);
}
}
clean();
}
clean();
}

// #end TESR
Expand All @@ -404,6 +411,7 @@ public boolean shouldRender(RenderWorldLastEvent event, IBlockAccess world) {

@Override
public void renderWorldLastEvent(RenderWorldLastEvent event, IBlockAccess world) {
this.tessellator = Tessellator.instance;
set(world);
partialTick = event.partialTicks;
renderGlobal = event.context;
Expand Down Expand Up @@ -486,7 +494,7 @@ public void startDrawing() {
*/
public void startDrawing(int drawMode) {
if (isDrawing()) draw();
t.startDrawing(drawMode);
this.tessellator.startDrawing(drawMode);
this.drawMode = drawMode;
}

Expand Down Expand Up @@ -520,7 +528,7 @@ public void next(int drawMode) {
* Triggers a draw.
*/
public void draw() {
if (isDrawing()) t.draw();
if (isDrawing()) this.tessellator.draw();
}

/**
Expand Down Expand Up @@ -554,7 +562,7 @@ public void tessellatorShift() {
if (isShifted) return;

isShifted = true;
t.addTranslation(x, y, z);
this.tessellator.addTranslation(x, y, z);
}

/**
Expand All @@ -564,7 +572,7 @@ public void tessellatorUnshift() {
if (!isShifted) return;

isShifted = false;
t.addTranslation(-x, -y, -z);
this.tessellator.addTranslation(-x, -y, -z);
}

/**
Expand Down Expand Up @@ -656,6 +664,7 @@ public void render() {
public void renderDestroyProgress() {
if (destroyBlockProgress != null) overrideTexture = damagedIcons[destroyBlockProgress.getPartialBlockDamage()];
// enableBlending();
this.tessellator = Tessellator.instance;
render();
}

Expand Down Expand Up @@ -731,7 +740,10 @@ protected void drawFace(Face f, RenderParameters faceParams) {
// use normals if available
if ((renderType == RenderType.ITEM_INVENTORY || renderType == RenderType.ISBRH_INVENTORY
|| params.useNormals.get()) && params.direction.get() != null)
t.setNormal(params.direction.get().offsetX, params.direction.get().offsetY, params.direction.get().offsetZ);
this.tessellator.setNormal(
params.direction.get().offsetX,
params.direction.get().offsetY,
params.direction.get().offsetZ);

baseBrightness = getBaseBrightness();

Expand Down Expand Up @@ -772,12 +784,12 @@ protected void drawVertex(Vertex vertex, int number) {
// alpha
if (!params.usePerVertexAlpha.get()) vertex.setAlpha(params.alpha.get());

t.setColorRGBA_I(vertex.getColor(), vertex.getAlpha());
t.setBrightness(vertex.getBrightness());
this.tessellator.setColorRGBA_I(vertex.getColor(), vertex.getAlpha());
this.tessellator.setBrightness(vertex.getBrightness());

if (params.useTexture.get())
t.addVertexWithUV(vertex.getX(), vertex.getY(), vertex.getZ(), vertex.getU(), vertex.getV());
else t.addVertex(vertex.getX(), vertex.getY(), vertex.getZ());
this.tessellator.addVertexWithUV(vertex.getX(), vertex.getY(), vertex.getZ(), vertex.getU(), vertex.getV());
else this.tessellator.addVertex(vertex.getX(), vertex.getY(), vertex.getZ());

vertexDrawn = true;
}
Expand Down
Loading