Skip to content

Instantly share code, notes, and snippets.

@chexo3
Created May 20, 2021 02:34
Show Gist options
  • Save chexo3/d4013846c002d6291d26bf80ceee6dd2 to your computer and use it in GitHub Desktop.
Save chexo3/d4013846c002d6291d26bf80ceee6dd2 to your computer and use it in GitHub Desktop.
net.minecraft.block.Trapdoor in Beta 1.7.3, BIN mappings. This is a scratch file to show the effective changes that my mixins create to Gun Man, who maintains the base class edit version.
package net.minecraft.block;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Living;
import net.minecraft.entity.player.PlayerBase;
import net.minecraft.level.Level;
import net.minecraft.level.TileView;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.maths.Box;
import net.minecraft.util.maths.MathHelper;
import net.minecraft.util.maths.Vec3f;
public class Trapdoor extends BlockBase {
protected Trapdoor(int i, Material arg) {
super(i, arg);
this.texture = 84;
if (arg == Material.METAL) {
++this.texture;
}
float var3 = 0.5F;
float var4 = 1.0F;
this.setBoundingBox(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, var4, 0.5F + var3);
}
//SlightlyBetterTrapdoors
private boolean doPlayerBasedRotation;
public boolean isFullOpaque() {
return false;
}
public boolean isFullCube() {
return false;
}
@Environment(EnvType.CLIENT)
public int getRenderType() {
return 0;
}
@Environment(EnvType.CLIENT)
public Box getOutlineShape(Level level, int x, int y, int z) {
this.updateBoundingBox(level, x, y, z);
return super.getOutlineShape(level, x, y, z);
}
public Box getCollisionShape(Level level, int x, int y, int z) {
this.updateBoundingBox(level, x, y, z);
return super.getCollisionShape(level, x, y, z);
}
public void updateBoundingBox(TileView tileView, int x, int y, int z) {
this.method_1060(tileView.getTileMeta(x, y, z));
}
@Environment(EnvType.CLIENT)
public void method_1605() {
float var1 = 0.1875F;
this.setBoundingBox(0.0F, 0.5F - var1 / 2.0F, 0.0F, 1.0F, 0.5F + var1 / 2.0F, 1.0F);
}
public void method_1060(int i) {
float var2 = 0.1875F;
this.setBoundingBox(0.0F, 0.0F, 0.0F, 1.0F, var2, 1.0F);
if (method_1061(i)) {
if ((i & 3) == 0) {
this.setBoundingBox(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
}
if ((i & 3) == 1) {
this.setBoundingBox(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
}
if ((i & 3) == 2) {
this.setBoundingBox(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if ((i & 3) == 3) {
this.setBoundingBox(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
}
}
}
public void activate(Level level, int x, int y, int z, PlayerBase player) {
this.canUse(level, x, y, z, player);
}
public boolean canUse(Level level, int x, int y, int z, PlayerBase player) {
if (this.material == Material.METAL) {
return true;
} else {
int var6 = level.getTileMeta(x, y, z);
level.setTileMeta(x, y, z, var6 ^ 4);
level.playLevelEvent(player, 1003, x, y, z, 0);
return true;
}
}
public void method_1059(Level arg, int i, int j, int k, boolean flag) {
int var6 = arg.getTileMeta(i, j, k);
boolean var7 = (var6 & 4) > 0;
if (var7 != flag) {
arg.setTileMeta(i, j, k, var6 ^ 4);
arg.playLevelEvent((PlayerBase)null, 1003, i, j, k, 0);
}
}
//SlightlyBetterTrapdoors
public void onAdjacentBlockUpdate(Level level, int x, int y, int z, int id) {
if (!level.isClient) {
int var6 = level.getTileMeta(x, y, z);
int var7 = x;
int var8 = z;
if ((var6 & 3) == 0) {
var8 = z + 1;
}
if ((var6 & 3) == 1) {
--var8;
}
if ((var6 & 3) == 2) {
var7 = x + 1;
}
if ((var6 & 3) == 3) {
--var7;
}
if (id > 0 && BlockBase.BY_ID[id].getEmitsRedstonePower()) {
boolean var9 = level.hasRedstonePower(x, y, z);
this.method_1059(level, x, y, z, var9);
}
}
}
public HitResult method_1564(Level arg, int i, int j, int k, Vec3f arg1, Vec3f arg2) {
this.updateBoundingBox(arg, i, j, k);
return super.method_1564(arg, i, j, k, arg1, arg2);
}
public void onBlockPlaced(Level level, int x, int y, int z, int facing) {
byte var6 = 0;
if (facing == 2) {
var6 = 0;
}
if (facing == 3) {
var6 = 1;
}
if (facing == 4) {
var6 = 2;
}
if (facing == 5) {
var6 = 3;
}
level.setTileMeta(x, y, z, var6);
}
//SlightlyBetterTrapdoors
public boolean canPlaceAt(Level level, int x, int y, int z, int meta) {
if (meta == 0 || meta == 1) {
doPlayerBasedRotation = true;
}
return true;
}
public void afterPlaced(Level level, int x, int y, int z, Living living) {
if (doPlayerBasedRotation) {
int rotation = MathHelper.floor((double) (living.yaw * 4.0F / 360.0F) + 0.5D) & 3;
int[] magic = {0, 3, 1, 2};
level.setTileMeta(x, y, z, magic[rotation]);
}
}
public static boolean method_1061(int i) {
return (i & 4) != 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment