Skip to content

Commit

Permalink
Port Apis base classes to biny
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Dec 25, 2024
1 parent 05a5d01 commit 8c5ebd5
Show file tree
Hide file tree
Showing 41 changed files with 489 additions and 507 deletions.
5 changes: 2 additions & 3 deletions apron/src/main/java/forge/BlockTextureParticles.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.entity.particle.ParticleEntity;

import net.minecraft.client.particle.Particle;
import io.github.betterthanupdates.Legacy;

@Legacy
@Environment(EnvType.CLIENT)
public class BlockTextureParticles {
public String texture;
public List<ParticleEntity> effects = new ArrayList<>();
public List<Particle> effects = new ArrayList<>();

public BlockTextureParticles() {
}
Expand Down
8 changes: 4 additions & 4 deletions apron/src/main/java/forge/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Configuration(File file) {

public Property getOrCreateBlockIdProperty(String key, int defaultId) {
if (this.configBlocks == null) {
this.configBlocks = new boolean[Block.BY_ID.length];
this.configBlocks = new boolean[Block.BLOCKS.length];

Arrays.fill(this.configBlocks, false);
}
Expand All @@ -55,13 +55,13 @@ public Property getOrCreateBlockIdProperty(String key, int defaultId) {
this.blockProperties.put(key, property);
property.name = key;

if (Block.BY_ID[defaultId] == null && !this.configBlocks[defaultId]) {
if (Block.BLOCKS[defaultId] == null && !this.configBlocks[defaultId]) {
property.value = Integer.toString(defaultId);
this.configBlocks[defaultId] = true;
return property;
} else {
for (int j = Block.BY_ID.length - 1; j >= 0; --j) {
if (Block.BY_ID[j] == null && !this.configBlocks[j]) {
for (int j = Block.BLOCKS.length - 1; j >= 0; --j) {
if (Block.BLOCKS[j] == null && !this.configBlocks[j]) {
property.value = Integer.toString(j);
this.configBlocks[j] = true;
return property;
Expand Down
46 changes: 23 additions & 23 deletions apron/src/main/java/forge/ForgeHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import java.util.LinkedList;

import net.minecraft.block.Block;
import net.minecraft.class_141;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SleepStatus;

import io.github.betterthanupdates.Legacy;
import io.github.betterthanupdates.forge.block.ForgeBlock;
Expand Down Expand Up @@ -51,9 +51,9 @@ public static void onDestroyCurrentItem(PlayerEntity player, ItemStack itemStack
}
}

public static SleepStatus sleepInBedAt(PlayerEntity player, int x, int y, int z) {
public static class_141 sleepInBedAt(PlayerEntity player, int x, int y, int z) {
for (ISleepHandler handler : sleepHandlers) {
SleepStatus status = handler.sleepInBedAt(player, x, y, z);
class_141 status = handler.sleepInBedAt(player, x, y, z);

if (status != null) {
return status;
Expand All @@ -64,10 +64,10 @@ public static SleepStatus sleepInBedAt(PlayerEntity player, int x, int y, int z)
}

public static boolean canHarvestBlock(Block block, PlayerEntity player, int meta) {
if (block.material.doesRequireTool()) {
if (block.material.method_898()) {
return true;
} else {
ItemStack itemstack = player.inventory.getHeldItem();
ItemStack itemstack = player.inventory.getSelectedItem();
return itemstack != null && canToolHarvestBlock(block, meta, itemstack);
}
}
Expand All @@ -76,7 +76,7 @@ public static boolean canToolHarvestBlock(Block block, int meta, ItemStack itemS
ForgeTool forgeTool = toolClasses.get(itemStack.itemId);

if (forgeTool == null) {
return itemStack.isEffectiveOn(block);
return itemStack.isSuitableFor(block);
} else {
String toolType = forgeTool.toolType;
int harvestLevel = forgeTool.harvestLevel;
Expand All @@ -87,9 +87,9 @@ public static boolean canToolHarvestBlock(Block block, int meta, ItemStack itemS
Integer blockHarvestLevel = toolHarvestLevels.get(new ToolEffectiveness(block.id, meta, toolType));

if (blockHarvestLevel == null) {
return itemStack.isEffectiveOn(block);
return itemStack.isSuitableFor(block);
} else {
return blockHarvestLevel <= harvestLevel && itemStack.isEffectiveOn(block);
return blockHarvestLevel <= harvestLevel && itemStack.isSuitableFor(block);
}
}
}
Expand Down Expand Up @@ -120,20 +120,20 @@ public static boolean isToolEffective(ItemStack tool, Block block, int meta) {
static void initTools() {
if (!toolInit) {
toolInit = true;
MinecraftForge.setToolClass(Item.WOOD_PICKAXE, "pickaxe", 0);
MinecraftForge.setToolClass(Item.WOODEN_PICKAXE, "pickaxe", 0);
MinecraftForge.setToolClass(Item.STONE_PICKAXE, "pickaxe", 1);
MinecraftForge.setToolClass(Item.IRON_PICKAXE, "pickaxe", 2);
MinecraftForge.setToolClass(Item.GOLD_PICKAXE, "pickaxe", 0);
MinecraftForge.setToolClass(Item.GOLDEN_PICKAXE, "pickaxe", 0);
MinecraftForge.setToolClass(Item.DIAMOND_PICKAXE, "pickaxe", 3);
MinecraftForge.setToolClass(Item.WOOD_AXE, "axe", 0);
MinecraftForge.setToolClass(Item.STONE_AXE, "axe", 1);
MinecraftForge.setToolClass(Item.WOODEN_AXE, "axe", 0);
MinecraftForge.setToolClass(Item.STONE_HATCHET, "axe", 1);
MinecraftForge.setToolClass(Item.IRON_AXE, "axe", 2);
MinecraftForge.setToolClass(Item.GOLD_AXE, "axe", 0);
MinecraftForge.setToolClass(Item.GOLDEN_AXE, "axe", 0);
MinecraftForge.setToolClass(Item.DIAMOND_AXE, "axe", 3);
MinecraftForge.setToolClass(Item.WOOD_SHOVEL, "shovel", 0);
MinecraftForge.setToolClass(Item.WOODEN_SHOVEL, "shovel", 0);
MinecraftForge.setToolClass(Item.STONE_SHOVEL, "shovel", 1);
MinecraftForge.setToolClass(Item.IRON_SHOVEL, "shovel", 2);
MinecraftForge.setToolClass(Item.GOLD_SHOVEL, "shovel", 0);
MinecraftForge.setToolClass(Item.GOLDEN_SHOVEL, "shovel", 0);
MinecraftForge.setToolClass(Item.DIAMOND_SHOVEL, "shovel", 3);
MinecraftForge.setBlockHarvestLevel(Block.OBSIDIAN, "pickaxe", 3);
MinecraftForge.setBlockHarvestLevel(Block.DIAMOND_ORE, "pickaxe", 2);
Expand All @@ -142,17 +142,17 @@ static void initTools() {
MinecraftForge.setBlockHarvestLevel(Block.GOLD_BLOCK, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.IRON_ORE, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.IRON_BLOCK, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.LAPIS_LAZULI_ORE, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.LAPIS_LAZULI_BLOCK, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.LAPIS_ORE, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.LAPIS_BLOCK, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.REDSTONE_ORE, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.REDSTONE_ORE_LIT, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.LIT_REDSTONE_ORE, "pickaxe", 2);
MinecraftForge.removeBlockEffectiveness(Block.REDSTONE_ORE, "pickaxe");
MinecraftForge.removeBlockEffectiveness(Block.REDSTONE_ORE_LIT, "pickaxe");
MinecraftForge.removeBlockEffectiveness(Block.LIT_REDSTONE_ORE, "pickaxe");

Block[] pickaxeEffectiveOn = new Block[] {
Block.COBBLESTONE,
Block.DOUBLE_STONE_SLAB,
Block.STONE_SLAB,
Block.DOUBLE_SLAB,
Block.SLAB,
Block.STONE,
Block.SANDSTONE,
Block.MOSSY_COBBLESTONE,
Expand All @@ -165,8 +165,8 @@ static void initTools() {
Block.DIAMOND_BLOCK,
Block.ICE,
Block.NETHERRACK,
Block.LAPIS_LAZULI_ORE,
Block.LAPIS_LAZULI_BLOCK
Block.LAPIS_ORE,
Block.LAPIS_BLOCK
};

for (Block block : pickaxeEffectiveOn) {
Expand Down
22 changes: 11 additions & 11 deletions apron/src/main/java/forge/ForgeHooksClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import net.minecraft.block.Block;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.WorldEventRenderer;
import net.minecraft.client.render.block.BlockRenderer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.hit.HitResult;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class ForgeHooksClient {
public ForgeHooksClient() {
}

public static boolean onBlockHighlight(WorldEventRenderer worldEventRenderer, PlayerEntity player, HitResult hitResult, int i, ItemStack itemStack, float f) {
public static boolean onBlockHighlight(WorldRenderer worldEventRenderer, PlayerEntity player, HitResult hitResult, int i, ItemStack itemStack, float f) {
for (IHighlightHandler handler : highlightHandlers) {
if (handler.onBlockHighlight(worldEventRenderer, player, hitResult, i, itemStack, f)) {
return true;
Expand All @@ -65,7 +65,7 @@ public static boolean canRenderInPass(Block block, int pass) {
IMultipassRender multipassRender = (IMultipassRender) block;
return multipassRender.canRenderInPass(pass);
} else {
return pass == block.getRenderPass();
return pass == block.getRenderLayer();
}
}

Expand All @@ -83,8 +83,8 @@ protected static void bindTessellator(int textureId, int sub) {
if (inWorld && !renderTextureTest.contains(key)) {
renderTextureTest.add(key);
renderTextureList.add(key);
tessellator.start();
tessellator.setOffset(
tessellator.startQuads();
tessellator.translate(
ForgeClientReflection.Tessellator$firstInstance.xOffset,
ForgeClientReflection.Tessellator$firstInstance.yOffset,
ForgeClientReflection.Tessellator$firstInstance.zOffset);
Expand Down Expand Up @@ -136,22 +136,22 @@ public static void afterRenderPass(int pass) {
for (IntegerPair l : renderTextureList) {
GL11.glBindTexture(3553, l.first());
Tessellator tessellator = tessellators.get(l);
tessellator.tessellate();
tessellator.draw();
}

GL11.glBindTexture(3553, ((ApronClientImpl) ApronApi.getInstance()).getTextureManager().getTextureId("/terrain.png"));
Tessellator.INSTANCE = ForgeClientReflection.Tessellator$firstInstance;
ForgeClientReflection.Tessellator$renderingWorldRenderer = false;
}

public static void beforeBlockRender(Block block, BlockRenderer blockRenderer) {
public static void beforeBlockRender(Block block, BlockRenderManager blockRenderer) {
if (block instanceof ITextureProvider && blockRenderer.textureOverride == -1) {
ITextureProvider textureProvider = (ITextureProvider) block;
bindTexture(textureProvider.getTextureFile(), 0);
}
}

public static void afterBlockRender(Block block, BlockRenderer blockRenderer) {
public static void afterBlockRender(Block block, BlockRenderManager blockRenderer) {
if (block instanceof ITextureProvider && blockRenderer.textureOverride == -1) {
unbindTexture();
}
Expand All @@ -172,8 +172,8 @@ public static void overrideTexture(Object o) {
}

// Not included in Reforged for unknown reasons
public static void renderCustomItem(ICustomItemRenderer customRenderer, BlockRenderer blockRenderer, int itemID, int meta, float f) {
if (blockRenderer.field_81) {
public static void renderCustomItem(ICustomItemRenderer customRenderer, BlockRenderManager blockRenderer, int itemID, int meta, float f) {
if (blockRenderer.inventoryColorEnabled) {
int j = 16777215;
float f1 = (float) (j >> 16 & 0xFF) / 255.0F;
float f3 = (float) (j >> 8 & 0xFF) / 255.0F;
Expand Down
5 changes: 2 additions & 3 deletions apron/src/main/java/forge/ICustomItemRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.block.BlockRenderer;

import net.minecraft.client.render.block.BlockRenderManager;
import io.github.betterthanupdates.Legacy;

@Legacy
@Environment(EnvType.CLIENT)
public interface ICustomItemRenderer {
void renderInventory(BlockRenderer blockRenderer, int itemId, int meta);
void renderInventory(BlockRenderManager blockRenderer, int itemId, int meta);
}
4 changes: 2 additions & 2 deletions apron/src/main/java/forge/IHighlightHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.WorldEventRenderer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.hit.HitResult;
Expand All @@ -17,5 +17,5 @@
@Legacy
@Environment(EnvType.CLIENT)
public interface IHighlightHandler {
boolean onBlockHighlight(WorldEventRenderer worldEventRenderer, PlayerEntity player, HitResult hitResult, int i, ItemStack itemStack, float f);
boolean onBlockHighlight(WorldRenderer worldEventRenderer, PlayerEntity player, HitResult hitResult, int i, ItemStack itemStack, float f);
}
4 changes: 2 additions & 2 deletions apron/src/main/java/forge/ISleepHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

package forge;

import net.minecraft.class_141;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.SleepStatus;

import io.github.betterthanupdates.Legacy;

@Legacy
public interface ISleepHandler {
SleepStatus sleepInBedAt(PlayerEntity player, int x, int y, int z);
class_141 sleepInBedAt(PlayerEntity player, int x, int y, int z);
}
6 changes: 3 additions & 3 deletions apron/src/main/java/forge/MinecraftForgeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.fabricmc.loader.api.FabricLoader;

import net.minecraft.block.Block;
import net.minecraft.client.render.block.BlockRenderer;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.item.Item;

import io.github.betterthanupdates.Legacy;
Expand All @@ -22,7 +22,7 @@
@Environment(EnvType.CLIENT)
@Legacy
public class MinecraftForgeClient {
private static final ICustomItemRenderer[] CUSTOM_ITEM_RENDERERS = new ICustomItemRenderer[Item.byId.length];
private static final ICustomItemRenderer[] CUSTOM_ITEM_RENDERERS = new ICustomItemRenderer[Item.ITEMS.length];

public MinecraftForgeClient() {
}
Expand Down Expand Up @@ -51,7 +51,7 @@ public static void preloadTexture(String texture) {
}
}

public static void renderBlock(BlockRenderer blockRenderer, Block block, int x, int y, int z) {
public static void renderBlock(BlockRenderManager blockRenderer, Block block, int x, int y, int z) {
ForgeHooksClient.beforeBlockRender(block, blockRenderer);
blockRenderer.render(block, x, y, z);
ForgeHooksClient.afterBlockRender(block, blockRenderer);
Expand Down
24 changes: 12 additions & 12 deletions apron/src/main/java/guiapi/ModScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import de.matthiasmann.twl.renderer.lwjgl.RenderScale;
import guiapi.widget.ScreenWidget;

import net.minecraft.class_564;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.ScreenScaler;

public class ModScreen extends Screen {
public static ModScreen currentScreen;
Expand All @@ -18,7 +18,7 @@ public class ModScreen extends Screen {
public static void back() {
if (currentScreen != null) {
Minecraft m = ModSettings.getMcinst();
m.openScreen(currentScreen.parentScreen);
m.setScreen(currentScreen.parentScreen);

if (currentScreen.parentScreen instanceof ModScreen) {
currentScreen = (ModScreen) currentScreen.parentScreen;
Expand All @@ -31,12 +31,12 @@ public static void back() {

public static void clicksound() {
Minecraft m = ModSettings.getMcinst();
m.soundHelper.playSound("random.click", 1.0F, 1.0F);
m.soundManager.method_2009("random.click", 1.0F, 1.0F);
}

public static void show(ModScreen screen) {
Minecraft m = ModSettings.getMcinst();
m.openScreen(screen);
m.setScreen(screen);
screen.setActive();
}

Expand All @@ -47,14 +47,14 @@ public static void show(Widget screen) {
public ModScreen(Screen screen) {
this.parentScreen = screen;
currentScreen = this;
this.passEvents = false;
this.field_155 = false;
}

public ModScreen(Screen screen, Widget widget) {
this.mainwidget = widget;
this.parentScreen = screen;
currentScreen = this;
this.passEvents = false;
this.field_155 = false;
}

@Override
Expand All @@ -64,22 +64,22 @@ public void render(int var1, int var2, float var3) {
this.renderBackground();
break;
case 1:
this.renderDirtBackground(0);
this.renderBackgroundTexture(0);
}

LWJGLRenderer var4 = (LWJGLRenderer) ScreenWidget.getInstance().gui.getRenderer();
ScreenScaler var5 = new ScreenScaler(
class_564 var5 = new class_564(
ScreenWidget.getInstance().minecraftInstance.options,
ScreenWidget.getInstance().minecraftInstance.actualWidth,
ScreenWidget.getInstance().minecraftInstance.actualHeight
ScreenWidget.getInstance().minecraftInstance.displayWidth,
ScreenWidget.getInstance().minecraftInstance.displayHeight
);
RenderScale.scale = var5.scale;
RenderScale.scale = var5.field_2391;
var4.syncViewportSize();
ScreenWidget.getInstance().gui.update();
}

@Override
public void method_130() {
public void tickInput() {
}

private void setActive() {
Expand Down
Loading

0 comments on commit 8c5ebd5

Please sign in to comment.