Skip to content

Commit

Permalink
Merge pull request #466 from KAMKEEL/glass-pane
Browse files Browse the repository at this point in the history
Singular Post - Pane Model
  • Loading branch information
Roadhog360 authored May 19, 2024
2 parents f62ff49 + e357915 commit 1b904a1
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/ganymedes01/etfuturum/EtFuturumMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ public List<String> getMixins() {
}
}

if (ConfigMixins.thinPanes) {
mixins.add("thinpanes.MixinBlockPane");
mixins.add("thinpanes.MixinRenderBlocks");
}

return mixins;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ConfigMixins extends ConfigBase {
public static boolean interpolatedTextures;
public static boolean hideSingleLevelEnchants;
public static boolean fireproofItems;
public static boolean thinPanes;

static final String catBackport = "backported features";
static final String catOptimization = "optimizations";
Expand Down Expand Up @@ -103,6 +104,7 @@ protected void syncConfigOptions() {
betterPistons = getBoolean("betterPistons", catBackport, true, "A port of Back in Slime, similar to how the elytra is a port of Backlytra. Allows pistons to interact with slime blocks. The original author of this is DonBruce64: https://legacy.curseforge.com/minecraft/mc-mods/back-in-slime-slime-blocks-for-1-7.\nModified Classes: net.minecraft.block.BlockPistonBase");
soulFire = getBoolean("soulFire", catBackport, true, "Is not a new block, but rather a mixin for fire. Allows fire to stay ignited on soul soil. Does double damage when standing in it, and does not spread to other blocks.\nEven if this is off fire can still stay ignited on soul soil, but do be mindful that fire will spread from soul soil if this option is disabled.\nModified Classes: net.minecraft.block.BlockFire net.minecraft.entity.Entity\nModified Client Classes: net.minecraft.client.renderer.RenderBlocks");
fireproofItems = getBoolean("fireproofItems", catBackport, true, "Some items such as Netherite will not burn in fire and will float to the surface of lava.");
thinPanes = getBoolean("thinPanes", catBackport, true, "Panes [Iron Bars, Glass Panes, etc] are changed to a single post if they are not connected to any other blocks");

stepHeightFix = getBoolean("stepHeightFix", catFixes, true, "Makes the player able to step up even if a block would be above their head at the destination.\nModified classes: net.minecraft.entity.Entity");
arrowFallingFix = getBoolean("arrowFallingFix", catFixes, true, "Prevents arrows from falling off of blocks too easily\nModified classes: net.minecraft.entity.EntityArrow");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ganymedes01.etfuturum.mixins.thinpanes;

import net.minecraft.block.Block;
import net.minecraft.block.BlockPane;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.List;

@Mixin(BlockPane.class)
public abstract class MixinBlockPane extends Block {

protected MixinBlockPane(Material p_i45394_1_) {
super(p_i45394_1_);
}

@Inject(method = "addCollisionBoxesToList", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.AFTER), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void remapCollisionsBoxes(World worldIn, int posX, int posY, int posZ, AxisAlignedBB bb, List boxList, Entity entity, CallbackInfo ci, boolean flag, boolean flag1, boolean flag2, boolean flag3) {
if(!flag && !flag1 && !flag2 && !flag3){
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 1.0F, 0.5625F);
super.addCollisionBoxesToList(worldIn, posX, posY, posZ, bb, boxList, entity);
ci.cancel();
}
}

@Inject(method = "setBlockBoundsBasedOnState", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.AFTER), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, int posX, int posY, int posZ, CallbackInfo ci, float f, float f1, float f2, float f3, boolean flag, boolean flag1, boolean flag2, boolean flag3)
{
if(!flag2 && !flag3 && !flag && !flag1){
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package ganymedes01.etfuturum.mixins.thinpanes;

import net.minecraft.block.Block;
import net.minecraft.block.BlockPane;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(RenderBlocks.class)
public abstract class MixinRenderBlocks {

@Inject(method = "renderBlockPane", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockPane;shouldSideBeRendered(Lnet/minecraft/world/IBlockAccess;IIII)Z", ordinal = 1, shift = At.Shift.AFTER), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void remapCollisionsBoxes(BlockPane p_147767_1_, int posX, int posY, int posZ, CallbackInfoReturnable<Boolean> cir,
int l, Tessellator tessellator, int i1, float f, float f1, float f2,
IIcon iicon, IIcon iicon1,
double d21, double d0, double d1, double d2, double d3, double d4, double d5,
double d6, double d7, double d8, double d9, double d10, double d11, double d12,
double d13, double d14, double d15, double d16, double d17, double d18,
boolean flag, boolean flag1, boolean flag2, boolean flag3, boolean flag4) {
// Not Connected to anything
if(!flag && !flag1 && !flag2 && !flag3){
// Cut out Icon Textures for Tops / Bottoms
double d00 = (double)iicon.getInterpolatedU(7.0D);
double d01 = (double)iicon.getInterpolatedU(9.0D);
double d000 = (double)iicon1.getInterpolatedV(7.0D);
double d001 = (double)iicon1.getInterpolatedV(9.0D);

tessellator.addVertexWithUV(d16, (double)(posY + 1), d13, d00, d2);
tessellator.addVertexWithUV(d16, (double)(posY + 0), d13, d00, d3);
tessellator.addVertexWithUV(d15, (double)(posY + 0), d13, d01, d3);
tessellator.addVertexWithUV(d15, (double)(posY + 1), d13, d01, d2);

tessellator.addVertexWithUV(d15, (double)(posY + 1), d13, d00, d2);
tessellator.addVertexWithUV(d15, (double)(posY + 0), d13, d00, d3);
tessellator.addVertexWithUV(d16, (double)(posY + 0), d13, d01, d3);
tessellator.addVertexWithUV(d16, (double)(posY + 1), d13, d01, d2);

tessellator.addVertexWithUV(d10, (double)(posY + 1), d17, d00, d2);
tessellator.addVertexWithUV(d10, (double)(posY + 0), d17, d00, d3);
tessellator.addVertexWithUV(d10, (double)(posY + 0), d18, d01, d3);
tessellator.addVertexWithUV(d10, (double)(posY + 1), d18, d01, d2);

tessellator.addVertexWithUV(d10, (double)(posY + 1), d18, d00, d2);
tessellator.addVertexWithUV(d10, (double)(posY + 0), d18, d00, d3);
tessellator.addVertexWithUV(d10, (double)(posY + 0), d17, d01, d3);
tessellator.addVertexWithUV(d10, (double)(posY + 1), d17, d01, d2);

// Top-Over
tessellator.addVertexWithUV(d15, (double)(posY + 1 - 0.001D), d18, d5, d000);
tessellator.addVertexWithUV(d16, (double)(posY + 1 - 0.001D), d18, d5, d001);
tessellator.addVertexWithUV(d16, (double)(posY + 1 - 0.001D), d17, d4, d001);
tessellator.addVertexWithUV(d15, (double)(posY + 1 - 0.001D), d17, d4, d000);

// Top-Under
tessellator.addVertexWithUV(d16, (double)(posY + 1 - 0.001D), d18, d5, d000);
tessellator.addVertexWithUV(d15, (double)(posY + 1 - 0.001D), d18, d5, d001);
tessellator.addVertexWithUV(d15, (double)(posY + 1 - 0.001D), d17, d4, d001);
tessellator.addVertexWithUV(d16, (double)(posY + 1 - 0.001D), d17, d4, d000);

// Bottom-Over
tessellator.addVertexWithUV(d15, (double)(posY + 0.001D), d18, d5, d000);
tessellator.addVertexWithUV(d16, (double)(posY + 0.001D), d18, d5, d001);
tessellator.addVertexWithUV(d16, (double)(posY + 0.001D), d17, d4, d001);
tessellator.addVertexWithUV(d15, (double)(posY + 0.001D), d17, d4, d000);

// Bottom-Under
tessellator.addVertexWithUV(d16, (double)(posY + 0.001D), d18, d5, d000);
tessellator.addVertexWithUV(d15, (double)(posY + 0.001D), d18, d5, d001);
tessellator.addVertexWithUV(d15, (double)(posY + 0.001D), d17, d4, d001);
tessellator.addVertexWithUV(d16, (double)(posY + 0.001D), d17, d4, d000);

cir.setReturnValue(true);
}
}

@Inject(method = "renderBlockStainedGlassPane", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/block/BlockPane;canPaneConnectTo(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/common/util/ForgeDirection;)Z", ordinal = 3, shift = At.Shift.AFTER), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void remapCollisionsBoxes(Block p_147733_1_, int posX, int posY, int posZ, CallbackInfoReturnable<Boolean> cir,
int l, Tessellator tessellator, int i1, float f, float f1, float f2, boolean flag5,
IIcon iicon, IIcon iicon1, double d22,
double d0, double d1, double d2, double d3, double d4, double d5, double d6,
double d7, double d8, double d9, double d10, double d11, double d12, double d13,
double d14, double d15, double d16, double d17, double d18,
boolean flag, boolean flag1, boolean flag2, boolean flag3) {
// Not Connected to Anything
if(!flag && !flag1 && !flag2 && !flag3){

double d00 = (double)posX + 0.4375F;
double d01 = (double)(posX + (1 - 0.4375F));
double d000 = (double)posZ + 0.4375F;
double d001 = (double)(posZ + (1 - 0.4375F));

tessellator.addVertexWithUV(d00, (double)posY + 0.999D, d17, d0, d3);
tessellator.addVertexWithUV(d00, (double)posY + 0.001D, d17, d0, d4);
tessellator.addVertexWithUV(d00, (double)posY + 0.001D, d18, d1, d4);
tessellator.addVertexWithUV(d00, (double)posY + 0.999D, d18, d1, d3);

tessellator.addVertexWithUV(d01, (double)posY + 0.999D, d18, d0, d3);
tessellator.addVertexWithUV(d01, (double)posY + 0.001D, d18, d0, d4);
tessellator.addVertexWithUV(d01, (double)posY + 0.001D, d17, d1, d4);
tessellator.addVertexWithUV(d01, (double)posY + 0.999D, d17, d1, d3);

tessellator.addVertexWithUV(d16, (double)posY + 0.999D, d000, d1, d3);
tessellator.addVertexWithUV(d16, (double)posY + 0.001D, d000, d1, d4);
tessellator.addVertexWithUV(d15, (double)posY + 0.001D, d000, d0, d4);
tessellator.addVertexWithUV(d15, (double)posY + 0.999D, d000, d0, d3);

tessellator.addVertexWithUV(d15, (double)posY + 0.999D, d001, d0, d3);
tessellator.addVertexWithUV(d15, (double)posY + 0.001D, d001, d0, d4);
tessellator.addVertexWithUV(d16, (double)posY + 0.001D, d001, d1, d4);
tessellator.addVertexWithUV(d16, (double)posY + 0.999D, d001, d1, d3);

// Top and Bottom
tessellator.addVertexWithUV(d16, (double)posY + 0.999D, d17, d6, d9);
tessellator.addVertexWithUV(d15, (double)posY + 0.999D, d17, d5, d9);
tessellator.addVertexWithUV(d15, (double)posY + 0.999D, d18, d5, d10);
tessellator.addVertexWithUV(d16, (double)posY + 0.999D, d18, d6, d10);
tessellator.addVertexWithUV(d15, (double)posY + 0.001D, d17, d5, d9);
tessellator.addVertexWithUV(d16, (double)posY + 0.001D, d17, d6, d9);
tessellator.addVertexWithUV(d16, (double)posY + 0.001D, d18, d6, d10);
tessellator.addVertexWithUV(d15, (double)posY + 0.001D, d18, d5, d10);

cir.setReturnValue(true);
}
}
}

0 comments on commit 1b904a1

Please sign in to comment.