mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-27 15:43:14 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3ffd2ab38 | ||
|
|
2892e0df64 | ||
|
|
a5e0584206 | ||
|
|
b80ce8c9a3 | ||
|
|
cb87007dfd | ||
|
|
8318b6a614 | ||
|
|
143a01f6c2 |
No files matched your search
@@ -25,6 +25,7 @@ whitelist.json
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
|
src/main/resources/mixins.*.json
|
||||||
*.bat
|
*.bat
|
||||||
layout.json
|
layout.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
+6
-6
@@ -1,23 +1,23 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev")
|
implementation("com.github.GTNewHorizons:CodeChickenCore:1.5.2:dev")
|
||||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.84-GTNH:dev")
|
implementation("com.github.GTNewHorizons:NotEnoughItems:2.9.16-GTNH:dev")
|
||||||
implementation("com.github.GTNewHorizons:ForgeMultipart:1.7.3:dev")
|
implementation("com.github.GTNewHorizons:ForgeMultipart:2.0.1:dev")
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.24")
|
compileOnly("org.projectlombok:lombok:1.18.24")
|
||||||
annotationProcessor("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.20.3:dev") {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
devOnlyNonPublishable("com.github.GTNewHorizons:WailaHarvestability:1.3.4-GTNH:dev")
|
devOnlyNonPublishable("com.github.GTNewHorizons:WailaHarvestability:1.4.0-GTNH:dev")
|
||||||
|
|
||||||
compileOnly("curse.maven:ee3-65509:2305023") { // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
|
compileOnly("curse.maven:ee3-65509:2305023") { // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOnly("com.github.GTNewHorizons:Angelica:2.1.15:api") {
|
compileOnly("com.github.GTNewHorizons:Angelica:2.2.47:api") {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -69,7 +69,7 @@ enableModernJavaSyntax = jabel
|
|||||||
|
|
||||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
# 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.
|
# 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.
|
# 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.
|
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||||
@@ -107,7 +107,7 @@ apiPackage = api
|
|||||||
accessTransformersFile = chisel_compile_at.cfg
|
accessTransformersFile = chisel_compile_at.cfg
|
||||||
|
|
||||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
# 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.
|
# 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.
|
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||||
@@ -115,7 +115,7 @@ usesMixins = true
|
|||||||
separateMixinSourceSet =
|
separateMixinSourceSet =
|
||||||
|
|
||||||
# Adds some debug arguments like verbose output and class export.
|
# 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.
|
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||||
mixinPlugin =
|
mixinPlugin =
|
||||||
@@ -123,7 +123,7 @@ mixinPlugin =
|
|||||||
# Specify the package that contains all of your Mixins. The package must exist or
|
# 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,
|
# 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.
|
# it must match with this or the build will fail.
|
||||||
mixinsPackage = mixins
|
mixinsPackage =
|
||||||
|
|
||||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||||
# This parameter is for legacy compatibility only
|
# This parameter is for legacy compatibility only
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#This file is generated by updateDaemonJvm
|
#This file is generated by updateDaemonJvm
|
||||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
|
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/50d5fe9033e125599b2aa94dc590a27d/redirect
|
||||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
|
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b4d79acf73eaf165b8c6bc8fba023764/redirect
|
||||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
|
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/50d5fe9033e125599b2aa94dc590a27d/redirect
|
||||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
|
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b4d79acf73eaf165b8c6bc8fba023764/redirect
|
||||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9064f22734b42ac03e85df04b632e167/redirect
|
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/54e1f31b8c26d88fb972744b5f1ba132/redirect
|
||||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/4d0277c49991306ac78048580fe34bcf/redirect
|
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/5d8d54de3a467a8da01a32410565830f/redirect
|
||||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
|
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/50d5fe9033e125599b2aa94dc590a27d/redirect
|
||||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
|
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b4d79acf73eaf165b8c6bc8fba023764/redirect
|
||||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a9fa3b809e484a1e1ac4308a5dda661a/redirect
|
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a7c7be8a3ec5d8e677e7250d9c1ce3ed/redirect
|
||||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/aa99913fa6d767d899ffc96082da01ca/redirect
|
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d0edfb63e02dc58e61e6c804b15e02e8/redirect
|
||||||
toolchainVersion=25
|
toolchainVersion=25
|
||||||
Vendored
BIN
Binary file not shown.
+2
@@ -2,6 +2,8 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
# gradlew start up script for POSIX generated by Gradle.
|
||||||
#
|
#
|
||||||
# Important for running:
|
# Important for running:
|
||||||
#
|
#
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
# bash, then to run this script, type that shell name before the whole
|
# bash, then to run this script, type that shell name before the whole
|
||||||
# command line, like:
|
# command line, like:
|
||||||
#
|
#
|
||||||
# ksh Gradle
|
# ksh gradlew
|
||||||
#
|
#
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
|||||||
Vendored
+12
-23
@@ -19,12 +19,12 @@
|
|||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem gradlew startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
setlocal EnableExtensions
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
@@ -51,7 +51,7 @@ echo. 1>&2
|
|||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
@@ -65,29 +65,18 @@ echo. 1>&2
|
|||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute gradlew
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||||
|
|
||||||
:end
|
:exitWithErrorLevel
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.32'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.34'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4,8 +4,12 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@@ -69,6 +73,57 @@ public class CarvingUtils {
|
|||||||
return new SimpleCarvingGroup(name);
|
return new SimpleCarvingGroup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to chisel the {@link ItemStack} from {@code input} into the {@code target} {@link ItemStack}.
|
||||||
|
* If it can be chiseled, the input's stack size and NBT data will be copied over
|
||||||
|
* to the newly created {@link ItemStack}.
|
||||||
|
*
|
||||||
|
* @param input The original {@link ItemStack} to be chiseled. Can't be {@code null}.
|
||||||
|
* @param target The desired {@link ItemStack} chiseling target. Stack size and NBT data are ignored.
|
||||||
|
* Can't be {@code null}.
|
||||||
|
*
|
||||||
|
* @return A copy of the {@code target} {@link ItemStack} with the input's stack count and NBT data,
|
||||||
|
* if this is a valid chiseling operation. Will return {@code null} if it's not possible to chisel
|
||||||
|
* {@code input} into {@code target}.
|
||||||
|
*/
|
||||||
|
public static @Nullable ItemStack tryChiselingInto(@Nonnull ItemStack input, @Nonnull ItemStack target) {
|
||||||
|
ICarvingRegistry registry = getChiselRegistry();
|
||||||
|
if (registry == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack chiselTarget = null;
|
||||||
|
|
||||||
|
List<ItemStack> chiselGroup = registry.getItemsForChiseling(input);
|
||||||
|
if (chiselGroup != null) {
|
||||||
|
for (ItemStack variation : chiselGroup) {
|
||||||
|
if (target.getItemDamage() == variation.getItemDamage() && target.getItem() == variation.getItem()) {
|
||||||
|
// We use the target from the carving group, rather than what was passed in via the method's args,
|
||||||
|
// to skip copying any NBT data the original target might contain.
|
||||||
|
chiselTarget = variation;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chiselTarget == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack result = chiselTarget.copy();
|
||||||
|
result.stackSize = input.stackSize;
|
||||||
|
|
||||||
|
if (input.hasTagCompound()) {
|
||||||
|
// Copy NBT from input to target to both avoid dupes and prevent loss of stored information
|
||||||
|
// (such as when chiseling drawers with items inside)
|
||||||
|
NBTTagCompound nbt = (NBTTagCompound) input.getTagCompound()
|
||||||
|
.copy();
|
||||||
|
result.setTagCompound(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static class SimpleCarvingVariation implements ICarvingVariation {
|
public static class SimpleCarvingVariation implements ICarvingVariation {
|
||||||
|
|
||||||
private int order;
|
private int order;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import team.chisel.ctmlib.ISubmapManager;
|
|||||||
import team.chisel.ctmlib.RenderBlocksCTM;
|
import team.chisel.ctmlib.RenderBlocksCTM;
|
||||||
import team.chisel.ctmlib.RenderBlocksColumn;
|
import team.chisel.ctmlib.RenderBlocksColumn;
|
||||||
import team.chisel.ctmlib.TextureSubmap;
|
import team.chisel.ctmlib.TextureSubmap;
|
||||||
import team.chisel.ctmlib.TextureSubmapCTM;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all default {@link ISubmapManager} behavior
|
* Handles all default {@link ISubmapManager} behavior
|
||||||
@@ -198,8 +197,8 @@ public enum TextureType {
|
|||||||
IIcon baseIcon = register.registerIcon(modName + ":" + texturePath);
|
IIcon baseIcon = register.registerIcon(modName + ":" + texturePath);
|
||||||
return Triple.of(
|
return Triple.of(
|
||||||
baseIcon,
|
baseIcon,
|
||||||
new TextureSubmapCTM(register.registerIcon(modName + ":" + texturePath + "-ctm"), 4),
|
new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctm"), 4, 4),
|
||||||
new TextureSubmapCTM(baseIcon, 2)
|
new TextureSubmap(baseIcon, 2, 2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -57,7 +57,7 @@ import team.chisel.world.GeneratorChisel;
|
|||||||
name = Chisel.MOD_NAME,
|
name = Chisel.MOD_NAME,
|
||||||
version = Chisel.VERSION,
|
version = Chisel.VERSION,
|
||||||
guiFactory = "team.chisel.client.gui.GuiFactory",
|
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@[2.0.0,);after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest;after:BiomesOPlenty")
|
||||||
public class Chisel {
|
public class Chisel {
|
||||||
|
|
||||||
public static final String MOD_ID = "chisel";
|
public static final String MOD_ID = "chisel";
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package team.chisel.block.tileentity;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -16,6 +15,7 @@ import net.minecraft.util.EnumChatFormatting;
|
|||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
import com.cricketcraft.chisel.api.IChiselItem;
|
import com.cricketcraft.chisel.api.IChiselItem;
|
||||||
|
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@@ -64,7 +64,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
|||||||
|
|
||||||
private int progress = 0;
|
private int progress = 0;
|
||||||
|
|
||||||
private static EntityItem ghostItem;
|
|
||||||
boolean equal = false;
|
boolean equal = false;
|
||||||
private ItemStack[] inventory = new ItemStack[8];
|
private ItemStack[] inventory = new ItemStack[8];
|
||||||
private String name = "autoChisel";
|
private String name = "autoChisel";
|
||||||
@@ -128,69 +127,83 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
// Client-side visuals
|
||||||
ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
|
if (worldObj.isRemote) {
|
||||||
|
|
||||||
if (!worldObj.isRemote && hasChisel() && base != null && target != null) {
|
|
||||||
if (canBeMadeFrom(base, target)) {
|
|
||||||
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
|
|
||||||
|
|
||||||
// reset progress
|
|
||||||
progress = 0;
|
|
||||||
|
|
||||||
// the max possible for this craft
|
|
||||||
int canBeMade = target.getMaxStackSize();
|
|
||||||
|
|
||||||
// if there are items in the output, they count towards the max we can make
|
|
||||||
if (output != null) {
|
|
||||||
canBeMade -= output.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// can't make more than we have
|
|
||||||
canBeMade = Math.min(base.stackSize, canBeMade);
|
|
||||||
|
|
||||||
// if we can't make any, forget it
|
|
||||||
if (canBeMade <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// result will always be a copy of the target
|
|
||||||
ItemStack chiseled = target.copy();
|
|
||||||
|
|
||||||
// if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
|
|
||||||
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
|
|
||||||
|
|
||||||
if (canChisel(chiseled)) {
|
|
||||||
// if our output is empty, just use the current result
|
|
||||||
if (output == null) {
|
|
||||||
setInventorySlotContents(OUTPUT, chiseled);
|
|
||||||
} else {
|
|
||||||
// otherwise just add our result to the existing stack
|
|
||||||
inventory[OUTPUT].stackSize += chiseled.stackSize;
|
|
||||||
slotChanged(OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
chiselItem(chiseled.stackSize, target);
|
|
||||||
|
|
||||||
// remove what we made from the stack
|
|
||||||
base.stackSize -= chiseled.stackSize;
|
|
||||||
if (base.stackSize <= 0) {
|
|
||||||
setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (worldObj.getTotalWorldTime() % 10 == 0) {
|
|
||||||
progress++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (worldObj.isRemote) {
|
|
||||||
if (chiseling) {
|
if (chiseling) {
|
||||||
chiselRot += rotAmnt;
|
chiselRot += rotAmnt;
|
||||||
if (chiselRot >= maxRot) {
|
if (chiselRot >= maxRot) {
|
||||||
|
// Play Chisel SFX
|
||||||
chiselItem(0, getTarget());
|
chiselItem(0, getTarget());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chiselRot = Math.max(chiselRot - rotAmnt, 0);
|
chiselRot = Math.max(chiselRot - rotAmnt, 0);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server-side crafting
|
||||||
|
ItemStack base = inventory[BASE];
|
||||||
|
ItemStack target = getTarget();
|
||||||
|
if (base == null || target == null || !hasChisel()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unfiltered chisel result. Actual crafting might fail or be of a lower stack size than this.
|
||||||
|
ItemStack chiseled = CarvingUtils.tryChiselingInto(base, target);
|
||||||
|
if (chiseled == null) {
|
||||||
|
// Not a valid chisel recipe
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progress < (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
|
||||||
|
if (worldObj.getTotalWorldTime() % 10 == 0) {
|
||||||
|
progress++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update progress and return
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crafting finished
|
||||||
|
progress = 0;
|
||||||
|
|
||||||
|
// Use the template's stack size as the max possible for this craft
|
||||||
|
int canBeMade = target.getMaxStackSize();
|
||||||
|
|
||||||
|
// If there are items in the output, they count towards the max we can make
|
||||||
|
ItemStack output = inventory[OUTPUT];
|
||||||
|
if (output != null) {
|
||||||
|
canBeMade -= output.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't make more than we have
|
||||||
|
canBeMade = Math.min(base.stackSize, canBeMade);
|
||||||
|
|
||||||
|
// If we can't make any, forget it
|
||||||
|
if (canBeMade <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have the stack upgrade, boost the stack size to the max possible, otherwise just one
|
||||||
|
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
|
||||||
|
|
||||||
|
if (canChisel(chiseled)) {
|
||||||
|
|
||||||
|
// Use (and possibly break) the chisel
|
||||||
|
chiselItem(chiseled.stackSize, target);
|
||||||
|
|
||||||
|
// Remove what we made from the input stack and add it to the output stack
|
||||||
|
base.stackSize -= chiseled.stackSize;
|
||||||
|
if (base.stackSize <= 0) {
|
||||||
|
setInventorySlotContents(BASE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output == null) {
|
||||||
|
setInventorySlotContents(OUTPUT, chiseled);
|
||||||
|
} else {
|
||||||
|
inventory[OUTPUT].stackSize += chiseled.stackSize;
|
||||||
|
slotChanged(OUTPUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,17 +217,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target
|
|
||||||
private boolean canBeMadeFrom(ItemStack from, ItemStack to) {
|
|
||||||
List<ItemStack> results = Carving.chisel.getItemsForChiseling(from);
|
|
||||||
for (ItemStack s : results) {
|
|
||||||
if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canChisel(ItemStack toMerge) {
|
private boolean canChisel(ItemStack toMerge) {
|
||||||
// if the output slot is empty we can merge without checking
|
// if the output slot is empty we can merge without checking
|
||||||
if (inventory[OUTPUT] == null) {
|
if (inventory[OUTPUT] == null) {
|
||||||
@@ -407,27 +409,15 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public EntityItem getItemForRendering(int slot) {
|
public ItemStack getItemForRendering(int slot) {
|
||||||
if (ghostItem == null) {
|
|
||||||
ghostItem = new EntityItem(worldObj);
|
|
||||||
ghostItem.hoverStart = 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slot == BASE && lastBase != null) {
|
if (slot == BASE && lastBase != null) {
|
||||||
ghostItem.setEntityItemStack(lastBase.copy());
|
return lastBase.copy();
|
||||||
return ghostItem;
|
|
||||||
} else if (slot == TARGET) {
|
} else if (slot == TARGET) {
|
||||||
ItemStack target = getTarget();
|
return getTarget();
|
||||||
if (target != null) {
|
|
||||||
ghostItem.setEntityItemStack(target);
|
|
||||||
return ghostItem;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} else if (inventory[slot] == null) {
|
} else if (inventory[slot] == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
ghostItem.setEntityItemStack(inventory[slot].copy());
|
return inventory[slot].copy();
|
||||||
return ghostItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
import team.chisel.ctmlib.Drawing;
|
import team.chisel.ctmlib.Drawing;
|
||||||
import team.chisel.ctmlib.RenderBlocksCTM;
|
import team.chisel.ctmlib.RenderBlocksCTM;
|
||||||
import team.chisel.ctmlib.TextureSubmap;
|
import team.chisel.ctmlib.TextureSubmap;
|
||||||
import team.chisel.ctmlib.TextureSubmapCTM;
|
|
||||||
import team.chisel.init.ChiselBlocks;
|
import team.chisel.init.ChiselBlocks;
|
||||||
|
|
||||||
public class SubmapManagerAntiblock extends SubmapManagerBase {
|
public class SubmapManagerAntiblock extends SubmapManagerBase {
|
||||||
@@ -94,8 +93,8 @@ public class SubmapManagerAntiblock extends SubmapManagerBase {
|
|||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||||
submap = new TextureSubmapCTM(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4);
|
submap = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4, 4);
|
||||||
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2);
|
submapSmall = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.Side;
|
|||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import team.chisel.ctmlib.RenderBlocksCTM;
|
import team.chisel.ctmlib.RenderBlocksCTM;
|
||||||
import team.chisel.ctmlib.TextureSubmap;
|
import team.chisel.ctmlib.TextureSubmap;
|
||||||
import team.chisel.ctmlib.TextureSubmapCTM;
|
|
||||||
|
|
||||||
public class SubmapManagerCarpetFloor extends SubmapManagerBase {
|
public class SubmapManagerCarpetFloor extends SubmapManagerBase {
|
||||||
|
|
||||||
@@ -40,8 +39,8 @@ public class SubmapManagerCarpetFloor extends SubmapManagerBase {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||||
String path = modName + ":carpet/" + color;
|
String path = modName + ":carpet/" + color;
|
||||||
submap = new TextureSubmapCTM(register.registerIcon(path + "-ctm"), 4);
|
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
|
||||||
submapSmall = new TextureSubmapCTM(register.registerIcon(path), 2);
|
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package team.chisel.client.render;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
@@ -90,9 +89,12 @@ public class SubmapManagerCombinedCTM extends SubmapManagerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerSubIcons(TextureMap textureMap) {
|
public void texturesStitched() {
|
||||||
for (int i = 0; i < icons.length; i++) {
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
import team.chisel.ctmlib.ISubmapManager;
|
import team.chisel.ctmlib.ISubmapManager;
|
||||||
import team.chisel.ctmlib.RenderBlocksCTM;
|
import team.chisel.ctmlib.RenderBlocksCTM;
|
||||||
import team.chisel.ctmlib.TextureSubmap;
|
import team.chisel.ctmlib.TextureSubmap;
|
||||||
import team.chisel.ctmlib.TextureSubmapCTM;
|
|
||||||
|
|
||||||
public class SubmapManagerSlab implements ISubmapManager {
|
public class SubmapManagerSlab implements ISubmapManager {
|
||||||
|
|
||||||
@@ -43,8 +42,8 @@ public class SubmapManagerSlab implements ISubmapManager {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||||
String path = modName + ":" + texture;
|
String path = modName + ":" + texture;
|
||||||
submap = new TextureSubmapCTM(register.registerIcon(path + "-ctm"), 4);
|
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
|
||||||
submapSmall = new TextureSubmapCTM(register.registerIcon(path), 2);
|
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
|
||||||
sideTexture = register.registerIcon(path + "-side");
|
sideTexture = register.registerIcon(path + "-side");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.Side;
|
|||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import team.chisel.ctmlib.RenderBlocksCTM;
|
import team.chisel.ctmlib.RenderBlocksCTM;
|
||||||
import team.chisel.ctmlib.TextureSubmap;
|
import team.chisel.ctmlib.TextureSubmap;
|
||||||
import team.chisel.ctmlib.TextureSubmapCTM;
|
|
||||||
|
|
||||||
public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
|
public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
|
||||||
|
|
||||||
@@ -72,8 +71,8 @@ public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
|
|||||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||||
String materialName = materialType.name()
|
String materialName = materialType.name()
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
submap = new TextureSubmapCTM(register.registerIcon(modName + ":" + materialName + "/" + color + "-ctm"), 4);
|
submap = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color + "-ctm"), 4, 4);
|
||||||
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":" + materialName + "/" + color), 2);
|
submapSmall = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import net.minecraft.client.renderer.entity.RenderManager;
|
|||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
@@ -160,13 +161,16 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Random rand = new Random();
|
private static final Random rand = new Random();
|
||||||
|
private final EntityItem entityItem = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float scale) {
|
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float scale) {
|
||||||
|
|
||||||
// Render Blocks
|
// Render Blocks
|
||||||
|
try {
|
||||||
|
this.entityItem.setWorld(tile.getWorldObj());
|
||||||
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
||||||
EntityItem item = autoChisel.getItemForRendering(TileEntityAutoChisel.TARGET);
|
EntityItem item = this.getItemForRendering(autoChisel, TileEntityAutoChisel.TARGET);
|
||||||
|
|
||||||
rand.setSeed(tile.xCoord + tile.yCoord + tile.zCoord);
|
rand.setSeed(tile.xCoord + tile.yCoord + tile.zCoord);
|
||||||
rand.nextBoolean();
|
rand.nextBoolean();
|
||||||
@@ -195,17 +199,18 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
|||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.BASE);
|
item = this.getItemForRendering(autoChisel, TileEntityAutoChisel.BASE);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslated(x + 0.35, y + 0.934, z + 0.5);
|
glTranslated(x + 0.35, y + 0.934, z + 0.5);
|
||||||
item.getEntityItem().stackSize = autoChisel.getLastBase() == null ? 1 : autoChisel.getLastBase().stackSize;
|
item.getEntityItem().stackSize = autoChisel.getLastBase() == null ? 1
|
||||||
|
: autoChisel.getLastBase().stackSize;
|
||||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
||||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.CHISEL);
|
item = this.getItemForRendering(autoChisel, TileEntityAutoChisel.CHISEL);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslated(x + 0.7, y + 1.01, z + 0.5);
|
glTranslated(x + 0.7, y + 1.01, z + 0.5);
|
||||||
@@ -221,5 +226,18 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
|||||||
settings.fancyGraphics = was;
|
settings.fancyGraphics = was;
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.entityItem.setWorld(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityItem getItemForRendering(TileEntityAutoChisel autoChisel, int slot) {
|
||||||
|
final ItemStack stack = autoChisel.getItemForRendering(slot);
|
||||||
|
if (stack != null) {
|
||||||
|
this.entityItem.setEntityItemStack(stack);
|
||||||
|
return this.entityItem;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
package team.chisel.compat.fmp;
|
package team.chisel.compat.fmp;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.microblock.MicroMaterialRegistry;
|
import codechicken.microblock.MicroMaterialRegistry;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
||||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
import codechicken.multipart.MultiPartRegistry.IPartFactory2;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import team.chisel.client.render.FullBrightMicroMaterial;
|
import team.chisel.client.render.FullBrightMicroMaterial;
|
||||||
import team.chisel.init.ChiselBlocks;
|
import team.chisel.init.ChiselBlocks;
|
||||||
|
|
||||||
public class FMPCompat implements IPartFactory, IPartConverter {
|
public class FMPCompat implements IPartFactory2, IPartConverter {
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
MultiPartRegistry.registerConverter(this);
|
MultiPartRegistry.registerConverter(this);
|
||||||
MultiPartRegistry.registerParts(this, new String[] { "chisel_torch" });
|
MultiPartRegistry.registerPartFactory(this, "chisel_torch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,7 +41,21 @@ public class FMPCompat implements IPartFactory, IPartConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TMultiPart createPart(String type, boolean client) {
|
public TMultiPart createPart(String type, NBTTagCompound nbt) {
|
||||||
|
return newPart(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart createPart(String type, MCDataInput packet) {
|
||||||
|
return newPart(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart createPartForClientPreview(String type, NBTTagCompound nbt) {
|
||||||
|
return newPart(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TMultiPart newPart(String type) {
|
||||||
if (type.equals("chisel_torch")) {
|
if (type.equals("chisel_torch")) {
|
||||||
return new PartChiselTorch();
|
return new PartChiselTorch();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
@@ -76,7 +77,7 @@ public class RecipeHandlerChisel extends TemplateRecipeHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRecipeName() {
|
public String getRecipeName() {
|
||||||
return "Chisel";
|
return StatCollector.translateToLocal("chisel.nei.title");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class SubmapManagerCTM implements ISubmapManager {
|
|||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||||
submap = new TextureSubmapCTM(register.registerIcon(modName + ":" + textureName + "-ctm"), 4);
|
submap = new TextureSubmap(register.registerIcon(modName + ":" + textureName + "-ctm"), 4, 4);
|
||||||
submapSmall = new TextureSubmapCTM(register.registerIcon(modName + ":" + textureName), 2);
|
submapSmall = new TextureSubmap(register.registerIcon(modName + ":" + textureName), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,34 +1,41 @@
|
|||||||
package team.chisel.ctmlib;
|
package team.chisel.ctmlib;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import lombok.experimental.Delegate;
|
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 {
|
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
|
@Delegate
|
||||||
private final IIcon baseIcon;
|
private IIcon baseIcon;
|
||||||
private final int width;
|
|
||||||
private final int height;
|
protected IIcon[][] icons;
|
||||||
protected final 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 baseIcon The IIcon to submap.
|
||||||
* @param width The width of the map, in icons.
|
* @param width The width of the map, in icons.
|
||||||
* @param height The height 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);
|
submaps.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The large "base" icon used for the submap.
|
||||||
|
*/
|
||||||
public IIcon getBaseIcon() {
|
public IIcon getBaseIcon() {
|
||||||
return baseIcon;
|
return baseIcon;
|
||||||
}
|
}
|
||||||
@@ -82,161 +92,94 @@ public class TextureSubmap implements IIcon, ISubmap {
|
|||||||
|
|
||||||
/* ==== Internal Stitching Logic ==== */
|
/* ==== 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.
|
* For internal use only, this is used to create the virtual "subicons" used in the map.
|
||||||
* <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.
|
|
||||||
*/
|
*/
|
||||||
protected final void registerSpriteGrid(TextureMap textureMap, int spriteColumns, int spriteRows) {
|
@SubscribeEvent
|
||||||
if (baseIcon == null || width <= 0 || height <= 0) {
|
public final void TexturesStitched(TextureStitchEvent.Post event) {
|
||||||
return;
|
for (TextureSubmap ts : submaps) {
|
||||||
}
|
ts.texturesStitched();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
public void texturesStitched() {
|
||||||
int cellsPerSpriteY = height / spriteRows;
|
|
||||||
boolean wholeSprite = cellsPerSpriteX == 1 && cellsPerSpriteY == 1;
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
IIcon sprite = sprites[x / cellsPerSpriteX][y / cellsPerSpriteY];
|
icons[x][y] = new TextureVirtual(getBaseIcon(), width, height, x, y);
|
||||||
icons[x][y] = wholeSprite ? sprite
|
|
||||||
: new TextureRegion(
|
|
||||||
sprite,
|
|
||||||
cellsPerSpriteX,
|
|
||||||
cellsPerSpriteY,
|
|
||||||
x % cellsPerSpriteX,
|
|
||||||
y % cellsPerSpriteY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIcon getBackingSprite(TextureMap textureMap, ResourceLocation sourceLocation, int columns, int rows, int x,
|
private class TextureVirtual implements IIcon {
|
||||||
int y) {
|
|
||||||
|
|
||||||
if (columns == 1 && rows == 1) {
|
private int width, height;
|
||||||
return baseIcon;
|
private float umin, umax, vmin, vmax;
|
||||||
}
|
private IIcon parentIcon;
|
||||||
|
|
||||||
String name = TextureSubmapResource.getSubIconName(sourceLocation, columns, rows, x, y);
|
private TextureVirtual(IIcon parent, int w, int h, int x, int y) {
|
||||||
return textureMap.registerIcon(name);
|
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;
|
width = parentIcon.getIconWidth();
|
||||||
private final int columns;
|
height = parentIcon.getIconHeight();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public float getMinU() {
|
public float getMinU() {
|
||||||
return getInterpolatedU(0);
|
return umin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public float getMaxU() {
|
public float getMaxU() {
|
||||||
return getInterpolatedU(16);
|
return umax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getInterpolatedU(double u) {
|
@SideOnly(Side.CLIENT)
|
||||||
return parent.getInterpolatedU((16.0 * x + u) / columns);
|
public float getInterpolatedU(double d0) {
|
||||||
|
return (float) (umin + (umax - umin) * d0 / 16.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public float getMinV() {
|
public float getMinV() {
|
||||||
return getInterpolatedV(0);
|
return vmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public float getMaxV() {
|
public float getMaxV() {
|
||||||
return getInterpolatedV(16);
|
return vmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getInterpolatedV(double v) {
|
@SideOnly(Side.CLIENT)
|
||||||
return parent.getInterpolatedV((16.0 * y + v) / rows);
|
public float getInterpolatedV(double d0) {
|
||||||
|
return (float) (vmin + (vmax - vmin) * d0 / 16.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public String getIconName() {
|
public String getIconName() {
|
||||||
return parent.getIconName();
|
return parentIcon.getIconName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public int getIconWidth() {
|
public int getIconWidth() {
|
||||||
return parent.getIconWidth() / columns;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public int getIconHeight() {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,7 @@ import net.minecraft.util.MathHelper;
|
|||||||
|
|
||||||
import com.cricketcraft.chisel.api.IChiselItem;
|
import com.cricketcraft.chisel.api.IChiselItem;
|
||||||
import com.cricketcraft.chisel.api.Statistics;
|
import com.cricketcraft.chisel.api.Statistics;
|
||||||
|
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||||
|
|
||||||
import team.chisel.carving.Carving;
|
import team.chisel.carving.Carving;
|
||||||
import team.chisel.utils.General;
|
import team.chisel.utils.General;
|
||||||
@@ -40,30 +41,29 @@ public class SlotChiselSelection extends Slot {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) {
|
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) {
|
||||||
ItemStack heldStack = player.inventory.getItemStack();
|
ItemStack chiselInputStack = selInventory.inventory[InventoryChiselSelection.normalSlots];
|
||||||
ItemStack crafted = selInventory.inventory[InventoryChiselSelection.normalSlots];
|
|
||||||
|
|
||||||
if (heldStack == null) {
|
if (itemstack == null) {
|
||||||
selInventory.decrStackSize(InventoryChiselSelection.normalSlots, 1);
|
selInventory.decrStackSize(InventoryChiselSelection.normalSlots, 1);
|
||||||
} else {
|
} else {
|
||||||
putStack(itemstack.copy());
|
if (chiselInputStack == null) {
|
||||||
|
|
||||||
player.inventory.setItemStack(null);
|
player.inventory.setItemStack(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (selInventory.inventory[InventoryChiselSelection.normalSlots] == null) return;
|
// Perform chisel crafting operation
|
||||||
|
ItemStack chiselingOutput = CarvingUtils.tryChiselingInto(chiselInputStack, itemstack);
|
||||||
|
player.inventory.setItemStack(chiselingOutput);
|
||||||
|
|
||||||
player.inventory.setItemStack(
|
// Clear the input stack
|
||||||
new ItemStack(
|
|
||||||
itemstack.getItem(),
|
|
||||||
selInventory.inventory[InventoryChiselSelection.normalSlots].stackSize,
|
|
||||||
itemstack.getItemDamage()));
|
|
||||||
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, null);
|
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
selInventory.updateItems();
|
selInventory.updateItems();
|
||||||
|
|
||||||
|
// Damage and possibly break the chisel
|
||||||
if (((IChiselItem) container.chisel.getItem())
|
if (((IChiselItem) container.chisel.getItem())
|
||||||
.onChisel(player.worldObj, container.chisel, General.getVariation(crafted))) {
|
.onChisel(player.worldObj, container.chisel, General.getVariation(chiselInputStack))) {
|
||||||
container.chisel.damageItem(1, player);
|
container.chisel.damageItem(1, player);
|
||||||
if (container.chisel.stackSize <= 0) {
|
if (container.chisel.stackSize <= 0) {
|
||||||
player.setCurrentItemOrArmor(0, null);
|
player.setCurrentItemOrArmor(0, null);
|
||||||
@@ -71,7 +71,8 @@ public class SlotChiselSelection extends Slot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player.worldObj.isRemote) {
|
if (player.worldObj.isRemote) {
|
||||||
String sound = Carving.chisel.getVariationSound(crafted.getItem(), crafted.getItemDamage());
|
String sound = Carving.chisel
|
||||||
|
.getVariationSound(chiselInputStack.getItem(), chiselInputStack.getItemDamage());
|
||||||
GeneralClient.playChiselSound(
|
GeneralClient.playChiselSound(
|
||||||
player.worldObj,
|
player.worldObj,
|
||||||
MathHelper.floor_double(player.posX),
|
MathHelper.floor_double(player.posX),
|
||||||
@@ -79,7 +80,7 @@ public class SlotChiselSelection extends Slot {
|
|||||||
MathHelper.floor_double(player.posZ),
|
MathHelper.floor_double(player.posZ),
|
||||||
sound);
|
sound);
|
||||||
} else {
|
} else {
|
||||||
container.playerInventory.player.addStat(Statistics.blocksChiseled, crafted.stackSize);
|
container.playerInventory.player.addStat(Statistics.blocksChiseled, chiselInputStack.stackSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,6 +148,9 @@ autochisel.slot.stack.tooltip=Stack Upgrade Slot
|
|||||||
autochisel.slot.reversion.tooltip=Reversion Upgrade Slot
|
autochisel.slot.reversion.tooltip=Reversion Upgrade Slot
|
||||||
chisel.autochisel.upgrade.disabled=Upgrades Disabled
|
chisel.autochisel.upgrade.disabled=Upgrades Disabled
|
||||||
|
|
||||||
|
#NEI
|
||||||
|
chisel.nei.title=Chisel
|
||||||
|
|
||||||
#Beacon
|
#Beacon
|
||||||
tile.chisel.beacon.name=Beacon
|
tile.chisel.beacon.name=Beacon
|
||||||
tile.beacon.black.desc=Black Beamed Beacon
|
tile.beacon.black.desc=Black Beamed Beacon
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8.5-GTNH",
|
|
||||||
"package": "com.cricketcraft.chisel.mixins",
|
|
||||||
"refmap": "mixins.chisel.refmap.json",
|
|
||||||
"target": "@env(DEFAULT)",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [
|
|
||||||
"MixinFallbackResourceManager"
|
|
||||||
],
|
|
||||||
"server": []
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user