Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.1' into 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Dec 15, 2023
2 parents 42dc5fd + 489a8e7 commit b99e226
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/run/
/out/
/.idea/
/build/
/.gradle/
/local-lib/
/out/
2 changes: 2 additions & 0 deletions src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {

CONFIG = new TomlConfigHandler(MOD_ID, toml);

Global.TEXTURE_ATLAS_WIDTH_TILES = Math.max(32, CONFIG.getInt("Experimental.AtlasWidth"));

// Initialize Block and Item static fields
try {
Class.forName("net.minecraft.core.block.Block");
Expand Down
84 changes: 42 additions & 42 deletions src/main/java/turniplabs/halplibe/helper/BlockCoords.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,53 @@
import turniplabs.halplibe.HalpLibe;

public class BlockCoords {
public static int lastX = 24;
public static int lastY = 0;
public static int area = 0;
public static boolean[][] usedCoordinates = new boolean[Global.TEXTURE_ATLAS_WIDTH_TILES][Global.TEXTURE_ATLAS_WIDTH_TILES];

public static int[] nextCoords() {
switch (area) {
case 0: {
int x = lastX;
int y = lastY;
if (++lastX > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
lastX = 22;
if (++lastY > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
area = 1;
lastX = 10;
lastY = 16;
}
}
for (int y = 0; y < usedCoordinates[0].length; y++) {
for (int x = 0; x < usedCoordinates.length; x++) {
if (usedCoordinates[x][y]) continue;
markIDUsed(x, y);
return new int[]{x, y};
}
case 1: {
int x = lastX;
int y = lastY;
if (++lastX > 21) {
lastX = 10;
if (++lastY > 30) {
area = 2;
lastX = 16;
lastY = 10;
}
}
return new int[]{x, y};
}
case 2: {
int x = lastX;
int y = lastY;
if (++lastX > 21) {
lastX = 16;
if (++lastY > 15) {
area = 3;
HalpLibe.LOGGER.info("Reached the end of block texture space!");
}
}
return new int[]{x, y};
}
throw new NullPointerException("Out of Texture space! Increase the atlas size in the halplibe config");
}
public static void markIDUsed(int x, int y){
if (x > Global.TEXTURE_ATLAS_WIDTH_TILES || y > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + x + ", " + y + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
usedCoordinates[x][y] = true;
}
public static void markSectionUsed(int[] topLeft, int[] bottomRight){
if (topLeft[0] > Global.TEXTURE_ATLAS_WIDTH_TILES || topLeft[1] > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + topLeft[0] + ", " + topLeft[1] + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
if (bottomRight[0] > Global.TEXTURE_ATLAS_WIDTH_TILES || bottomRight[1] > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + bottomRight[0] + ", " + bottomRight[1] + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
for (int x = topLeft[0]; x <= bottomRight[0]; x++) {
for (int y = topLeft[1]; y <= bottomRight[1]; y++) {
markIDUsed(x, y);
}
default:
HalpLibe.LOGGER.info("No more block texture spaces are available!");
return new int[]{21, 15};
}
}
static {
markSectionUsed(new int[]{0,0}, new int[]{17, 15});
markSectionUsed(new int[]{18,0}, new int[]{19, 6});
markSectionUsed(new int[]{20,0}, new int[]{21, 3});
markSectionUsed(new int[]{0,16}, new int[]{4, 28});
markSectionUsed(new int[]{0,31}, new int[]{8, 31});
markSectionUsed(new int[]{20,20}, new int[]{31, 31});
markSectionUsed(new int[]{16,24}, new int[]{19, 31});
markSectionUsed(new int[]{5,17}, new int[]{6, 24});
markSectionUsed(new int[]{7,18}, new int[]{10, 20});
markIDUsed(15, 16);
markIDUsed(16, 16);
markIDUsed(18, 8);
markIDUsed(18, 9);
markIDUsed(18, 10);
markIDUsed(22, 0);
markIDUsed(23, 0);
}
}
57 changes: 28 additions & 29 deletions src/main/java/turniplabs/halplibe/helper/ItemCoords.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@
import turniplabs.halplibe.HalpLibe;

public class ItemCoords {
public static int lastX = 16;
public static int lastY = 0;
public static int area = 0;
public static boolean[][] usedCoordinates = new boolean[Global.TEXTURE_ATLAS_WIDTH_TILES][Global.TEXTURE_ATLAS_WIDTH_TILES];

public static int[] nextCoords() {
switch (area) {
case 0: {
int x = lastX;
int y = lastY;
if (++lastX > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
lastX = 16;
if (++lastY > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
area = 1;
lastX = 0;
lastY = 16;
}
for (int y = 0; y < usedCoordinates[0].length; y++) {
for (int x = 0; x < usedCoordinates.length; x++) {
if (!usedCoordinates[x][y]){
markIDUsed(x, y);
return new int[]{x, y};
}
return new int[]{x, y};
}
case 1: {
int x = lastX;
int y = lastY;
if (++lastX > 15) {
lastX = 0;
if (++lastY > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
area = 2;
HalpLibe.LOGGER.info("Reached the end of item texture space!");
}
}
return new int[]{x, y};
}
throw new NullPointerException("Out of Texture space! Increase the atlas size in the halplibe config");
}
public static void markIDUsed(int x, int y){
if (x > Global.TEXTURE_ATLAS_WIDTH_TILES || y > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + x + ", " + y + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
usedCoordinates[x][y] = true;
}
public static void markSectionUsed(int[] topLeft, int[] bottomRight){
if (topLeft[0] > Global.TEXTURE_ATLAS_WIDTH_TILES || topLeft[1] > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + topLeft[0] + ", " + topLeft[1] + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
if (bottomRight[0] > Global.TEXTURE_ATLAS_WIDTH_TILES || bottomRight[1] > Global.TEXTURE_ATLAS_WIDTH_TILES){
throw new IllegalArgumentException("Coordinates [" + bottomRight[0] + ", " + bottomRight[1] + "] is outside the valid range of [" + Global.TEXTURE_ATLAS_WIDTH_TILES + ", " + Global.TEXTURE_ATLAS_WIDTH_TILES + "]");
}
for (int x = topLeft[0]; x <= bottomRight[0]; x++) {
for (int y = topLeft[1]; y <= bottomRight[1]; y++) {
markIDUsed(x, y);
}
default:
HalpLibe.LOGGER.info("No more item texture spaces are available!");
return new int[]{15, Global.TEXTURE_ATLAS_WIDTH_TILES-1};
}
}
static {
markSectionUsed(new int[]{0,0}, new int[]{15, 15});
}
}
3 changes: 1 addition & 2 deletions src/main/java/turniplabs/halplibe/helper/RecipeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ public class RecipeHelper {
public static final RecipesFurnace smeltingManager = RecipesFurnace.getInstance();
@Deprecated
public static final RecipesBlastFurnace blastingManager = RecipesBlastFurnace.getInstance();

@Deprecated
public static void removeRecipe(Item outputItem, int meta) {
IRecipe theRecipe = null;
}

@Deprecated
public static class Crafting {

public static void createShapelessRecipe(Item outputItem, int amount, Object[] aobj) {
craftingManager.addShapelessRecipe(new ItemStack(outputItem, amount), aobj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ public abstract class RenderEngineMixin {
@Shadow
private List<DynamicTexture> dynamicTextures;
@Shadow protected abstract void generateMipmaps(ByteBuffer buffer, BufferedImage image, int levels, boolean smooth);

@Shadow @Final public Minecraft mc;
@Shadow private boolean clampTexture;
@Shadow private boolean blurTexture;
@Shadow @Final public Minecraft mc;
@Unique
private final RenderEngine thisAsRenderEngine = (RenderEngine)(Object)this;
@Inject(method = "initDynamicTextures", at = @At("TAIL"))
Expand Down Expand Up @@ -84,7 +83,7 @@ private void adjustAtlasSize(BufferedImage img, int id, boolean mipmap, Callback
Buffer.put(resizedAtlas);
GL11.glTexImage2D(3553, 0, 6408, w, h, 0, 6408, 5121, Buffer.buffer);
if (mipmap) {
this.generateMipmaps(Buffer.buffer, resizedAtlas, this.mc.gameSettings.mipmapLevels.value, this.mc.gameSettings.mipmapType.value == MipmapType.SMOOTH);
this.generateMipmaps(Buffer.buffer, resizedAtlas, mc.gameSettings.mipmapLevels.value, mc.gameSettings.mipmapType.value == MipmapType.SMOOTH);
}
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void spawnParticle(String particle, double x, double y, double z, double
double maxDistance = 16.0;

if (!(distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ > maxDistance * maxDistance)) {
Map<String, Class<? extends EntityFX>> particles = (Map<String, Class<? extends EntityFX>>) ParticleHelper.particles;
Map<String, Class<? extends EntityFX>> particles = ParticleHelper.particles;
for (String name : particles.keySet()) {
if (name.equals(particle)) {
Class<? extends EntityFX> clazz = particles.get(name);
Expand Down

0 comments on commit b99e226

Please sign in to comment.