Compare commits

..
Author SHA1 Message Date
Martin Robertz af5b351dcf update 2025-07-01 13:16:56 +02:00
JohnButlerThird b70e830b86 Load after salisarcana 2025-06-30 17:49:41 -04:00
JohnButlerThird df1dd32506 spotlessApply 2025-06-30 17:28:32 -04:00
JohnButlerThird 33a55876a4 Added Thaumcraft compat 2025-06-30 17:21:40 -04:00
JohnButlerThird 0850d9a1a9 Updated textures + recipes 2025-06-30 01:14:38 -04:00
JohnButlerThird 2dbc003643 Added BOP support 2025-06-27 03:16:22 -04:00
3377 changed files with 581 additions and 4440 deletions

No files matched your search

+2 -2
View File
@@ -3,9 +3,9 @@ name: Build and test
on:
pull_request:
branches: [ master, main, release/** ]
branches: [ master, main ]
push:
branches: [ master, main, release/** ]
branches: [ master, main ]
jobs:
build-and-test:
-17
View File
@@ -1,17 +0,0 @@
name: Optimize images
on:
pull_request:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
push:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
jobs:
optimize-images:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
secrets: inherit
+1 -1
View File
@@ -25,6 +25,6 @@ whitelist.json
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
*.bat
layout.json
.DS_Store
-1
View File
@@ -1,6 +1,5 @@
Contributing
============
Before contributing, make sure you're familiar with the [GT:NH Contribution Guidelines](https://github.com/GTNewHorizons/.github/blob/master/CONTRIBUTING.md)
___
Setting up a Development Environment
------------------------------------
+5 -5
View File
@@ -1,14 +1,14 @@
// Add your dependencies here
dependencies {
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.84-GTNH:dev")
implementation("com.github.GTNewHorizons:ForgeMultipart:1.7.3:dev")
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.3:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.60-GTNH:dev")
implementation("com.github.GTNewHorizons:ForgeMultipart:1.6.6:dev")
compileOnly("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24")
devOnlyNonPublishable("com.github.GTNewHorizons:waila:1.19.22:dev") {
devOnlyNonPublishable("com.github.GTNewHorizons:waila:1.8.10:dev") {
transitive = false
}
devOnlyNonPublishable("com.github.GTNewHorizons:WailaHarvestability:1.3.4-GTNH:dev")
@@ -17,7 +17,7 @@ dependencies {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Angelica:2.1.15:api") {
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta47:api") {
transitive = false
}
}
+9 -49
View File
@@ -39,37 +39,13 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
@@ -107,7 +83,7 @@ apiPackage = api
accessTransformersFile = chisel_compile_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = true
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.
@@ -115,15 +91,13 @@ usesMixins = true
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = true
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage = mixins
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
@@ -177,7 +151,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
@@ -186,11 +160,6 @@ modrinthRelations =
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# Comma-separated supported CurseForge environments: client, server (case-insensitive).
# Use client or server for mods that only support one environment. Defaults to client,server.
# These tags describe where the mod can run, not whether installation is required on both sides.
curseForgeEnvironments = client,server
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
@@ -203,12 +172,6 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
@@ -238,6 +201,3 @@ curseForgeRelations =
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
# Non-GTNH properties
org.gradle.configuration-cache = true
org.gradle.parallel = true
-12
View File
@@ -1,12 +0,0 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9064f22734b42ac03e85df04b632e167/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/4d0277c49991306ac78048580fe34bcf/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a9fa3b809e484a1e1ac4308a5dda661a/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/aa99913fa6d767d899ffc96082da01ca/redirect
toolchainVersion=25
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+6 -3
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -114,6 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -171,6 +172,7 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -210,7 +212,8 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -1
View File
@@ -70,10 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.32'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
}
@@ -1,34 +0,0 @@
package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
/**
* To be implemented on an {@link IBlockAccess} that renders blocks which are only part of a block space, so it can
* decide connected textures itself instead of reporting the blocks around it.
* <p>
* Connected textures ask this for every location they check, while rendering in this world. Render bounds smaller than
* the block are then a part of the block: they show the matching part of the block's connected texture, instead of the
* whole texture squeezed into the bounds.
*/
public interface IConnectionAccess {
/**
* Whether the given location shows the block being rendered, as seen from the block being rendered.
*
* @param x X coord of the block to check against. NOT the position of the block being rendered.
* @param y Y coord of the block to check against.
* @param z Z coord of the block to check against.
* @param side The side being rendered, NOT the side being connected from.
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @param fromX X coord of the block being rendered. It is not necessarily adjacent, it can also be diagonal to the
* location.
* @param fromY Y coord of the block being rendered.
* @param fromZ Z coord of the block being rendered.
* @param block The block being rendered.
* @param meta The metadata of the block being rendered.
* @return True if the location shows the given block and metadata.
*/
boolean matches(int x, int y, int z, int side, int fromX, int fromY, int fromZ, Block block, int meta);
}
@@ -36,57 +36,4 @@ public interface IFacade {
* @return The metadata of your facade block.
*/
int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
/**
* Gets the block this facade is acting as towards the block that is checking for a connection. Implement this if
* the facade can show different blocks to different neighbours.
* <p>
* Defaults to {@link #getFacade(IBlockAccess, int, int, int, int)}.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @param fromX X coord of the block being rendered, which is checking for a connection. NOT the position of
* your block. It is not necessarily adjacent, it can also be diagonal to your block.
* @param fromY Y coord of the block being rendered.
* @param fromZ Z coord of the block being rendered.
* @param fromBlock The block being rendered.
* @param fromMeta The metadata of the block being rendered.
* @return The block inside of your facade block, as seen from the block being rendered.
*/
default Block getFacade(IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY, int fromZ,
Block fromBlock, int fromMeta) {
return getFacade(world, x, y, z, side);
}
/**
* Gets the metadata of the block that this facade is acting as towards the block that is checking for a
* connection. Implement this together with
* {@link #getFacade(IBlockAccess, int, int, int, int, int, int, int, Block, int)}.
* <p>
* Defaults to {@link #getFacadeMetadata(IBlockAccess, int, int, int, int)}.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @param fromX X coord of the block being rendered, which is checking for a connection. NOT the position of
* your block. It is not necessarily adjacent, it can also be diagonal to your block.
* @param fromY Y coord of the block being rendered.
* @param fromZ Z coord of the block being rendered.
* @param fromBlock The block being rendered.
* @param fromMeta The metadata of the block being rendered.
* @return The metadata of your facade block, as seen from the block being rendered.
*/
default int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY, int fromZ,
Block fromBlock, int fromMeta) {
return getFacadeMetadata(world, x, y, z, side);
}
}
@@ -14,10 +14,10 @@ import team.chisel.ctmlib.ISubmapManager;
public class VariationInfoBase implements IVariationInfo {
private final ICarvingVariation variation;
private final String unlocDesc;
private final ISubmapManager manager;
private final TextureType type;
private ICarvingVariation variation;
private String unlocDesc;
private ISubmapManager manager;
private TextureType type;
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) {
this(variation, unlocDesc, manager, TextureType.CUSTOM);
@@ -6,11 +6,6 @@ import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.resources.FallbackResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
@@ -23,7 +18,6 @@ import org.apache.commons.lang3.tuple.Triple;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.CTM;
@@ -31,7 +25,6 @@ import team.chisel.ctmlib.ISubmapManager;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.RenderBlocksColumn;
import team.chisel.ctmlib.TextureSubmap;
import team.chisel.ctmlib.TextureSubmapCTM;
/**
* Handles all default {@link ISubmapManager} behavior
@@ -91,15 +84,15 @@ public enum TextureType {
return data.getRight();
Block block = world.getBlock(x, y, z);
boolean topConnected = ctm.isConnected(world, x, y + 1, z, side, x, y, z, block, meta);
boolean botConnected = ctm.isConnected(world, x, y - 1, z, side, x, y, z, block, meta);
boolean topConnected = ctm.isConnected(world, x, y + 1, z, side, block, meta);
boolean botConnected = ctm.isConnected(world, x, y - 1, z, side, block, meta);
TextureSubmap map = data.getLeft();
if (topConnected && botConnected)
return map.getSubIcon(0, 1);
if (topConnected)
if (topConnected && !botConnected)
return map.getSubIcon(1, 1);
if (botConnected)
if (!topConnected && botConnected)
return map.getSubIcon(1, 0);
return map.getSubIcon(0, 0);
}
@@ -107,9 +100,11 @@ public enum TextureType {
@Override
@SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
TextureType.initStatics();
RenderBlocksColumn ret = theRenderBlocksColumn.get();
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
ret.blockAccess = world;
ret.renderMaxX = 1.0;
ret.renderMaxY = 1.0;
ret.renderMaxZ = 1.0;
@@ -143,11 +138,11 @@ public enum TextureType {
boolean reverse = side == 3 || side == 4;
if (side < 4) {
p = ctm.isConnected(world, x - 1, y, z, side, x, y, z, block, meta);
n = ctm.isConnected(world, x + 1, y, z, side, x, y, z, block, meta);
p = ctm.isConnected(world, x - 1, y, z, side, block, meta);
n = ctm.isConnected(world, x + 1, y, z, side, block, meta);
} else {
p = ctm.isConnected(world, x, y, z - 1, side, x, y, z, block, meta);
n = ctm.isConnected(world, x, y, z + 1, side, x, y, z, block, meta);
p = ctm.isConnected(world, x, y, z - 1, side, block, meta);
n = ctm.isConnected(world, x, y, z + 1, side, block, meta);
}
TextureSubmap map = data.getLeft();
@@ -198,8 +193,8 @@ public enum TextureType {
IIcon baseIcon = register.registerIcon(modName + ":" + texturePath);
return Triple.of(
baseIcon,
new TextureSubmapCTM(register.registerIcon(modName + ":" + texturePath + "-ctm"), 4),
new TextureSubmapCTM(baseIcon, 2)
new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctm"), 4, 4),
new TextureSubmap(baseIcon, 2, 2)
);
}
@@ -211,12 +206,15 @@ public enum TextureType {
@Override
@SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
TextureType.initStatics();
RenderBlocksCTM ret = theRenderBlocksCTM.get();
Triple<?, TextureSubmap, TextureSubmap> data = (Triple<?, TextureSubmap, TextureSubmap>) cachedObject;
ret.blockAccess = world;
ret.submap = data.getMiddle();
ret.submapSmall = data.getRight();
ret.rendererOld = rendererOld;
return ret;
}
},
@@ -273,8 +271,6 @@ public enum TextureType {
CUSTOM;
/* Some util stuff for shared code between v* and r* */
public static final boolean fixedBottomFaceUV = (boolean) Launch.blackboard
.getOrDefault("hodgepodge.FixesConfig.fixBottomFaceUV", Boolean.FALSE);
public static IIcon getVIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
int variationSize = (type == TextureType.V9) ? 3 : 2;
@@ -295,9 +291,6 @@ public enum TextureType {
//For DOWN, reverse the indexes for only Z
textureZ = (variationSize - textureZ - 1);
}*/
else if (side == 0 && fixedBottomFaceUV) {
textureX = variationSize - textureX - 1;
}
int index;
if (side == 0 || side == 1) {
@@ -333,18 +326,33 @@ public enum TextureType {
private static final TextureType[] VALUES;
private static final CTM ctm = CTM.getInstance();
private static final Random rand = new Random();
private static final ThreadLocal<RenderBlocksCTM> theRenderBlocksCTM = FMLLaunchHandler.side().isClient() ? ThreadLocal.withInitial(RenderBlocksCTM::new) : null;
private static final ThreadLocal<RenderBlocksColumn> theRenderBlocksColumn = FMLLaunchHandler.side().isClient() ? ThreadLocal.withInitial(RenderBlocksColumn::new) : null;
@SideOnly(Side.CLIENT)
private static ThreadLocal<RenderBlocksCTM> theRenderBlocksCTM;
@SideOnly(Side.CLIENT)
private static ThreadLocal<RenderBlocksColumn> theRenderBlocksColumn;
private final String[] suffixes;
private String[] suffixes;
static {
VALUES = ArrayUtils.subarray(values(), 0, values().length - 1);
}
TextureType(String... suffixes) {
private TextureType(String... suffixes) {
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
}
private static void initStatics() {
if (theRenderBlocksCTM == null) {
theRenderBlocksCTM = ThreadLocal.withInitial(RenderBlocksCTM::new);
theRenderBlocksColumn = ThreadLocal.withInitial(RenderBlocksColumn::new);
}
}
@SideOnly(Side.CLIENT)
public static void clearStatics() {
if(theRenderBlocksCTM != null) theRenderBlocksCTM.remove();
if(theRenderBlocksColumn != null) theRenderBlocksColumn.remove();
}
public ISubmapManager createManagerFor(ICarvingVariation variation, String texturePath) {
return new SubmapManagerDefault(this, variation, texturePath);
}
@@ -389,25 +397,11 @@ public enum TextureType {
return CUSTOM;
}
// This is ugly, but faster than class.getResource
private static boolean exists(String modid, String path, String postfix) {
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
final IResourceManager resMan = Minecraft.getMinecraft().getResourceManager();
if (resMan instanceof SimpleReloadableResourceManager simple) {
FallbackResourceManager fallback = (FallbackResourceManager)simple.domainResourceManagers.get(rl.getResourceDomain());
if (fallback != null) {
for (Object obj : fallback.resourcePacks) {
if (obj instanceof IResourcePack rp && rp.resourceExists(rl)) {
return true;
}
}
return false;
}
}
// Fallback
try {
resMan.getAllResources(rl);
Minecraft.getMinecraft().getResourceManager().getAllResources(rl);
return true;
} catch (Throwable t) {
return false;
@@ -1,63 +0,0 @@
package com.cricketcraft.chisel.mixins;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.resources.FallbackResourceManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import team.chisel.ctmlib.TextureSubmapResource;
/**
* Provides generated resources for independently stitched CTM submap sprites.
* <p>
* For example, a request for chisel:textures/blocks/__chisel_submap/2x2/1_0/foo.png is resolved from
* chisel:textures/blocks/foo.png and cropped to its top-right tile. This lets Minecraft and other mods treat each
* submap sprite like an ordinary texture resource.
*/
@Mixin(FallbackResourceManager.class)
public abstract class MixinFallbackResourceManager {
@Shadow
public abstract IResource getResource(ResourceLocation location) throws IOException;
@Shadow
public abstract List<IResource> getAllResources(ResourceLocation location) throws IOException;
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
private void chisel$getSubmapResource(ResourceLocation location, CallbackInfoReturnable<IResource> cir)
throws IOException {
TextureSubmapResource.SubmapLocation submap = TextureSubmapResource.parse(location);
if (submap == null) return;
IResource source = getResource(submap.source());
cir.setReturnValue(new TextureSubmapResource(source, submap, true));
}
@Inject(method = "getAllResources", at = @At("HEAD"), cancellable = true)
private void chisel$getAllSubmapResources(ResourceLocation location, CallbackInfoReturnable<List<IResource>> cir)
throws IOException {
TextureSubmapResource.SubmapLocation submap = TextureSubmapResource.parse(location);
if (submap == null) return;
List<IResource> sources = getAllResources(submap.source());
List<IResource> resources = new ArrayList<>(sources.size());
for (IResource source : sources) {
// Different resource packs may provide different images for the same location, so we can't cache them
resources.add(new TextureSubmapResource(source, submap, false));
}
cir.setReturnValue(resources);
}
}
@@ -88,7 +88,6 @@ public class BlockNameConversion {
namingConversion.put("blockFft", "fantasyblock");
namingConversion.put("blockCarpetFloor", "carpet");
namingConversion.put("blockLaboratory", "laboratoryblock");
namingConversion.put("wroughtironblock", "castironblock");
}
public static Item findItem(String oldname) {
+1 -1
View File
@@ -57,7 +57,7 @@ import team.chisel.world.GeneratorChisel;
name = Chisel.MOD_NAME,
version = Chisel.VERSION,
guiFactory = "team.chisel.client.gui.GuiFactory",
dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest;after:BiomesOPlenty")
dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest;after:BiomesOPlenty;after:salisarcana")
public class Chisel {
public static final String MOD_ID = "chisel";
File diff suppressed because it is too large. Load diff
@@ -1,67 +0,0 @@
package team.chisel.block;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockCarvableConcreteSlab extends BlockCarvableSlab {
public BlockCarvableConcreteSlab(BlockCarvable block) {
super(block);
top = new BlockCarvableConcreteSlab(this);
FMLCommonHandler.instance()
.bus()
.register(new EventHandler());
}
// Constructor to get concrete top slabs to work
public BlockCarvableConcreteSlab(BlockCarvableSlab bottomBlock) {
super(bottomBlock);
FMLCommonHandler.instance()
.bus()
.register(new EventHandler());
}
@SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck;
public class EventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient()
&& event.player.onGround
&& event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY) - 2,
MathHelper.floor_double(player.posZ));
if (below == BlockCarvableConcreteSlab.this) {
manualInputCheck.updatePlayerMoveState();
if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) {
player.motionX *= Configurations.concreteVelocityMult + 0.05;
player.motionZ *= Configurations.concreteVelocityMult + 0.05;
}
}
}
}
}
}
@@ -1,79 +0,0 @@
package team.chisel.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockCarvableConcreteStairs extends BlockCarvableStairs {
public BlockCarvableConcreteStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper);
FMLCommonHandler.instance()
.bus()
.register(new EventHandler());
}
// Override super's getSubBlocks to allow concrete's 11 variants
// Stairs are added to the list in pairs, so odd-numbered variant counts create
// a block that shouldn't exist. This modification makes the block unreachable by normal
// means (NEI, creative menu), but still technically exists in-game
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
list.add(new ItemStack(block, 1, 0));
// If odd# of variations && meta for the current block == variation.size - 1, exit
// Second check checks if the current block is at the end of the variation list
if (carverHelper.infoList.size() % 2 == 1 && this.blockMeta == carverHelper.infoList.size() - 1) return;
list.add(new ItemStack(block, 1, 8));
}
@SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck;
public class EventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(TickEvent.PlayerTickEvent event) {
if (event.phase == TickEvent.Phase.START && event.side.isClient()
&& event.player.onGround
&& event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY) - 2,
MathHelper.floor_double(player.posZ));
if (below == BlockCarvableConcreteStairs.this) {
manualInputCheck.updatePlayerMoveState();
if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) {
player.motionX *= Configurations.concreteVelocityMult + 0.05;
player.motionZ *= Configurations.concreteVelocityMult + 0.05;
}
}
}
}
}
}
@@ -33,11 +33,6 @@ public class BlockCarvableGlowstone extends BlockCarvable {
return 0;
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
Block glowstone = world.getBlock(x, y, z);
@@ -6,7 +6,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockSand;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -20,7 +19,6 @@ import com.cricketcraft.chisel.api.rendering.ClientUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class BlockCarvableSand extends BlockSand implements ICarvable {
@@ -85,11 +83,6 @@ public class BlockCarvableSand extends BlockSand implements ICarvable {
return carverHelper.getVariation(meta);
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return Configurations.canMobsSpawnOnTheChiselBlocks;
}
public static class SoundType extends Block.SoundType {
public final String soundNameStep;
@@ -40,7 +40,7 @@ public class BlockCarvableStairs extends BlockStairs implements ICarvable {
@Override
public int damageDropped(int i) {
return i & 0x8;
return i / 8;
}
@Override
@@ -21,34 +21,31 @@ public class BlockConcrete extends BlockCarvable {
super();
FMLCommonHandler.instance()
.bus()
.register(new EventHandler());
.register(this);
}
@SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck;
public class EventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient()
&& event.player.onGround
&& event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY) - 2,
MathHelper.floor_double(player.posZ));
if (below == BlockConcrete.this) {
manualInputCheck.updatePlayerMoveState();
if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) {
player.motionX *= Configurations.concreteVelocityMult + 0.05;
player.motionZ *= Configurations.concreteVelocityMult + 0.05;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient()
&& event.player.onGround
&& event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY) - 2,
MathHelper.floor_double(player.posZ));
if (below == this) {
manualInputCheck.updatePlayerMoveState();
if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) {
player.motionX *= Configurations.concreteVelocityMult + 0.05;
player.motionZ *= Configurations.concreteVelocityMult + 0.05;
}
}
}
@@ -6,7 +6,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -15,8 +14,6 @@ import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.config.Configurations;
public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
public CarvableHelper carverHelper;
@@ -65,9 +62,4 @@ public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return Configurations.canMobsSpawnOnTheChiselBlocks;
}
}
@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.ForgeHooksClient;
import team.chisel.client.render.RendererMultiLayer;
@@ -42,6 +43,7 @@ public abstract class BlockMultiLayerBase extends Block {
@Override
public boolean canRenderInPass(int pass) {
ForgeHooksClient.setRenderPass(pass);
return pass == 1 || pass == 0;
}
@@ -62,7 +62,7 @@ public class BlockRoadLine extends BlockCarvable {
if (par1World.isRemote) return;
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
par1World.setBlockToAir(par2, par3, par4);
}
@@ -37,8 +37,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
STACK,
REVERSION;
public static final Upgrade[] VALUES = values();
public String getUnlocalizedName() {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
return "item.upgrade_" + this.name()
@@ -382,7 +380,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
return itemStack.getItem() instanceof IChiselItem;
default:
return Features.AUTO_CHISEL_UPGRADES.enabled() && itemStack.getItem() == ChiselItems.upgrade
&& Upgrade.VALUES[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
&& Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
}
}
@@ -467,7 +465,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
String unloc = name == null ? null : String.format(base, name);
return StatCollector.translateToLocal(unloc);
} else {
return Upgrade.VALUES[slotNumber - MIN_UPGRADE].getLocalizedName();
return Upgrade.values()[slotNumber - MIN_UPGRADE].getLocalizedName();
}
}
@@ -19,7 +19,11 @@ import team.chisel.ctmlib.Drawing;
@ThreadSafeISBRH(perThread = false)
public class RendererCTMPane implements ISimpleBlockRenderingHandler {
public static final int id = RenderingRegistry.getNextAvailableRenderId();
public static int id;
public RendererCTMPane() {
id = RenderingRegistry.getNextAvailableRenderId();
}
@Override
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
@@ -29,7 +33,7 @@ public class RendererCTMPane implements ISimpleBlockRenderingHandler {
Drawing.drawBlock(block, meta, renderer);
}
static class PaneRenderer {
class PaneRenderer {
double i0u0;
double i0uh;
@@ -27,8 +27,7 @@ public class RendererEldritch implements ISimpleBlockRenderingHandler {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
private static final ThreadLocal<RenderBlocksEldritch> rendererThreadLocal = ThreadLocal
.withInitial(RenderBlocksEldritch::new);
ThreadLocal<RenderBlocksEldritch> rendererThreadLocal = ThreadLocal.withInitial(RenderBlocksEldritch::new);
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
@@ -60,11 +59,7 @@ public class RendererEldritch implements ISimpleBlockRenderingHandler {
renderer.renderMaxX = 1.0;
renderer.renderMaxY = 1.0;
renderer.renderMaxZ = 1.0;
try {
renderer.renderStandardBlock(block, x, y, z);
} finally {
renderer.blockAccess = null;
}
renderer.renderStandardBlock(block, x, y, z);
return true;
/*
@@ -40,28 +40,13 @@ public class RendererLayeredGlow implements ISimpleBlockRenderingHandler {
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
final Tessellator tessellator = Tessellator.instance;
final boolean prevEnableAO = renderer.enableAO;
final int tint = Configurations.configColors[world.getBlockMetadata(x, y, z)];
tessellator.setColorOpaque_I(tint);
tessellator.setColorOpaque_I(Configurations.configColors[world.getBlockMetadata(x, y, z)]);
tessellator.setBrightness(0xF000F0);
setFullbrightColor(renderer, tint);
Drawing.renderAllFaces(renderer, block, x, y, z, ((BlockCarvableGlow) block).getGlowTexture());
renderer.enableAO = prevEnableAO;
renderer.renderStandardBlock(block, x, y, z);
return true;
}
private static void setFullbrightColor(RenderBlocks renderer, int color) {
final float r = (color >> 16 & 255) / 255.0F;
final float g = (color >> 8 & 255) / 255.0F;
final float b = (color & 255) / 255.0F;
renderer.enableAO = true;
renderer.colorRedTopLeft = renderer.colorRedBottomLeft = renderer.colorRedBottomRight = renderer.colorRedTopRight = r;
renderer.colorGreenTopLeft = renderer.colorGreenBottomLeft = renderer.colorGreenBottomRight = renderer.colorGreenTopRight = g;
renderer.colorBlueTopLeft = renderer.colorBlueBottomLeft = renderer.colorBlueBottomRight = renderer.colorBlueTopRight = b;
renderer.brightnessTopLeft = renderer.brightnessBottomLeft = renderer.brightnessTopRight = renderer.brightnessBottomRight = 0xF000F0;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
@@ -14,7 +14,7 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
@@ -28,11 +28,17 @@ public class RendererMultiLayer implements ISimpleBlockRenderingHandler {
final static float bot = -0.001f;
final static float top = 1.0f - bot;
public static final int id = RenderingRegistry.getNextAvailableRenderId();
public static int id;
public RendererMultiLayer() {
id = RenderingRegistry.getNextAvailableRenderId();
}
@Override
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
if (!(blck instanceof BlockMultiLayerBase block)) return;
if (blck == null || !(blck instanceof BlockMultiLayerBase)) return;
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
if (block.icon != null) {
renderer.overrideBlockTexture = block.icon;
@@ -55,9 +61,10 @@ public class RendererMultiLayer implements ISimpleBlockRenderingHandler {
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId,
RenderBlocks renderer) {
if (!(blck instanceof BlockMultiLayerBase block)) return false;
if (blck == null || !(blck instanceof BlockMultiLayerBase)) return false;
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
if (ForgeHooksClient.getWorldRenderPass() == 0) {
if (MinecraftForgeClient.getRenderPass() == 0) {
if (block.icon != null) {
renderer.overrideBlockTexture = block.icon;
renderer.renderStandardBlock(block, x, y, z);
@@ -16,7 +16,11 @@ import team.chisel.ctmlib.Drawing;
@ThreadSafeISBRH(perThread = false)
public class RendererStairs implements ISimpleBlockRenderingHandler {
public static final int id = RenderingRegistry.getNextAvailableRenderId();
public static int id;
public RendererStairs() {
id = RenderingRegistry.getNextAvailableRenderId();
}
@Override
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
@@ -30,7 +34,8 @@ public class RendererStairs implements ISimpleBlockRenderingHandler {
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId,
RenderBlocks renderer) {
if (!(blck instanceof BlockCarvableStairs block)) return false;
if (blck == null || !(blck instanceof BlockCarvableStairs)) return false;
BlockCarvableStairs block = (BlockCarvableStairs) blck;
renderer.renderBlockStairs(block, x, y, z);
@@ -10,13 +10,11 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.Drawing;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.TextureSubmap;
import team.chisel.ctmlib.TextureSubmapCTM;
import team.chisel.init.ChiselBlocks;
public class SubmapManagerAntiblock extends SubmapManagerBase {
@@ -76,10 +74,10 @@ public class SubmapManagerAntiblock extends SubmapManagerBase {
}
};
private static final ThreadLocal<RenderBlocksCTMFullbright> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksCTMFullbright::new) : null;
@SideOnly(Side.CLIENT)
private RenderBlocksCTMFullbright rb;
private final String color;
private String color;
private TextureSubmap submap, submapSmall;
public SubmapManagerAntiblock(String color) {
@@ -94,14 +92,16 @@ public class SubmapManagerAntiblock extends SubmapManagerBase {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(String modName, Block block, IIconRegister register) {
submap = new TextureSubmapCTM(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4);
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2);
submap = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4, 4);
submapSmall = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2, 2);
}
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksCTMFullbright rb = renderBlocksThreadLocal.get();
if (rb == null) {
rb = new RenderBlocksCTMFullbright();
}
rb.setRenderBoundsFromBlock(block);
rb.submap = submap;
rb.submapSmall = submapSmall;
@@ -6,21 +6,19 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.TextureSubmap;
import team.chisel.ctmlib.TextureSubmapCTM;
public class SubmapManagerCarpetFloor extends SubmapManagerBase {
private static final ThreadLocal<RenderBlocksCTM> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksCTM::new) : null;
@SideOnly(Side.CLIENT)
private RenderBlocksCTM rb;
private TextureSubmap submap;
private TextureSubmap submapSmall;
private final String color;
private String color;
public SubmapManagerCarpetFloor(String color) {
this.color = color;
@@ -40,14 +38,16 @@ public class SubmapManagerCarpetFloor extends SubmapManagerBase {
@SideOnly(Side.CLIENT)
public void registerIcons(String modName, Block block, IIconRegister register) {
String path = modName + ":carpet/" + color;
submap = new TextureSubmapCTM(register.registerIcon(path + "-ctm"), 4);
submapSmall = new TextureSubmapCTM(register.registerIcon(path), 2);
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
}
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksCTM rb = renderBlocksThreadLocal.get();
if (rb == null) {
rb = new RenderBlocksCTM();
}
rb.setRenderBoundsFromBlock(block);
rb.submap = submap;
rb.submapSmall = submapSmall;
@@ -3,7 +3,6 @@ package team.chisel.client.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
@@ -15,7 +14,6 @@ import com.cricketcraft.chisel.api.carving.CarvingUtils;
import com.cricketcraft.chisel.api.rendering.TextureType;
import com.cricketcraft.chisel.api.rendering.TextureType.AbstractSubmapManager;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.RenderBlocksCTM;
@@ -80,9 +78,9 @@ public class SubmapManagerCombinedCTM extends SubmapManagerBase {
}
}
private static class Submap extends TextureSubmap {
private class Submap extends TextureSubmap {
private final TextureSubmap[][] submap;
private TextureSubmap[][] submap;
public Submap(IIcon base, int wh, TextureSubmap[][] submap) {
super(base, wh, wh);
@@ -90,22 +88,25 @@ public class SubmapManagerCombinedCTM extends SubmapManagerBase {
}
@Override
public void registerSubIcons(TextureMap textureMap) {
public void texturesStitched() {
for (int i = 0; i < icons.length; i++) {
System.arraycopy(submap[i], 0, icons[i], 0, icons[i].length);
for (int j = 0; j < icons[i].length; j++) {
icons[i][j] = submap[i][j];
submap[i][j].texturesStitched();
}
}
}
}
private final ThreadLocal<RenderBlocksCombinedCTM> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksCombinedCTM::new) : null;
@SideOnly(Side.CLIENT)
private RenderBlocksCTM rb;
private TextureSubmap submap, smallSubmap;
private final int size;
private final String texturePath;
private final int meta;
private int size;
private String texturePath;
private int meta;
private IIcon defaultIcon;
private final TextureType rType;
private TextureType rType;
public SubmapManagerCombinedCTM(int meta, String texturePath, TextureType rType) {
assert rType == TextureType.R16 || rType == TextureType.R9
@@ -117,7 +118,10 @@ public class SubmapManagerCombinedCTM extends SubmapManagerBase {
this.texturePath = texturePath;
this.size = Integer.parseInt(
rType.name()
.substring(1)); // >.>
.substring(
1,
rType.name()
.length())); // >.>
this.rType = rType;
}
@@ -129,7 +133,9 @@ public class SubmapManagerCombinedCTM extends SubmapManagerBase {
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksCombinedCTM rb = renderBlocksThreadLocal.get();
if (rb == null) {
rb = new RenderBlocksCombinedCTM();
}
rb.setRenderBoundsFromBlock(block);
return rb;
}
@@ -7,23 +7,21 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.ISubmapManager;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.TextureSubmap;
import team.chisel.ctmlib.TextureSubmapCTM;
public class SubmapManagerSlab implements ISubmapManager {
private static final ThreadLocal<RenderBlocksCTM> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksCTM::new) : null;
@SideOnly(Side.CLIENT)
private RenderBlocksCTM rb;
private TextureSubmap submap;
private TextureSubmap submapSmall;
private IIcon sideTexture;
private final String texture;
private String texture;
public SubmapManagerSlab(String texture) {
this.texture = texture;
@@ -43,26 +41,42 @@ public class SubmapManagerSlab implements ISubmapManager {
@SideOnly(Side.CLIENT)
public void registerIcons(String modName, Block block, IIconRegister register) {
String path = modName + ":" + texture;
submap = new TextureSubmapCTM(register.registerIcon(path + "-ctm"), 4);
submapSmall = new TextureSubmapCTM(register.registerIcon(path), 2);
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
sideTexture = register.registerIcon(path + "-side");
}
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksCTM rb = renderBlocksThreadLocal.get();
if (rb == null) {
rb = new RenderBlocksCTM();
}
rb.setRenderBoundsFromBlock(block);
rb.submap = submap;
rb.submapSmall = submapSmall;
return rb;
}
@Override
@SideOnly(Side.CLIENT)
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {}
private boolean hadOverride = false;
@Override
@SideOnly(Side.CLIENT)
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {}
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
RenderBlocksCTM rbctm = (RenderBlocksCTM) renderer;
if (side.ordinal() < 2 && !rbctm.rendererOld.hasOverrideBlockTexture()) {
rbctm.rendererOld.setOverrideBlockTexture(sideTexture);
hadOverride = false;
} else {
hadOverride = true;
}
}
@Override
@SideOnly(Side.CLIENT)
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (!hadOverride) {
((RenderBlocksCTM) renderer).rendererOld.clearOverrideBlockTexture();
}
}
}
@@ -6,12 +6,10 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.TextureSubmap;
import team.chisel.ctmlib.TextureSubmapCTM;
public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
@@ -50,11 +48,10 @@ public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
}
};
private static final ThreadLocal<RenderBlocksCTMFullbright> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksCTMFullbright::new) : null;
private RenderBlocksCTMFullbright renderBlocksFullbright;
private final String color;
private final MaterialType materialType;
private String color;
private MaterialType materialType;
private TextureSubmap submap, submapSmall;
public SubmapManagerSpecialMaterial(String color, MaterialType materialType) {
@@ -72,14 +69,16 @@ public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
public void registerIcons(String modName, Block block, IIconRegister register) {
String materialName = materialType.name()
.toLowerCase();
submap = new TextureSubmapCTM(register.registerIcon(modName + ":" + materialName + "/" + color + "-ctm"), 4);
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":" + materialName + "/" + color), 2);
submap = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color + "-ctm"), 4, 4);
submapSmall = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color), 2, 2);
}
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksCTMFullbright renderBlocksFullbright = renderBlocksThreadLocal.get();
if (renderBlocksFullbright == null) {
renderBlocksFullbright = new RenderBlocksCTMFullbright();
}
renderBlocksFullbright.setRenderBoundsFromBlock(block);
renderBlocksFullbright.submap = submap;
renderBlocksFullbright.submapSmall = submapSmall;
@@ -11,7 +11,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.carving.CarvingUtils;
import com.cricketcraft.chisel.api.rendering.TextureType;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.ISubmapManager;
@@ -22,81 +21,81 @@ public class SubmapManagerVoidstone extends SubmapManagerBase {
// TODO there must be a better more generic way to do this...
@SideOnly(Side.CLIENT)
private static class RenderBlocksVoidstone extends RenderBlocksCTM {
private class RenderBlocksVoidstone extends RenderBlocksCTM {
@Override
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceXNeg(block, x, y, z, icon);
renderMinX += 0.001;
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.WEST.ordinal()));
super.renderFaceXNeg(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceXNeg(block, x, y, z, icon);
}
@Override
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceXPos(block, x, y, z, icon);
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.EAST.ordinal()));
renderMaxX -= 0.001;
super.renderFaceXPos(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceXPos(block, x, y, z, icon);
}
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceYNeg(block, x, y, z, icon);
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.DOWN.ordinal()));
renderMinY += 0.001;
super.renderFaceYNeg(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceYNeg(block, x, y, z, icon);
}
@Override
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceYPos(block, x, y, z, icon);
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.UP.ordinal()));
renderMaxY -= 0.001;
super.renderFaceYPos(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceYPos(block, x, y, z, icon);
}
@Override
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceZNeg(block, x, y, z, icon);
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.NORTH.ordinal()));
renderMinZ += 0.001;
super.renderFaceZNeg(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceZNeg(block, x, y, z, icon);
}
@Override
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceZPos(block, x, y, z, icon);
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.SOUTH.ordinal()));
renderMaxZ -= 0.001;
super.renderFaceZPos(block, x, y, z, null);
clearOverrideBlockTexture();
super.renderFaceZPos(block, x, y, z, icon);
}
private IIcon getBase(double x, double y, double z, int side) {
return TextureType.getVIcon(
TextureType.V4,
base,
MathHelper.floor_double(x),
MathHelper.floor_double(y),
MathHelper.floor_double(z),
side);
}
}
private static final ThreadLocal<RenderBlocksVoidstone> renderBlocksThreadLocal = FMLLaunchHandler.side()
.isClient() ? ThreadLocal.withInitial(RenderBlocksVoidstone::new) : null;
@SideOnly(Side.CLIENT)
private RenderBlocksVoidstone rb;
private ISubmapManager overlay;
private static TextureSubmap base;
private TextureSubmap base;
private final String texture;
private final int meta;
private IIcon getBase(double x, double y, double z, int side) {
return TextureType.getVIcon(
TextureType.V4,
base,
MathHelper.floor_double(x),
MathHelper.floor_double(y),
MathHelper.floor_double(z),
side);
}
private String texture;
private int meta;
public SubmapManagerVoidstone(String texture, int meta) {
this.texture = texture;
@@ -124,18 +123,15 @@ public class SubmapManagerVoidstone extends SubmapManagerBase {
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
RenderBlocksVoidstone rb = renderBlocksThreadLocal.get();
if (rb == null) {
rb = new RenderBlocksVoidstone();
}
RenderBlocks ctx = overlay.createRenderContext(rendererOld, block, world);
rb.setRenderBoundsFromBlock(block);
if (ctx instanceof RenderBlocksCTM) {
rb.submap = ((RenderBlocksCTM) ctx).submap;
rb.submapSmall = ((RenderBlocksCTM) ctx).submapSmall;
} else {
rb.submap = null;
rb.submapSmall = null;
}
return rb;
}
}
@@ -26,7 +26,7 @@ public class RenderCarvableBeacon extends TileEntityBeaconRenderer implements IS
private static final ResourceLocation texture = new ResourceLocation("textures/entity/beacon_beam.png");
private final int renderId;
private int renderId;
public RenderCarvableBeacon() {
this.renderId = RenderingRegistry.getNextAvailableRenderId();
@@ -25,7 +25,6 @@ public class NEIChiselConfig implements IConfigureNEI {
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "limestone_slab_top")));
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_slab_top")));
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_pillar_slab_top")));
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "concrete_slab_top")));
RecipeHandlerChisel handler = new RecipeHandlerChisel();
API.registerRecipeHandler(handler);
@@ -303,7 +303,7 @@ public class Configurations {
}
/* features */
for (Features feature : Features.VALUES) {
for (Features feature : Features.values()) {
features.put(
featureName(feature),
config.get("features", featureName(feature), true)
+24 -78
View File
@@ -16,7 +16,6 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.IConnectable;
import com.cricketcraft.chisel.api.IConnectionAccess;
import com.cricketcraft.chisel.api.IFacade;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
@@ -192,30 +191,24 @@ public class CTM {
}
/**
* A check for if the block being rendered can connect to the given location on the given side. Passes the block
* being rendered on to {@link IFacade} blocks, so they can decide per neighbour.
* A simple check for if the given block can connect to the given direction on the given side.
*
* @param world
* @param x The x coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param y The y coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param z The z coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param side The side of the block to check for connection status. This is <i>not</i> the direction to check in.
* @param fromX The x coordinate of your block, the block being rendered.
* @param fromY The y coordinate of your block, the block being rendered.
* @param fromZ The z coordinate of your block, the block being rendered.
* @param block The block being rendered.
* @param meta The metadata of the block being rendered.
* @param block The block to check against for connection.
* @param meta The metadata to check against for connection.
* @return True if the given block can connect to the given location on the given side.
*/
public boolean isConnected(IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY, int fromZ,
Block block, int meta) {
public boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
return isConnected(world, x, y, z, dir, fromX, fromY, fromZ, block, meta);
return isConnected(world, x, y, z, dir, block, meta);
}
/**
* A check for if the block being rendered can connect to the given location on the given side. Passes the block
* being rendered on to {@link IFacade} blocks, so they can decide per neighbour.
* A simple check for if the given block can connect to the given direction on the given side.
*
* @param world
* @param x The x coordinate of the block to check <i>against</i>. This is not the position of your block.
@@ -223,72 +216,41 @@ public class CTM {
* @param z The z coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param dir The {@link ForgeDirection side} of the block to check for connection status. This is <i>not</i> the
* direction to check in.
* @param fromX The x coordinate of your block, the block being rendered.
* @param fromY The y coordinate of your block, the block being rendered.
* @param fromZ The z coordinate of your block, the block being rendered.
* @param block The block being rendered.
* @param meta The metadata of the block being rendered.
* @param block The block to check against for connection.
* @param meta The metadata to check against for connection.
* @return True if the given block can connect to the given location on the given side.
*/
public boolean isConnected(IBlockAccess world, int x, int y, int z, ForgeDirection dir, int fromX, int fromY,
int fromZ, Block block, int meta) {
public boolean isConnected(IBlockAccess world, int x, int y, int z, ForgeDirection dir, Block block, int meta) {
if (CTMLib.chiselLoaded() && connectionBlocked(world, x, y, z, dir.ordinal())) {
return false;
}
if (!matches(world, x, y, z, dir.ordinal(), fromX, fromY, fromZ, block, meta)) {
return false;
}
if (disableObscuredFaceCheck.or(disableObscuredFaceCheckConfig)) {
return true;
}
// check that we aren't already connected outwards from this side
int x2 = x + dir.offsetX;
int y2 = y + dir.offsetY;
int z2 = z + dir.offsetZ;
return !matches(world, x2, y2, z2, dir.ordinal(), fromX, fromY, fromZ, block, meta);
}
/**
* Whether the given location shows the block being rendered, as seen from the block being rendered. Asks the world
* if it is an {@link IConnectionAccess}, otherwise compares the block or {@link IFacade} at that location.
*
* @param world
* @param x The x coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param y The y coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param z The z coordinate of the block to check <i>against</i>. This is not the position of your block.
* @param side The side being rendered. -1 for unknown.
* @param fromX The x coordinate of your block, the block being rendered.
* @param fromY The y coordinate of your block, the block being rendered.
* @param fromZ The z coordinate of your block, the block being rendered.
* @param block The block being rendered.
* @param meta The metadata of the block being rendered.
* @return True if the given location shows the given block and metadata.
*/
public boolean matches(IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY, int fromZ,
Block block, int meta) {
if (CTMLib.chiselLoaded()) {
return matchesAccess(world, x, y, z, side, fromX, fromY, fromZ, block, meta);
}
return block.equals(world.getBlock(x, y, z)) && world.getBlockMetadata(x, y, z) == meta;
}
boolean disableObscured = disableObscuredFaceCheck.or(disableObscuredFaceCheckConfig);
private boolean matchesAccess(IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY, int fromZ,
Block block, int meta) {
if (world instanceof IConnectionAccess) {
return ((IConnectionAccess) world).matches(x, y, z, side, fromX, fromY, fromZ, block, meta);
}
Block blk = world.getBlock(x, y, z);
Block con = getFacade(blk, world, x, y, z, side, fromX, fromY, fromZ, block, meta);
Block con = getBlockOrFacade(world, x, y, z, dir.ordinal());
Block obscuring = disableObscured ? null : getBlockOrFacade(world, x2, y2, z2, dir.ordinal());
// no block or a bad API user
if (con == null) {
return false;
}
return con.equals(block) && getFacadeMeta(blk, world, x, y, z, side, fromX, fromY, fromZ, block, meta) == meta;
boolean ret = con.equals(block) && getBlockOrFacadeMetadata(world, x, y, z, dir.ordinal()) == meta;
// no block obscuring this face
if (obscuring == null) {
return ret;
}
// check that we aren't already connected outwards from this side
ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, dir.ordinal()) == meta);
return ret;
}
private boolean connectionBlocked(IBlockAccess world, int x, int y, int z, int side) {
@@ -348,20 +310,4 @@ public class CTM {
}
return blk;
}
private int getFacadeMeta(Block blk, IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY,
int fromZ, Block fromBlock, int fromMeta) {
if (blk instanceof IFacade) {
return ((IFacade) blk).getFacadeMetadata(world, x, y, z, side, fromX, fromY, fromZ, fromBlock, fromMeta);
}
return world.getBlockMetadata(x, y, z);
}
private Block getFacade(Block blk, IBlockAccess world, int x, int y, int z, int side, int fromX, int fromY,
int fromZ, Block fromBlock, int fromMeta) {
if (blk instanceof IFacade) {
blk = ((IFacade) blk).getFacade(world, x, y, z, side, fromX, fromY, fromZ, fromBlock, fromMeta);
}
return blk;
}
}
@@ -2,7 +2,6 @@ package team.chisel.ctmlib;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
@@ -28,38 +27,29 @@ public class CTMRenderer implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
final WorldClient world = Minecraft.getMinecraft().theWorld;
final RenderBlocks rb = getContext(renderer, block, world, ((ICTMBlock<?>) block).getManager(metadata));
boolean clean = false;
if (rb.blockAccess == null) {
rb.blockAccess = world;
clean = true;
}
try {
Drawing.drawBlock(block, metadata, rb);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
rb.unlockBlockBounds();
} finally {
if (clean) rb.blockAccess = null;
}
RenderBlocks rb = getContext(
renderer,
block,
Minecraft.getMinecraft().theWorld,
((ICTMBlock<?>) block).getManager(metadata),
metadata);
Drawing.drawBlock(block, metadata, rb);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
rb.unlockBlockBounds();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
final int meta = world.getBlockMetadata(x, y, z);
final RenderBlocks rb = getContext(
renderer,
block,
world,
((ICTMBlock<?>) block).getManager(world, x, y, z, meta));
boolean clean = false;
if (rb.blockAccess == null) {
rb.blockAccess = world;
clean = true;
}
RenderBlocks rendererOld) {
try {
rb.renderAllFaces = renderer.renderAllFaces;
int meta = world.getBlockMetadata(x, y, z);
RenderBlocks rb = getContext(
rendererOld,
block,
world,
((ICTMBlock<?>) block).getManager(world, x, y, z, meta),
meta);
rb.renderAllFaces = rendererOld.renderAllFaces;
boolean ret = rb.renderStandardBlock(block, x, y, z);
rb.unlockBlockBounds();
rb.renderAllFaces = false;
@@ -70,15 +60,15 @@ public class CTMRenderer implements ISimpleBlockRenderingHandler {
crashreportcategory.addCrashSection("Block name", GameRegistry.findUniqueIdentifierFor(block));
crashreportcategory.addCrashSection("Block metadata", world.getBlockMetadata(x, y, z));
throw new ReportedException(crashreport);
} finally {
if (clean) rb.blockAccess = null;
}
}
private RenderBlocks getContext(RenderBlocks rendererOld, Block block, IBlockAccess world, ISubmapManager manager) {
protected RenderBlocks getContext(RenderBlocks rendererOld, Block block, IBlockAccess world, ISubmapManager manager,
int meta) {
if (!rendererOld.hasOverrideBlockTexture() && manager != null) {
RenderBlocks rb = manager.createRenderContext(rendererOld, block, world);
if (rb != null && rb != rendererOld) {
rb.blockAccess = world;
if (rendererOld.lockBlockBounds) {
rb.overrideBlockBounds(
rendererOld.renderMinX,
@@ -88,8 +78,10 @@ public class CTMRenderer implements ISimpleBlockRenderingHandler {
rendererOld.renderMaxY,
rendererOld.renderMaxZ);
}
if (rb instanceof RenderBlocksCTM rbctm) {
if (rb instanceof RenderBlocksCTM) {
RenderBlocksCTM rbctm = (RenderBlocksCTM) rb;
rbctm.manager = rbctm.manager == null ? manager : rbctm.manager;
rbctm.rendererOld = rbctm.rendererOld == null ? rendererOld : rbctm.rendererOld;
}
return rb;
}
+1 -4
View File
@@ -61,15 +61,12 @@ public enum Dir {
public boolean isConnected(CTM inst, IBlockAccess world, int x, int y, int z, int sideIdx, Block block, int meta) {
ForgeDirection side = getOrientation(sideIdx);
ForgeDirection[] dirs = getNormalizedDirs(side);
int fromX = x;
int fromY = y;
int fromZ = z;
for (ForgeDirection dir : dirs) {
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
}
return inst.isConnected(world, x, y, z, side, fromX, fromY, fromZ, block, meta);
return inst.isConnected(world, x, y, z, side, block, meta);
}
private ForgeDirection[] getNormalizedDirs(ForgeDirection normal) {
@@ -58,8 +58,6 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.IConnectionAccess;
import lombok.Getter;
public class RenderBlocksCTM extends RenderBlocks {
@@ -104,56 +102,30 @@ public class RenderBlocksCTM extends RenderBlocks {
XZ_HALF_Y(0.5, 1, 0.5);
// @formatter:on
private final double x, y, z;
private double x, y, z;
Vert(double x, double y, double z) {
private Vert(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
double get(int axis) {
return axis == 0 ? x : axis == 1 ? y : z;
}
private static double u, v, xDiff, yDiff, zDiff, uDiff, vDiff;
void render(RenderBlocksCTM inst, SubSide side, int cacheID) {
void render(RenderBlocksCTM inst, ForgeDirection normal, int cacheID) {
final Tessellator tessellator = Tessellator.instance;
final ForgeDirection normal = side.normal;
if (inst.enableAO) {
tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]);
tessellator.setBrightness(inst.lightingCache[cacheID]);
}
double u = cacheID == 1 || cacheID == 2 ? inst.maxU : inst.minU;
double v = cacheID < 2 ? inst.maxV : inst.minV;
u = cacheID == 1 || cacheID == 2 ? inst.maxU : inst.minU;
v = cacheID < 2 ? inst.maxV : inst.minV;
if (inst.renderPart) {
// only the part inside the bounds, showing the texture where it lies in the block
double px = Math.min(Math.max(x, inst.renderMinX), inst.renderMaxX);
double py = Math.min(Math.max(y, inst.renderMinY), inst.renderMaxY);
double pz = Math.min(Math.max(z, inst.renderMinZ), inst.renderMaxZ);
double uMoved = Math.abs(normal.offsetX != 0 ? pz - z : px - x);
double vMoved = Math.abs(normal.offsetY != 0 ? pz - z : py - y);
// a sub-side is half a block wide
u += (u == inst.minU ? 2 : -2) * (inst.maxU - inst.minU) * uMoved;
v += (v == inst.minV ? 2 : -2) * (inst.maxV - inst.minV) * vMoved;
if (inst.enableAO) {
// the caches hold the light at the sub-side's corners, the vertex moved, so take the light there
double lightX = inst.boundsFraction(side.lightAxisX, px, py, pz);
double lightY = inst.boundsFraction(side.lightAxisY, px, py, pz);
inst.mixLight(side.lightRisingX ? lightX : 1 - lightX, side.lightRisingY ? lightY : 1 - lightY);
}
tessellator.addVertexWithUV(px, py, pz, u, v);
return;
}
uDiff = inst.maxU - inst.minU;
vDiff = inst.maxV - inst.minV;
double uDiff = inst.maxU - inst.minU;
double vDiff = inst.maxV - inst.minV;
double xDiff;
double yDiff;
double zDiff;
if (inst.renderMinX + inst.renderMinY + inst.renderMinZ != 0
|| inst.renderMaxX + inst.renderMaxY + inst.renderMaxZ != 3) {
boolean uMin = u == inst.minU;
@@ -206,11 +178,8 @@ public class RenderBlocksCTM extends RenderBlocks {
YNEG_LB(ZERO, X_HALF, XZ_HALF, Z_HALF), YNEG_RB(X_HALF, X, Z_HALF_X, XZ_HALF), YNEG_RT(XZ_HALF, Z_HALF_X, XZ, X_HALF_Z), YNEG_LT(Z_HALF, XZ_HALF, X_HALF_Z, Z),
YPOS_LB(YZ, X_HALF_YZ, XZ_HALF_Y, Z_HALF_Y), YPOS_RB(X_HALF_YZ, XYZ, Z_HALF_XY, XZ_HALF_Y), YPOS_RT(XZ_HALF_Y, Z_HALF_XY, XY, X_HALF_Y), YPOS_LT(Z_HALF_Y, XZ_HALF_Y, X_HALF_Y, Y);
// @formatter:on
private final Vert xmin, xmax, ymin, ymax;
private final ForgeDirection normal;
/** The block axes the light maps' x and y run along, and whether they run towards 1. */
private final int lightAxisX, lightAxisY;
private final boolean lightRisingX, lightRisingY;
private Vert xmin, xmax, ymin, ymax;
private ForgeDirection normal;
SubSide(Vert xmin, Vert ymin, Vert ymax, Vert xmax) {
this.xmin = xmin;
@@ -218,15 +187,6 @@ public class RenderBlocksCTM extends RenderBlocks {
this.ymax = ymax;
this.xmax = xmax;
this.normal = calcNormal();
// the caches step along the light maps' x from xmin to ymin, and along their y from xmin to xmax
this.lightAxisX = axis(xmin, ymin);
this.lightAxisY = axis(xmin, xmax);
this.lightRisingX = ymin.get(lightAxisX) > xmin.get(lightAxisX);
this.lightRisingY = xmax.get(lightAxisY) > xmin.get(lightAxisY);
}
private static int axis(Vert from, Vert to) {
return from.x != to.x ? 0 : from.y != to.y ? 1 : 2;
}
private ForgeDirection calcNormal() {
@@ -244,10 +204,10 @@ public class RenderBlocksCTM extends RenderBlocks {
}
void render(RenderBlocksCTM inst) {
xmin.render(inst, this, 0);
ymin.render(inst, this, 1);
ymax.render(inst, this, 2);
xmax.render(inst, this, 3);
xmin.render(inst, normal, 0);
ymin.render(inst, normal, 1);
ymax.render(inst, normal, 2);
xmax.render(inst, normal, 3);
}
}
@@ -274,6 +234,7 @@ public class RenderBlocksCTM extends RenderBlocks {
protected float[] bluCache = new float[4];
public TextureSubmap submap;
public TextureSubmap submapSmall;
public RenderBlocks rendererOld;
public ISubmapManager manager;
protected int[][] lightmap = new int[3][3];
@@ -286,12 +247,6 @@ public class RenderBlocksCTM extends RenderBlocks {
@Getter
protected boolean inWorld = false;
/**
* Whether the render bounds are a part of the block, which shows its part of the block's texture instead of the
* whole texture squeezed in. Set when rendering in an {@link IConnectionAccess}.
*/
protected boolean renderPart = false;
@Override
public boolean renderStandardBlock(Block block, int x, int y, int z) {
bx = x;
@@ -302,10 +257,11 @@ public class RenderBlocksCTM extends RenderBlocks {
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addTranslation(x, y, z);
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
setOverrideBlockTexture(rendererOld.overrideBlockTexture);
}
inWorld = true;
renderPart = CTMLib.chiselLoaded() && blockAccess instanceof IConnectionAccess;
boolean res = super.renderStandardBlock(block, x, y, z);
renderPart = false;
inWorld = false;
tessellator.addTranslation(-x, -y, -z);
@@ -403,96 +359,8 @@ public class RenderBlocksCTM extends RenderBlocks {
| ((sunlightBitChannel / lightVals.length) & 0xF00000);
}
/**
* @return where the point lies between the render bounds along the axis, from 0 at their min to 1 at their max
*/
protected double boundsFraction(int axis, double x, double y, double z) {
double min = axis == 0 ? renderMinX : axis == 1 ? renderMinY : renderMinZ;
double max = axis == 0 ? renderMaxX : axis == 1 ? renderMaxY : renderMaxZ;
double pos = axis == 0 ? x : axis == 1 ? y : z;
return max > min ? (pos - min) / (max - min) : 0;
}
/**
* Sets the color and brightness at a point of the face, mixed from the corners of the light maps, which are the
* corners of the render bounds. The point is given in the maps' x and y, from 0 to 1.
*/
protected void mixLight(double x, double y) {
double w00 = (1 - x) * (1 - y);
double w20 = x * (1 - y);
double w22 = x * y;
double w02 = (1 - x) * y;
final Tessellator tessellator = Tessellator.instance;
tessellator.setColorOpaque_F(
mixColor(redmap, w00, w20, w22, w02),
mixColor(grnmap, w00, w20, w22, w02),
mixColor(blumap, w00, w20, w22, w02));
// vanilla mixes the corners of partial bounds the same way
tessellator.setBrightness(
mixAoBrightness(lightmap[0][0], lightmap[2][0], lightmap[2][2], lightmap[0][2], w00, w20, w22, w02));
}
private static float mixColor(float[][] map, double w00, double w20, double w22, double w02) {
return (float) (map[0][0] * w00 + map[2][0] * w20 + map[2][2] * w22 + map[0][2] * w02);
}
protected void side(Block block, SubSide side, int iconIndex) {
// If we have an overridden texture when we're supposed to render a CTM texture,
// we'll treat it as a normal block texture but still render it the CTM way: quarter of a texture at a time.
// This way has one benefit: if an overridden texture is a base block texture and a CTM texture (that is being
// rendered next) is an overlay texture above the base, we're avoiding any z-fighting issues because we
// create identical vertices and now only order of rendering dictates which texture will be rendered above
if (hasOverrideBlockTexture()) {
IIcon icon = overrideBlockTexture;
double u0 = icon.getMinU();
double u1 = icon.getMaxU();
double v0 = icon.getMinV();
double v1 = icon.getMaxV();
double uMid = (u0 + u1) / 2;
double vMid = (v0 + v1) / 2;
// Map all LB-style subsides to bottom-left quarter, RB to bottom-right, RT to top-right, LT to top-left
switch (side) {
// bottom-left quarter
case XNEG_LB, XPOS_LB, YNEG_LB, YPOS_LB, ZNEG_LB, ZPOS_LB -> {
minU = u0;
maxU = uMid;
minV = vMid;
maxV = v1;
}
// bottom-right quarter
case XNEG_RB, XPOS_RB, YNEG_RB, YPOS_RB, ZNEG_RB, ZPOS_RB -> {
minU = uMid;
maxU = u1;
minV = vMid;
maxV = v1;
}
// top-right quarter
case XNEG_RT, XPOS_RT, YNEG_RT, YPOS_RT, ZNEG_RT, ZPOS_RT -> {
minU = uMid;
maxU = u1;
minV = v0;
maxV = vMid;
}
// top-left quarter
case XNEG_LT, XPOS_LT, YNEG_LT, YPOS_LT, ZNEG_LT, ZPOS_LT -> {
minU = u0;
maxU = uMid;
minV = v0;
maxV = vMid;
}
}
side.render(this);
return;
}
IIcon icon;
TextureSubmap map;
if (iconIndex >= 16) {
@@ -510,10 +378,25 @@ public class RenderBlocksCTM extends RenderBlocks {
icon = map.getSubIcon(x, y);
}
minU = icon.getMinU();
maxU = icon.getMaxU();
minV = icon.getMinV();
maxV = icon.getMaxV();
double umax = icon.getMaxU();
double umin = icon.getMinU();
double vmax = icon.getMaxV();
double vmin = icon.getMinV();
minU = umin;
maxU = umax;
minV = vmin;
maxV = vmax;
// uCache[0] = umin;
// uCache[1] = umax;
// uCache[2] = umax;
// uCache[3] = umin;
//
// vCache[0] = vmax;
// vCache[1] = vmax;
// vCache[2] = vmin;
// vCache[3] = vmin;
side.render(this);
}
@@ -521,10 +404,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.WEST);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceXNeg(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
@@ -546,10 +429,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.EAST);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceXPos(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
fillLightmap(brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight, brightnessTopRight);
fillColormap(colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, redmap);
@@ -571,10 +454,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.NORTH);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceZNeg(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
@@ -596,10 +479,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.SOUTH);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceZPos(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
@@ -621,10 +504,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.DOWN);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceYNeg(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
@@ -646,10 +529,10 @@ public class RenderBlocksCTM extends RenderBlocks {
@Override
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
pre(ForgeDirection.UP);
if (!inWorld || submap == null) {
if (!inWorld || hasOverrideBlockTexture() || submap == null) {
super.renderFaceYPos(block, 0, 0, 0, icon);
} else {
int[] tex = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
fillLightmap(brightnessTopRight, brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight);
fillColormap(colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, redmap);
@@ -16,15 +16,16 @@ public class RenderBlocksColumn extends RenderBlocks {
public IIcon iconTop;
private boolean inWorld;
private final IIcon[] sides = new IIcon[6];
private final CTM ctm = CTM.getInstance();
private IIcon sides[] = new IIcon[6];
private CTM ctm = CTM.getInstance();
public RenderBlocksColumn() {
super();
}
boolean connected(IBlockAccess world, int x, int y, int z, int fromX, int fromY, int fromZ, Block block, int meta) {
return ctm.matches(world, x, y, z, -1, fromX, fromY, fromZ, block, meta);
boolean connected(IBlockAccess world, int x, int y, int z, Block block, int meta) {
Block inWorld = ctm.getBlockOrFacade(world, x, y, z, -1);
return inWorld != null && inWorld.equals(block) && ctm.getBlockOrFacadeMetadata(world, x, y, z, -1) == meta;
}
@Override
@@ -32,8 +33,8 @@ public class RenderBlocksColumn extends RenderBlocks {
int metadata = blockAccess.getBlockMetadata(x, y, z);
inWorld = true;
boolean yp = connected(blockAccess, x, y + 1, z, x, y, z, block, metadata);
boolean yn = connected(blockAccess, x, y - 1, z, x, y, z, block, metadata);
boolean yp = connected(blockAccess, x, y + 1, z, block, metadata);
boolean yn = connected(blockAccess, x, y - 1, z, block, metadata);
if (yp || yn) {
sides[0] = iconTop;
@@ -45,13 +46,13 @@ public class RenderBlocksColumn extends RenderBlocks {
sides[3] = sides[4] = sides[5] = sides[2];
} else {
boolean xp = connected(blockAccess, x + 1, y, z, x, y, z, block, metadata);
boolean xn = connected(blockAccess, x - 1, y, z, x, y, z, block, metadata);
boolean xp = connected(blockAccess, x + 1, y, z, block, metadata);
boolean xn = connected(blockAccess, x - 1, y, z, block, metadata);
if (xp && (connected(blockAccess, x + 1, y + 1, z, x + 1, y, z, block, metadata)
|| connected(blockAccess, x + 1, y - 1, z, x + 1, y, z, block, metadata))) xp = false;
if (xn && (connected(blockAccess, x - 1, y + 1, z, x - 1, y, z, block, metadata)
|| connected(blockAccess, x - 1, y - 1, z, x - 1, y, z, block, metadata))) xn = false;
if (xp && (connected(blockAccess, x + 1, y + 1, z, block, metadata)
|| connected(blockAccess, x + 1, y - 1, z, block, metadata))) xp = false;
if (xn && (connected(blockAccess, x - 1, y + 1, z, block, metadata)
|| connected(blockAccess, x - 1, y - 1, z, block, metadata))) xn = false;
if (xp || xn) {
uvRotateEast = 2;
@@ -75,17 +76,17 @@ public class RenderBlocksColumn extends RenderBlocks {
}
sides[2] = sides[3] = sides[1];
} else {
boolean zp = connected(blockAccess, x, y, z + 1, x, y, z, block, metadata);
boolean zn = connected(blockAccess, x, y, z - 1, x, y, z, block, metadata);
boolean zp = connected(blockAccess, x, y, z + 1, block, metadata);
boolean zn = connected(blockAccess, x, y, z - 1, block, metadata);
if (zp && (connected(blockAccess, x, y + 1, z + 1, x, y, z + 1, block, metadata)
|| connected(blockAccess, x, y - 1, z + 1, x, y, z + 1, block, metadata))) zp = false;
if (zp && (connected(blockAccess, x + 1, y, z + 1, x, y, z + 1, block, metadata)
|| connected(blockAccess, x - 1, y, z + 1, x, y, z + 1, block, metadata))) zp = false;
if (zn && (connected(blockAccess, x, y + 1, z - 1, x, y, z - 1, block, metadata)
|| connected(blockAccess, x, y - 1, z - 1, x, y, z - 1, block, metadata))) zn = false;
if (zn && (connected(blockAccess, x + 1, y, z - 1, x, y, z - 1, block, metadata)
|| connected(blockAccess, x - 1, y, z - 1, x, y, z - 1, block, metadata))) zn = false;
if (zp && (connected(blockAccess, x, y + 1, z + 1, block, metadata)
|| connected(blockAccess, x, y - 1, z + 1, block, metadata))) zp = false;
if (zp && (connected(blockAccess, x + 1, y, z + 1, block, metadata)
|| connected(blockAccess, x - 1, y, z + 1, block, metadata))) zp = false;
if (zn && (connected(blockAccess, x, y + 1, z - 1, block, metadata)
|| connected(blockAccess, x, y - 1, z - 1, block, metadata))) zn = false;
if (zn && (connected(blockAccess, x + 1, y, z - 1, block, metadata)
|| connected(blockAccess, x - 1, y, z - 1, block, metadata))) zn = false;
if (zp || zn) {
uvRotateSouth = 1;
@@ -48,8 +48,8 @@ public class SubmapManagerCTM implements ISubmapManager {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(String modName, Block block, IIconRegister register) {
submap = new TextureSubmapCTM(register.registerIcon(modName + ":" + textureName + "-ctm"), 4);
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":" + textureName), 2);
submap = new TextureSubmap(register.registerIcon(modName + ":" + textureName + "-ctm"), 4, 4);
submapSmall = new TextureSubmap(register.registerIcon(modName + ":" + textureName), 2, 2);
}
@Override
@@ -1,34 +1,41 @@
package team.chisel.ctmlib;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import org.apache.commons.lang3.ArrayUtils;
import com.google.common.collect.Lists;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import lombok.experimental.Delegate;
/**
* Represents a grid of individually accessible texture regions.
* This class is used to split up a large IIcon into smaller "submapped" icons used for CTM and other texture
* manipulation.
*/
public class TextureSubmap implements IIcon, ISubmap {
private static final List<TextureSubmap> submaps = Collections.synchronizedList(new ArrayList<>(128));
private static List<TextureSubmap> submaps = Lists.newArrayList();
private static TextureSubmap dummy = new TextureSubmap(null, 0, 0);
static {
MinecraftForge.EVENT_BUS.register(dummy);
}
private int width, height;
@Delegate
private final IIcon baseIcon;
private final int width;
private final int height;
protected final IIcon[][] icons;
private IIcon baseIcon;
protected IIcon[][] icons;
/**
* Construct a new submap. A submap is not required to be square, but it is required to be rectangular.
*
* @param baseIcon The IIcon to submap.
* @param width The width of the map, in icons.
* @param height The height of the map, in icons.
@@ -41,6 +48,9 @@ public class TextureSubmap implements IIcon, ISubmap {
submaps.add(this);
}
/**
* The large "base" icon used for the submap.
*/
public IIcon getBaseIcon() {
return baseIcon;
}
@@ -82,161 +92,94 @@ public class TextureSubmap implements IIcon, ISubmap {
/* ==== Internal Stitching Logic ==== */
static {
MinecraftForge.EVENT_BUS.register(new StitchHandler());
}
public static final class StitchHandler {
@SubscribeEvent
public void onTextureStitchPre(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() != 0) return;
TextureSubmapResource.beginTextureStitch();
for (TextureSubmap submap : submaps) {
submap.registerSubIcons(event.map);
}
submaps.clear();
}
@SubscribeEvent
public void onTextureStitchPost(TextureStitchEvent.Post event) {
if (event.map.getTextureType() != 0) return;
TextureSubmapResource.endTextureStitch();
}
}
public void registerSubIcons(TextureMap textureMap) {
registerSpriteGrid(textureMap, width, height);
}
/**
* Splits the texture into a grid of atlas sprites and assigns sub-icons to them.
* <p>
* The number of sub-icons is determined by the submap's width and height,
* while spriteColumns and spriteRows determine how many separate atlas sprites
* are used. Each sprite can contain one or more sub-icons.
* <p>
* For example, a 4x4 submap backed by a 2x2 sprite grid uses four atlas sprites,
* each containing a 2x2 group of sub-icons.
* For internal use only, this is used to create the virtual "subicons" used in the map.
*/
protected final void registerSpriteGrid(TextureMap textureMap, int spriteColumns, int spriteRows) {
if (baseIcon == null || width <= 0 || height <= 0) {
return;
}
if (spriteColumns <= 0 || spriteRows <= 0 || width % spriteColumns != 0 || height % spriteRows != 0) {
throw new IllegalArgumentException(
"Logical submap " + width
+ "x"
+ height
+ " cannot be backed by sprite grid "
+ spriteColumns
+ "x"
+ spriteRows);
@SubscribeEvent
public final void TexturesStitched(TextureStitchEvent.Post event) {
for (TextureSubmap ts : submaps) {
ts.texturesStitched();
}
}
ResourceLocation sourceLocation = new ResourceLocation(baseIcon.getIconName());
IIcon[][] sprites = new IIcon[spriteColumns][spriteRows];
for (int spriteX = 0; spriteX < spriteColumns; spriteX++) {
for (int spriteY = 0; spriteY < spriteRows; spriteY++) {
sprites[spriteX][spriteY] = getBackingSprite(
textureMap,
sourceLocation,
spriteColumns,
spriteRows,
spriteX,
spriteY);
}
}
int cellsPerSpriteX = width / spriteColumns;
int cellsPerSpriteY = height / spriteRows;
boolean wholeSprite = cellsPerSpriteX == 1 && cellsPerSpriteY == 1;
public void texturesStitched() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
IIcon sprite = sprites[x / cellsPerSpriteX][y / cellsPerSpriteY];
icons[x][y] = wholeSprite ? sprite
: new TextureRegion(
sprite,
cellsPerSpriteX,
cellsPerSpriteY,
x % cellsPerSpriteX,
y % cellsPerSpriteY);
icons[x][y] = new TextureVirtual(getBaseIcon(), width, height, x, y);
}
}
}
private IIcon getBackingSprite(TextureMap textureMap, ResourceLocation sourceLocation, int columns, int rows, int x,
int y) {
private class TextureVirtual implements IIcon {
if (columns == 1 && rows == 1) {
return baseIcon;
}
private int width, height;
private float umin, umax, vmin, vmax;
private IIcon parentIcon;
String name = TextureSubmapResource.getSubIconName(sourceLocation, columns, rows, x, y);
return textureMap.registerIcon(name);
}
private TextureVirtual(IIcon parent, int w, int h, int x, int y) {
parentIcon = parent;
private static final class TextureRegion implements IIcon {
umin = parentIcon.getInterpolatedU(16.0 * (x) / w);
umax = parentIcon.getInterpolatedU(16.0 * (x + 1) / w);
vmin = parentIcon.getInterpolatedV(16.0 * (y) / h);
vmax = parentIcon.getInterpolatedV(16.0 * (y + 1) / h);
private final IIcon parent;
private final int columns;
private final int rows;
private final int x;
private final int y;
private TextureRegion(IIcon parent, int columns, int rows, int x, int y) {
this.parent = parent;
this.columns = columns;
this.rows = rows;
this.x = x;
this.y = y;
width = parentIcon.getIconWidth();
height = parentIcon.getIconHeight();
}
@Override
@SideOnly(Side.CLIENT)
public float getMinU() {
return getInterpolatedU(0);
return umin;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaxU() {
return getInterpolatedU(16);
return umax;
}
@Override
public float getInterpolatedU(double u) {
return parent.getInterpolatedU((16.0 * x + u) / columns);
@SideOnly(Side.CLIENT)
public float getInterpolatedU(double d0) {
return (float) (umin + (umax - umin) * d0 / 16.0);
}
@Override
@SideOnly(Side.CLIENT)
public float getMinV() {
return getInterpolatedV(0);
return vmin;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaxV() {
return getInterpolatedV(16);
return vmax;
}
@Override
public float getInterpolatedV(double v) {
return parent.getInterpolatedV((16.0 * y + v) / rows);
@SideOnly(Side.CLIENT)
public float getInterpolatedV(double d0) {
return (float) (vmin + (vmax - vmin) * d0 / 16.0);
}
@Override
@SideOnly(Side.CLIENT)
public String getIconName() {
return parent.getIconName();
return parentIcon.getIconName();
}
@Override
@SideOnly(Side.CLIENT)
public int getIconWidth() {
return parent.getIconWidth() / columns;
return width;
}
@Override
@SideOnly(Side.CLIENT)
public int getIconHeight() {
return parent.getIconHeight() / rows;
return height;
}
}
}
@@ -1,27 +0,0 @@
package team.chisel.ctmlib;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
/**
* A CTM submap that keeps each tile in one atlas sprite while exposing its four quadrants as sub-icons.
*/
public final class TextureSubmapCTM extends TextureSubmap {
/**
* @param baseIcon The registered texture sheet.
* @param size The number of logical quadrants per axis: 4 for the CTM sheet, 2 for the normal texture.
*/
public TextureSubmapCTM(IIcon baseIcon, int size) {
super(baseIcon, size, size);
if (size <= 0 || (size & 1) != 0) {
throw new IllegalArgumentException("CTM submap size must be a positive even number: " + size);
}
}
@Override
public void registerSubIcons(TextureMap textureMap) {
registerSpriteGrid(textureMap, getWidth() / 2, getHeight() / 2);
}
}
@@ -1,280 +0,0 @@
package team.chisel.ctmlib;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.MemoryCacheImageOutputStream;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.data.AnimationFrame;
import net.minecraft.client.resources.data.AnimationMetadataSection;
import net.minecraft.client.resources.data.IMetadataSection;
import net.minecraft.util.ResourceLocation;
import com.github.bsideup.jabel.Desugar;
public final class TextureSubmapResource implements IResource {
@Desugar
public record SubmapLocation(ResourceLocation source, int columns, int rows, int cellX, int cellY) {}
@Desugar
private record SubmapCacheKey(ResourceLocation source, int columns, int rows) {}
@Nullable
private static volatile ConcurrentHashMap<SubmapCacheKey, byte[][]> imageCache;
private static final String PREFIX = "__chisel_submap/";
private final IResource resource;
private final SubmapLocation submap;
private final boolean cacheable;
private byte[] imageData;
public TextureSubmapResource(IResource resource, SubmapLocation submap, boolean cacheable) {
this.resource = resource;
this.submap = submap;
this.cacheable = cacheable;
}
public static SubmapLocation parse(ResourceLocation location) {
String path = location.getResourcePath();
int prefix = path.indexOf(PREFIX);
if (prefix < 0 || prefix > 0 && path.charAt(prefix - 1) != '/') return null;
int gridStart = prefix + PREFIX.length();
int gridEnd = path.indexOf('/', gridStart);
if (gridEnd < 0) return null;
int cellEnd = path.indexOf('/', gridEnd + 1);
if (cellEnd < 0) return null;
String grid = path.substring(gridStart, gridEnd);
String cell = path.substring(gridEnd + 1, cellEnd);
int gridSeparator = grid.indexOf('x');
int cellSeparator = cell.indexOf('_');
if (gridSeparator <= 0 || cellSeparator <= 0) return null;
try {
int columns = Integer.parseInt(grid.substring(0, gridSeparator));
int rows = Integer.parseInt(grid.substring(gridSeparator + 1));
int cellX = Integer.parseInt(cell.substring(0, cellSeparator));
int cellY = Integer.parseInt(cell.substring(cellSeparator + 1));
if (cellX < 0 || cellY < 0 || cellX >= columns || cellY >= rows) {
return null;
}
String sourcePath = path.substring(0, prefix) + path.substring(cellEnd + 1);
ResourceLocation sourceLocation = new ResourceLocation(location.getResourceDomain(), sourcePath);
return new SubmapLocation(sourceLocation, columns, rows, cellX, cellY);
} catch (NumberFormatException ignored) {
return null;
}
}
public static String getSubIconName(ResourceLocation source, int columns, int rows, int cellX, int cellY) {
return source.getResourceDomain() + ":"
+ PREFIX
+ columns
+ "x"
+ rows
+ "/"
+ cellX
+ "_"
+ cellY
+ "/"
+ source.getResourcePath();
}
public static void beginTextureStitch() {
imageCache = new ConcurrentHashMap<>();
}
public static void endTextureStitch() {
imageCache = null;
}
@Override
public InputStream getInputStream() {
if (imageData == null) {
try {
imageData = getCachedImageData(resource, submap);
} catch (IOException e) {
throw new RuntimeException("Failed to generate submap resource " + submap.source(), e);
}
}
return new ByteArrayInputStream(imageData);
}
private byte[] getCachedImageData(IResource resource, SubmapLocation submap) throws IOException {
ConcurrentHashMap<SubmapCacheKey, byte[][]> cache = imageCache;
if (!cacheable || cache == null) {
return generateCell(resource, submap);
}
SubmapCacheKey key = new SubmapCacheKey(submap.source(), submap.columns(), submap.rows());
byte[][] cells = cache.get(key);
if (cells == null) {
cells = generateSubmap(resource, submap);
byte[][] existing = cache.putIfAbsent(key, cells);
if (existing != null) {
cells = existing;
}
} else {
// generateCell and generateSubmap automatically close the stream, but we also need to close it on cache hit
resource.getInputStream()
.close();
}
return cells[submap.cellX() * submap.rows() + submap.cellY()];
}
private static byte[][] generateSubmap(IResource resource, SubmapLocation submap) throws IOException {
BufferedImage source = read(resource, submap.source());
byte[][] cells = new byte[submap.columns() * submap.rows()][];
for (int x = 0; x < submap.columns(); x++) {
for (int y = 0; y < submap.rows(); y++) {
BufferedImage cropped = crop(source, submap.columns(), submap.rows(), x, y);
cells[x * submap.rows() + y] = encode(cropped);
}
}
return cells;
}
private static byte[] generateCell(IResource resource, SubmapLocation submap) throws IOException {
BufferedImage source = read(resource, submap.source());
BufferedImage cropped = crop(source, submap.columns(), submap.rows(), submap.cellX(), submap.cellY());
return encode(cropped);
}
private static BufferedImage read(IResource resource, ResourceLocation location) throws IOException {
BufferedImage image;
try (InputStream stream = resource.getInputStream()) {
image = ImageIO.read(stream);
}
if (image == null) {
throw new IOException("Unable to decode " + location);
}
return image;
}
private static byte[] encode(BufferedImage image) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("png");
ImageWriter writer = writers.next();
ImageWriteParam param = writer.getDefaultWriteParam();
if (param.canWriteCompressed()) {
// Disable compression to avoid wasting time compressing images that will immediately be decoded again
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(1.0f);
}
try (ImageOutputStream imageOutput = new MemoryCacheImageOutputStream(output)) {
writer.setOutput(imageOutput);
writer.write(null, new IIOImage(image, null, null), param);
} finally {
writer.dispose();
}
return output.toByteArray();
}
private static BufferedImage crop(BufferedImage source, int columns, int rows, int cellX, int cellY)
throws IOException {
int frameSize = source.getWidth();
int sourceHeight = source.getHeight();
if (frameSize < columns || frameSize < rows
|| frameSize % columns != 0
|| frameSize % rows != 0
|| sourceHeight % frameSize != 0) {
throw new IOException(
"Texture size " + frameSize
+ "x"
+ sourceHeight
+ " cannot be split into submap "
+ columns
+ "x"
+ rows);
}
int cellWidth = frameSize / columns;
int cellHeight = frameSize / rows;
int frameCount = sourceHeight / frameSize;
BufferedImage result = new BufferedImage(cellWidth, cellHeight * frameCount, BufferedImage.TYPE_INT_ARGB);
int[] pixels = new int[cellWidth * cellHeight];
for (int frame = 0; frame < frameCount; frame++) {
int sourceX = cellX * cellWidth;
int sourceY = frame * frameSize + cellY * cellHeight;
source.getRGB(sourceX, sourceY, cellWidth, cellHeight, pixels, 0, cellWidth);
result.setRGB(0, frame * cellHeight, cellWidth, cellHeight, pixels, 0, cellWidth);
}
return result;
}
@Override
public boolean hasMetadata() {
return resource.hasMetadata();
}
@Override
public IMetadataSection getMetadata(String sectionName) {
IMetadataSection metadata = resource.getMetadata(sectionName);
if (!(metadata instanceof AnimationMetadataSection animation)) {
return metadata;
}
if (animation.getFrameWidth() < 0 && animation.getFrameHeight() < 0) {
return metadata;
}
List<AnimationFrame> frames = new ArrayList<>(animation.getFrameCount());
for (int i = 0; i < animation.getFrameCount(); i++) {
if (animation.frameHasTime(i)) {
frames.add(new AnimationFrame(animation.getFrameIndex(i), animation.getFrameTimeSingle(i)));
} else {
frames.add(new AnimationFrame(animation.getFrameIndex(i)));
}
}
int frameWidth = scaleMetadataDimension(animation.getFrameWidth(), submap.columns());
int frameHeight = scaleMetadataDimension(animation.getFrameHeight(), submap.rows());
return new AnimationMetadataSection(frames, frameWidth, frameHeight, animation.getFrameTime());
}
private static int scaleMetadataDimension(int dimension, int divisions) {
if (dimension < 0) {
return dimension;
}
if (dimension % divisions != 0) {
throw new IllegalArgumentException(
"Animation frame size " + dimension + " is not divisible by submap size " + divisions);
}
return dimension / divisions;
}
}
@@ -7,8 +7,6 @@ import team.chisel.Chisel;
import team.chisel.block.BlockCarvable;
import team.chisel.block.BlockCarvableBeacon;
import team.chisel.block.BlockCarvableCarpet;
import team.chisel.block.BlockCarvableConcreteSlab;
import team.chisel.block.BlockCarvableConcreteStairs;
import team.chisel.block.BlockCarvableGlass;
import team.chisel.block.BlockCarvableGlowstone;
import team.chisel.block.BlockCarvableIce;
@@ -55,7 +53,6 @@ public final class ChiselBlocks {
public static final BlockCarvable sandstone = null;
public static final BlockCarvable sandstone_scribbles = null;
public static final BlockConcrete concrete = null;
public static final BlockCarvableConcreteSlab concrete_slab = null;
public static final BlockRoadLine road_line = null;
public static final BlockCarvable iron_block = null;
public static final BlockCarvable gold_block = null;
@@ -68,7 +65,6 @@ public final class ChiselBlocks {
public static final BlockCarvable netherrack = null;
public static final BlockCarvable mossy_cobblestone = null;
public static final BlockCarvable stonebricksmooth = null;
public static final BlockCarvable hardenedClay = null;
public static final BlockCarvablePane iron_bars = null;
public static final BlockCarvableIce ice = null;
public static final BlockCarvableIce ice_pillar = null;
@@ -150,7 +146,6 @@ public final class ChiselBlocks {
public static BlockCarvableStairs[] limestoneStairs = new BlockCarvableStairs[8];
public static BlockCarvableIceStairs[] iceStairs = new BlockCarvableIceStairs[8];
public static BlockCarvablePackedIceStairs[] packediceStairs = new BlockCarvablePackedIceStairs[8];
public static BlockCarvableConcreteStairs[] concreteStairs = new BlockCarvableConcreteStairs[6];
public static Block[] torches = new BlockCarvableTorch[16];
@@ -177,38 +172,5 @@ public final class ChiselBlocks {
// 1.19, skipped 10 versions but thats fine
public static final BlockCarvable froglight = null;
// Backports from Dustrial Decor. Original artists are WDSPC and Evo_94!
public static final BlockCarvable lantern = null;
public static final BlockCarvable sheetmetal = null;
// June Additions
public static final BlockCarvable moss = null;
public static final BlockCarvableCarpet moss_carpet = null;
public static final BlockCarvable cobalt = null;
public static final BlockCarvable electrum = null;
public static final BlockCarvable invar = null;
public static final BlockCarvable nickel = null;
public static final BlockCarvable platinum = null;
public static final BlockCarvable cast_iron = null;
public static final BlockCarvable stainless_steel = null;
public static final BlockCarvable titanium = null;
public static final BlockCarvable tungstensteel = null;
public static final BlockCarvable rpp = null;
public static final BlockCarvable iridium = null;
public static final BlockCarvable osmium = null;
public static final BlockCarvable coral = null;
public static final BlockCarvable coral2 = null;
public static final BlockCarvable mud = null;
public static final BlockCarvable albumblock = null;
public static final BlockCarvable albumblock2 = null;
public static final BlockCarvable albumblock3 = null;
public static final BlockCarvable brickCustom2 = null;
public static final BlockCarvable brutalism = null;
public static final BlockConcrete road = null;
public static final BlockCarvable porcelain = null;
public static final BlockCarvable alabaster = null;
// Architect's Palette Backport
private ChiselBlocks() {}
}
@@ -119,10 +119,6 @@ public class ContainerChisel extends Container {
InventoryChiselSelection.normalSlots + 1 + 36,
false)) {
entity.inventory.setItemStack(itemstack1);
if (slotIdx == InventoryChiselSelection.normalSlots) {
slot.onPickupFromSlot(entity, itemstack1);
slot.putStack(null);
}
return null;
}
}
@@ -26,12 +26,12 @@ public class ItemUpgrade extends BaseItem {
@Override
public IIcon getIconFromDamage(int meta) {
// using modulo throughout to prevent AIOB
return this.icons[meta % Upgrade.VALUES.length];
return this.icons[meta % Upgrade.values().length];
}
@Override
public void registerIcons(IIconRegister reg) {
Upgrade[] upgrades = Upgrade.VALUES;
Upgrade[] upgrades = Upgrade.values();
for (int i = 0; i < upgrades.length; i++) {
this.icons[i] = reg.registerIcon(
Chisel.MOD_ID + ":upgrade_"
@@ -43,14 +43,14 @@ public class ItemUpgrade extends BaseItem {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < Upgrade.VALUES.length; i++) {
for (int i = 0; i < Upgrade.values().length; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
Upgrade[] upgrades = Upgrade.VALUES;
Upgrade[] upgrades = Upgrade.values();
return upgrades[stack.getItemDamage() % upgrades.length].getUnlocalizedName();
}
}
@@ -11,12 +11,14 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.oredict.OreDictionary;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import com.cricketcraft.chisel.api.rendering.TextureType;
import com.google.common.collect.Queues;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -31,10 +33,11 @@ public final class ChiselController {
protected static class GuiOpen implements Runnable {
private final EntityPlayer player;
private final ItemStack stack;
private EntityPlayer player;
private ItemStack stack;
public GuiOpen(EntityPlayer player, ItemStack stack) {
super();
this.player = player;
this.stack = stack;
}
@@ -52,7 +55,7 @@ public final class ChiselController {
public static final ChiselController INSTANCE = new ChiselController();
final Queue<GuiOpen> openQueue = Queues.newArrayDeque();
Queue<GuiOpen> openQueue = Queues.newArrayDeque();
private ChiselController() {}
@@ -160,4 +163,11 @@ public final class ChiselController {
}
}
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
if (event.world.isRemote) {
TextureType.clearStatics();
}
}
}
@@ -14,6 +14,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
@@ -51,7 +52,6 @@ public class ItemChisel extends Item implements IChiselItem {
super();
this.type = type;
setMaxStackSize(1);
setMaxDamage(Configurations.allowChiselDamage ? type.maxDamage : 0);
setTextureName(
Chisel.MOD_ID + ":chisel_"
+ type.name()
@@ -68,6 +68,13 @@ public class ItemChisel extends Item implements IChiselItem {
+ type.name()
.toLowerCase());
}
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public int getMaxDamage(ItemStack stack) {
if (Configurations.allowChiselDamage) return type.maxDamage;
return 0;
}
@Override
@@ -5,7 +5,3 @@ public net.minecraft.client.renderer.Tessellator field_78417_x
# GUI stuff for item scale
protected net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V # drawSlot
# Checking if a resource exists
public net.minecraft.client.resources.SimpleReloadableResourceManager field_110548_a # domainResourceManagers
public net.minecraft.client.resources.FallbackResourceManager field_110540_a # resourcePacks
File diff suppressed because it is too large. Load diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Loaded 100 of 3377 files, more files were not shown because too many files have changed in this diff. Show more