Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 53f7046f93 | |||
| 44544c598f | |||
| bcee2ec427 | |||
| 9e41d543f5 | |||
| 81cc0b804d | |||
| e1fc9908b3 | |||
| 9ed1535477 | |||
| 1ef345d4a4 | |||
| ff7d1b9719 | |||
| 88c9370e4f | |||
| f2aae3ef0f | |||
| 12739f1e66 | |||
| 81d2170ada | |||
| 0f469e9df6 | |||
| 0f34f09b32 | |||
| 8e54a8fed9 | |||
| d9bb81a00f | |||
| 39e038d916 | |||
| 12ca8d109a | |||
| f0d0595c8f | |||
| b756d68be1 | |||
| 60b07e5ca5 | |||
| 7c99fca789 | |||
| ab393b0ed1 | |||
| 957bc4c5cc | |||
| 133ed1f09d | |||
| e90dd2f9c6 | |||
| 9719c7ffc3 | |||
| 319d92a371 | |||
| db9ec2b070 | |||
| 3a0552c56e | |||
| 8a0dd192e5 | |||
| a97b35f3d0 | |||
| 00d4c20d9f | |||
| 1394ab0863 | |||
| 5efc085693 | |||
| 159f4c7f14 | |||
| aff94cec8c | |||
| ee7fe9f40d | |||
| 2184d03d0b | |||
| 9c9a49f9e7 | |||
| 44c0931c02 | |||
| b7949e4134 | |||
| ea95913ec8 | |||
| 423ab81813 | |||
| 33d7f02323 | |||
| 4e42b17e81 | |||
| b8d4f0cffa | |||
| fc0f8eab56 | |||
| 7e1bfdb5ac | |||
| 41b7900706 | |||
| 1f9707e256 | |||
| 7656157b0d | |||
| 954ce1442e | |||
| ee67c5ea50 | |||
| 73735c5cd5 | |||
| c1713f1682 | |||
| f455fd1994 | |||
| 1657c88681 | |||
| fd67e0e5c6 | |||
| 87c2c94bd4 | |||
| d591a1492c | |||
| d1ba26311b | |||
| 8733c2c11f | |||
| 4230fc7325 | |||
| 484af8baf3 | |||
| 9456f639d4 | |||
| fe753c540b | |||
| 2fabab3a6a | |||
| 6f39bd8fe8 | |||
| c7d3877129 | |||
| 822249dda8 | |||
| 1404806d3d | |||
| 12e3fa9127 | |||
| 8617dc8340 | |||
| 9bc844738c | |||
| eab6483bd7 | |||
| 7ca9405c8b | |||
| 39959145a3 | |||
| 22f552217f | |||
| 8f0e408772 | |||
| 62bbc32763 | |||
| 872d8d33cb | |||
| 1801302d8f | |||
| a85ffec9f9 | |||
| 5fca946ef3 | |||
| f8446209ce | |||
| 088627aedf | |||
| c8d08f9726 | |||
| 259d932946 |
@@ -55,7 +55,15 @@ jobs:
|
|||||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: ./gradlew publish --no-daemon --max-workers 1
|
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1
|
||||||
|
- name: Publish to modmaven
|
||||||
|
env:
|
||||||
|
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||||
|
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||||
|
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||||
|
MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }}
|
||||||
|
MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }}
|
||||||
|
run: ./gradlew publishMavenPublicationToModmavenRepository --no-daemon --max-workers 1
|
||||||
- name: Prepare artifact metadata
|
- name: Prepare artifact metadata
|
||||||
id: prepare_artifact_metadata
|
id: prepare_artifact_metadata
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -72,12 +72,20 @@ The API for Applied Energistics 2. It is open source to discuss changes, improve
|
|||||||
|
|
||||||
### Maven
|
### Maven
|
||||||
|
|
||||||
We use Github Packages as maven repository now. You can use the following snippet as example on how to add a repository to your gradle build file.
|
Our authoritative Maven repository is Github Packages, which you can also use in your builds. Use of Github Packages
|
||||||
|
[requires special setup](https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages)
|
||||||
|
to authenticate with your personal access token.
|
||||||
|
|
||||||
|
AE2 is also available without authentication from Modmaven. You can use the following snippet as example on how to add a repository to your gradle build file.
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name "AE2"
|
name "Modmaven"
|
||||||
url "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
|
url "https://modmaven.k-4u.nl/"
|
||||||
|
// For Gradle 5.1 and above, limit it to just AE2
|
||||||
|
content {
|
||||||
|
includeGroup 'appeng'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,13 @@ publishing {
|
|||||||
groupId = project.group
|
groupId = project.group
|
||||||
artifactId = project.archivesBaseName
|
artifactId = project.archivesBaseName
|
||||||
version = project.version
|
version = project.version
|
||||||
|
|
||||||
|
// ForgeGradle will generate wild dependency definitions, see https://github.com/MinecraftForge/ForgeGradle/issues/584
|
||||||
|
// Since we don't actually depend on anything, just remove the entire node.
|
||||||
|
pom.withXml {
|
||||||
|
asNode().remove(asNode().dependencies)
|
||||||
|
}
|
||||||
|
|
||||||
from components.java
|
from components.java
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
artifact javadocJar
|
artifact javadocJar
|
||||||
@@ -205,5 +212,13 @@ publishing {
|
|||||||
name = "GitHubPackages"
|
name = "GitHubPackages"
|
||||||
url = "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
|
url = "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
credentials {
|
||||||
|
username System.getenv("MODMAVEN_USER")
|
||||||
|
password System.getenv("MODMAVEN_PASSWORD")
|
||||||
|
}
|
||||||
|
name = "modmaven"
|
||||||
|
url = "https://modmaven.k-4u.nl/artifactory/local-releases/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -9,23 +9,24 @@ artifact_basename=appliedenergistics2
|
|||||||
# Minecraft Versions #
|
# Minecraft Versions #
|
||||||
#########################################################
|
#########################################################
|
||||||
minecraft_release=1.16
|
minecraft_release=1.16
|
||||||
minecraft_version=1.16.1
|
minecraft_version=1.16.2
|
||||||
mcp_mappings=20200723-1.16.1
|
mcp_mappings=20200723-1.16.1
|
||||||
forge_version=32.0.93
|
forge_version=33.0.42
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Provided APIs #
|
# Provided APIs #
|
||||||
#########################################################
|
#########################################################
|
||||||
jei_version=7.0.0.6
|
jei_minecraft_version=1.16.2
|
||||||
top_version=3.0.1-beta-4
|
jei_version=7.3.2.25
|
||||||
|
top_version=3.0.3-beta-6
|
||||||
hwyla_version=1.10.8-B72_1.15.2
|
hwyla_version=1.10.8-B72_1.15.2
|
||||||
ctm_version=MC1.15.2-1.1.0.9
|
ctm_version=MC1.15.2-1.1.0.9
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Deployment #
|
# Deployment #
|
||||||
#########################################################
|
#########################################################
|
||||||
website_version=1.16.1
|
website_version=1.16.2
|
||||||
curse_versions=1.16.1
|
curse_versions=1.16.2
|
||||||
curseforge_project=223794
|
curseforge_project=223794
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ dependencies {
|
|||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
// compile against provided APIs
|
// compile against provided APIs
|
||||||
compileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api"
|
compileOnly "mezz.jei:jei-${jei_minecraft_version}:${jei_version}:api"
|
||||||
compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api"
|
compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api"
|
||||||
|
|
||||||
// Runtime, Mods
|
// Runtime, Mods
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
|
runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}:${jei_version}")
|
||||||
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
|
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
|
||||||
//runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}")
|
//runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}")
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
package appeng.api.config;
|
package appeng.api.config;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent the security systems basic permissions, these are not for
|
* Represent the security systems basic permissions, these are not for
|
||||||
* anti-griefing, they are part of the mod as a gameplay feature.
|
* anti-griefing, they are part of the mod as a gameplay feature.
|
||||||
@@ -58,7 +60,7 @@ public enum SecurityPermissions {
|
|||||||
*/
|
*/
|
||||||
SECURITY;
|
SECURITY;
|
||||||
|
|
||||||
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase();
|
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
public String getTranslatedName() {
|
public String getTranslatedName() {
|
||||||
return this.translationKey + ".name";
|
return this.translationKey + ".name";
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public interface ICraftingHelper {
|
|||||||
* @param stack If null, a new item will be created to hold the encoded pattern.
|
* @param stack If null, a new item will be created to hold the encoded pattern.
|
||||||
* Otherwise the given item must already contains an encoded
|
* Otherwise the given item must already contains an encoded
|
||||||
* pattern that will be overwritten.
|
* pattern that will be overwritten.
|
||||||
|
* @throws IllegalArgumentException If either in or out contain only empty
|
||||||
|
* ItemStacks.
|
||||||
* @return A new encoded pattern, or the given stack with the pattern encoded in
|
* @return A new encoded pattern, or the given stack with the pattern encoded in
|
||||||
* it.
|
* it.
|
||||||
*/
|
*/
|
||||||
@@ -73,6 +75,8 @@ public interface ICraftingHelper {
|
|||||||
* operation by the ME system.
|
* operation by the ME system.
|
||||||
* @param allowSubstitutes Controls whether the ME system will allow the use of
|
* @param allowSubstitutes Controls whether the ME system will allow the use of
|
||||||
* equivalent items to craft this recipe.
|
* equivalent items to craft this recipe.
|
||||||
|
* @throws IllegalArgumentException If either in or out contain only empty
|
||||||
|
* ItemStacks.
|
||||||
*/
|
*/
|
||||||
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
|
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
|
||||||
boolean allowSubstitutes);
|
boolean allowSubstitutes);
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013 AlgorithmX2
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
|
||||||
* the Software without restriction, including without limitation the rights to
|
|
||||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package appeng.api.implementations;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines the result of performing a transition from the world into a storage
|
|
||||||
* cell, if its possible, and what the energy usage is.
|
|
||||||
*/
|
|
||||||
public class TransitionResult {
|
|
||||||
public final boolean success;
|
|
||||||
public final double energyUsage;
|
|
||||||
|
|
||||||
public TransitionResult(final boolean success, final double power) {
|
|
||||||
this.success = success;
|
|
||||||
this.energyUsage = power;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,13 +23,23 @@
|
|||||||
|
|
||||||
package appeng.api.implementations.items;
|
package appeng.api.implementations.items;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IGrowableCrystal {
|
public interface IGrowableCrystal {
|
||||||
|
|
||||||
ItemStack triggerGrowth(ItemStack is);
|
ItemStack triggerGrowth(ItemStack is);
|
||||||
|
|
||||||
float getMultiplier(Block blk, Material mat);
|
/**
|
||||||
|
* Gets the crystal growth multiplier based on the material it is submerged in.
|
||||||
|
*
|
||||||
|
* @param state The blockstate of the block the crystal is currently in.
|
||||||
|
* @return The multiplier for the growth tick progress. Zero if the crystal
|
||||||
|
* cannot grow in the current material.
|
||||||
|
*/
|
||||||
|
float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,8 @@ package appeng.api.implementations.items;
|
|||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.RegistryKey;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
import appeng.api.implementations.TransitionResult;
|
|
||||||
import appeng.api.util.WorldCoord;
|
import appeng.api.util.WorldCoord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,13 +49,13 @@ public interface ISpatialStorageCell {
|
|||||||
int getMaxStoredDim(ItemStack is);
|
int getMaxStoredDim(ItemStack is);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the currently stored Dimension id.
|
* get the currently stored spatial storage plot id.
|
||||||
*
|
*
|
||||||
* @param is spatial storage cell
|
* @param is spatial storage cell
|
||||||
*
|
*
|
||||||
* @return dimension id or -1
|
* @return plot id or -1
|
||||||
*/
|
*/
|
||||||
RegistryKey<World> getStoredDimension(ItemStack is);
|
int getAllocatedPlotId(ItemStack is);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a spatial swap with the contents of the cell, and the world.
|
* Perform a spatial swap with the contents of the cell, and the world.
|
||||||
@@ -69,7 +66,7 @@ public interface ISpatialStorageCell {
|
|||||||
* @param max max coord
|
* @param max max coord
|
||||||
* @param playerId owner of current grid or -1
|
* @param playerId owner of current grid or -1
|
||||||
*
|
*
|
||||||
* @return result of transition
|
* @return success of transition
|
||||||
*/
|
*/
|
||||||
TransitionResult doSpatialTransition(ItemStack is, ServerWorld w, WorldCoord min, WorldCoord max, int playerId);
|
boolean doSpatialTransition(ItemStack is, ServerWorld w, WorldCoord min, WorldCoord max, int playerId);
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.capabilities.CapabilityProvider;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
@@ -346,10 +347,12 @@ public interface IPart extends ICustomCableConnection {
|
|||||||
* capabilities on the cable bus will be forwarded to parts on the appropriate
|
* capabilities on the cable bus will be forwarded to parts on the appropriate
|
||||||
* side.
|
* side.
|
||||||
*
|
*
|
||||||
* @see TileEntity#getCapability(Capability, net.minecraft.util.Direction)
|
* @see CapabilityProvider#getCapability(Capability,
|
||||||
|
* net.minecraft.util.Direction)
|
||||||
*
|
*
|
||||||
* @return The capability or null.
|
* @return The capability
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
default <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
|
default <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
|
||||||
return LazyOptional.empty();
|
return LazyOptional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Applied Energistics 2.
|
|
||||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package appeng.api.storage;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.util.RegistryKey;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.server.ServerWorld;
|
|
||||||
|
|
||||||
public interface ISpatialDimension {
|
|
||||||
ServerWorld getWorld(RegistryKey<World> cellDim);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
RegistryKey<World> createNewCellDimension(BlockPos capacity);
|
|
||||||
|
|
||||||
void deleteCellDimension(RegistryKey<World> cellDim);
|
|
||||||
|
|
||||||
boolean isCellDimension(RegistryKey<World> cellDim);
|
|
||||||
|
|
||||||
BlockPos getCellDimensionOrigin(RegistryKey<World> cellDim);
|
|
||||||
|
|
||||||
BlockPos getCellDimensionSize(RegistryKey<World> cellDim);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a user-facing tooltip that describes this dimension so that a player can
|
|
||||||
* keep storage cells apart.
|
|
||||||
*/
|
|
||||||
void addCellDimensionTooltip(RegistryKey<World> cellDim, List<ITextComponent> lines);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -27,13 +27,14 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.DimensionType;
|
import net.minecraft.world.DimensionType;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a location in the Minecraft Universe
|
* Represents a location in the Minecraft Universe
|
||||||
*/
|
*/
|
||||||
public class DimensionalCoord extends WorldCoord {
|
public class DimensionalCoord extends WorldCoord {
|
||||||
|
|
||||||
private final IWorld world;
|
private final World world;
|
||||||
private final DimensionType dimension;
|
private final DimensionType dimension;
|
||||||
|
|
||||||
public DimensionalCoord(final DimensionalCoord coordinate) {
|
public DimensionalCoord(final DimensionalCoord coordinate) {
|
||||||
@@ -48,13 +49,13 @@ public class DimensionalCoord extends WorldCoord {
|
|||||||
this.dimension = this.world.func_230315_m_();
|
this.dimension = this.world.func_230315_m_();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimensionalCoord(final IWorld world, final int x, final int y, final int z) {
|
public DimensionalCoord(final World world, final int x, final int y, final int z) {
|
||||||
super(x, y, z);
|
super(x, y, z);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.dimension = world.func_230315_m_();
|
this.dimension = world.func_230315_m_();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimensionalCoord(final IWorld world, final BlockPos pos) {
|
public DimensionalCoord(final World world, final BlockPos pos) {
|
||||||
super(pos);
|
super(pos);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.dimension = world.func_230315_m_();
|
this.dimension = world.func_230315_m_();
|
||||||
@@ -84,7 +85,7 @@ public class DimensionalCoord extends WorldCoord {
|
|||||||
return this.world == world;
|
return this.world == world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWorld getWorld() {
|
public World getWorld() {
|
||||||
return this.world;
|
return this.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.item.ItemModelsProperties;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -45,14 +43,6 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
|
|||||||
|
|
||||||
public AEBaseBlockItemChargeable(Block id, Properties props) {
|
public AEBaseBlockItemChargeable(Block id, Properties props) {
|
||||||
super(id, props);
|
super(id, props);
|
||||||
|
|
||||||
ItemModelsProperties.func_239418_a_(this, new ResourceLocation("appliedenergistics2:fill_level"),
|
|
||||||
(is, world, entity) -> {
|
|
||||||
double curPower = getAECurrentPower(is);
|
|
||||||
double maxPower = getAEMaxPower(is);
|
|
||||||
|
|
||||||
return (int) Math.round(100 * curPower / maxPower);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -111,11 +111,6 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
|
|||||||
return this.tileEntityFactory.get();
|
return this.tileEntityFactory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
|
|
||||||
super.dropXpOnBlockBreak(worldIn, pos, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (newState.getBlock() == state.getBlock()) {
|
if (newState.getBlock() == state.getBlock()) {
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package appeng.block.crafting;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||||
|
import appeng.bootstrap.IBlockRendering;
|
||||||
|
import appeng.bootstrap.IItemRendering;
|
||||||
|
import appeng.client.render.crafting.MonitorBakedModel;
|
||||||
|
import appeng.client.render.model.AutoRotatingBakedModel;
|
||||||
|
|
||||||
|
public class CraftingMonitorBlockRendering extends BlockRenderingCustomizer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||||
|
rendering.renderType(RenderType.getCutout());
|
||||||
|
rendering.modelCustomizer(CraftingMonitorBlockRendering::customizeModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static IBakedModel customizeModel(ResourceLocation path, IBakedModel model) {
|
||||||
|
// The formed model handles rotations itself, the unformed one does not
|
||||||
|
if (model instanceof MonitorBakedModel) {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
return new AutoRotatingBakedModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,18 +19,12 @@
|
|||||||
package appeng.block.misc;
|
package appeng.block.misc;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
@@ -42,8 +36,6 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
|||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
@@ -52,8 +44,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||||||
import appeng.api.util.AEAxisAlignedBB;
|
import appeng.api.util.AEAxisAlignedBB;
|
||||||
import appeng.block.AEBaseTileBlock;
|
import appeng.block.AEBaseTileBlock;
|
||||||
import appeng.client.render.effects.ParticleTypes;
|
import appeng.client.render.effects.ParticleTypes;
|
||||||
import appeng.client.render.renderable.ItemRenderable;
|
|
||||||
import appeng.client.render.tesr.ModularTESR;
|
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.Api;
|
import appeng.core.Api;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
@@ -175,15 +165,4 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
|
|||||||
return VoxelShapes.create(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
|
return VoxelShapes.create(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<ChargerTileEntity>> createTesr() {
|
|
||||||
return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(ChargerBlock::getRenderedItem));
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerTileEntity tile) {
|
|
||||||
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
|
|
||||||
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package appeng.block.networking;
|
package appeng.block.networking;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@@ -51,7 +53,7 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getString() {
|
public String getString() {
|
||||||
return this.name().toLowerCase();
|
return this.name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
|
|||||||
|
|
||||||
if (s.isLumen()) {
|
if (s.isLumen()) {
|
||||||
builder.setColorRGB(s.getColor().whiteVariant);
|
builder.setColorRGB(s.getColor().whiteVariant);
|
||||||
builder.setRenderFullBright(true);
|
builder.setEmissiveMaterial(true);
|
||||||
} else {
|
} else {
|
||||||
builder.setColorRGB(s.getColor().mediumVariant);
|
builder.setColorRGB(s.getColor().mediumVariant);
|
||||||
builder.setRenderFullBright(false);
|
builder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
float offset = offsetConstant;
|
float offset = offsetConstant;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
|||||||
|
|
||||||
if (formedState.isPowered()) {
|
if (formedState.isPowered()) {
|
||||||
builder.setTexture(this.lightCornerTexture);
|
builder.setTexture(this.lightCornerTexture);
|
||||||
builder.setRenderFullBright(true);
|
builder.setEmissiveMaterial(true);
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||||
// ring texture
|
// ring texture
|
||||||
@@ -131,6 +131,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
|||||||
DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MAX + xOffset,
|
DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MAX + xOffset,
|
||||||
DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset);
|
DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset);
|
||||||
}
|
}
|
||||||
|
builder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.setTexture(this.ringTexture);
|
builder.setTexture(this.ringTexture);
|
||||||
@@ -143,7 +144,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
|||||||
|
|
||||||
if (formedState.isPowered()) {
|
if (formedState.isPowered()) {
|
||||||
builder.setTexture(this.lightTexture);
|
builder.setTexture(this.lightTexture);
|
||||||
builder.setRenderFullBright(true);
|
builder.setEmissiveMaterial(true);
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
// Offset the face by a slight amount so that it is drawn over the already drawn
|
// Offset the face by a slight amount so that it is drawn over the already drawn
|
||||||
// ring texture
|
// ring texture
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package appeng.block.storage;
|
package appeng.block.storage;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
@@ -47,7 +50,18 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
|
|||||||
|
|
||||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||||
private static final double AABB_OFFSET_TOP = 0.125;
|
private static final double AABB_OFFSET_TOP = 0.0625;
|
||||||
|
|
||||||
|
// Precomputed bounding boxes of the chest, sorted into the map by the UP
|
||||||
|
// direction
|
||||||
|
private static final Map<Direction, VoxelShape> SHAPES = new EnumMap<>(Direction.class);
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (Direction up : Direction.values()) {
|
||||||
|
AxisAlignedBB aabb = computeAABB(up);
|
||||||
|
SHAPES.put(up, VoxelShapes.create(aabb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum SkyChestType {
|
public enum SkyChestType {
|
||||||
STONE, BLOCK
|
STONE, BLOCK
|
||||||
@@ -87,37 +101,30 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
// TODO Cache this! It can't be that hard!
|
final SkyChestTileEntity sk = this.getTileEntity(worldIn, pos);
|
||||||
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
Direction up = sk != null ? sk.getUp() : Direction.UP;
|
||||||
return VoxelShapes.create(aabb);
|
return SHAPES.get(up);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) {
|
private static AxisAlignedBB computeAABB(Direction up) {
|
||||||
final SkyChestTileEntity sk = this.getTileEntity(w, pos);
|
final double offsetX = up.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||||
Direction o = Direction.UP;
|
final double offsetY = up.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||||
|
final double offsetZ = up.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||||
if (sk != null) {
|
|
||||||
o = sk.getUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
|
||||||
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
|
||||||
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
|
||||||
|
|
||||||
// for x/z top and bottom is swapped
|
// for x/z top and bottom is swapped
|
||||||
final double minX = Math.max(0.0,
|
final double minX = Math.max(0.0,
|
||||||
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP)));
|
offsetX + (up.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getXOffset() * AABB_OFFSET_TOP)));
|
||||||
final double minY = Math.max(0.0,
|
final double minY = Math.max(0.0,
|
||||||
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM)));
|
offsetY + (up.getYOffset() < 0 ? AABB_OFFSET_TOP : (up.getYOffset() * AABB_OFFSET_BOTTOM)));
|
||||||
final double minZ = Math.max(0.0,
|
final double minZ = Math.max(0.0,
|
||||||
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP)));
|
offsetZ + (up.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getZOffset() * AABB_OFFSET_TOP)));
|
||||||
|
|
||||||
final double maxX = Math.min(1.0,
|
final double maxX = Math.min(1.0,
|
||||||
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM)));
|
1.0 - offsetX - (up.getXOffset() < 0 ? AABB_OFFSET_TOP : (up.getXOffset() * AABB_OFFSET_BOTTOM)));
|
||||||
final double maxY = Math.min(1.0,
|
final double maxY = Math.min(1.0,
|
||||||
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP)));
|
1.0 - offsetY - (up.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getYOffset() * AABB_OFFSET_TOP)));
|
||||||
final double maxZ = Math.min(1.0,
|
final double maxZ = Math.min(1.0,
|
||||||
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM)));
|
1.0 - offsetZ - (up.getZOffset() < 0 ? AABB_OFFSET_TOP : (up.getZOffset() * AABB_OFFSET_BOTTOM)));
|
||||||
|
|
||||||
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.ItemModelsProperties;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@@ -38,8 +40,10 @@ import appeng.api.definitions.IBlockDefinition;
|
|||||||
import appeng.api.features.AEFeature;
|
import appeng.api.features.AEFeature;
|
||||||
import appeng.block.AEBaseBlock;
|
import appeng.block.AEBaseBlock;
|
||||||
import appeng.block.AEBaseBlockItem;
|
import appeng.block.AEBaseBlockItem;
|
||||||
|
import appeng.block.AEBaseBlockItemChargeable;
|
||||||
import appeng.block.AEBaseTileBlock;
|
import appeng.block.AEBaseTileBlock;
|
||||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||||
|
import appeng.bootstrap.components.IClientSetupComponent;
|
||||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
import appeng.core.AEItemGroup;
|
import appeng.core.AEItemGroup;
|
||||||
@@ -149,6 +153,24 @@ class BlockDefinitionBuilder implements IBlockBuilder {
|
|||||||
item.setRegistryName(AppEng.MOD_ID, this.registryName);
|
item.setRegistryName(AppEng.MOD_ID, this.registryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register the client-only item model property for chargeable items
|
||||||
|
if (item instanceof AEBaseBlockItemChargeable) {
|
||||||
|
AEBaseBlockItemChargeable chargeable = (AEBaseBlockItemChargeable) item;
|
||||||
|
this.factory.addBootstrapComponent(new IClientSetupComponent() {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void setup() {
|
||||||
|
ItemModelsProperties.func_239418_a_(item, new ResourceLocation("appliedenergistics2:fill_level"),
|
||||||
|
(is, world, entity) -> {
|
||||||
|
double curPower = chargeable.getAECurrentPower(is);
|
||||||
|
double maxPower = chargeable.getAEMaxPower(is);
|
||||||
|
|
||||||
|
return (int) Math.round(100 * curPower / maxPower);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Register the item and block with the game
|
// Register the item and block with the game
|
||||||
this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
|
this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
package appeng.client;
|
package appeng.client;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public enum ActionKey {
|
public enum ActionKey {
|
||||||
@@ -13,7 +15,7 @@ public enum ActionKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getTranslationKey() {
|
public String getTranslationKey() {
|
||||||
return "key." + this.name().toLowerCase() + ".desc";
|
return "key." + this.name().toLowerCase(Locale.ROOT) + ".desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultKey() {
|
public int getDefaultKey() {
|
||||||
|
|||||||
@@ -138,15 +138,15 @@ public class ClientHelper extends ServerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CableRenderMode getRenderMode() {
|
public CableRenderMode getCableRenderMode() {
|
||||||
if (Platform.isServer()) {
|
if (Platform.isServer()) {
|
||||||
return super.getRenderMode();
|
return super.getCableRenderMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Minecraft mc = Minecraft.getInstance();
|
final Minecraft mc = Minecraft.getInstance();
|
||||||
final PlayerEntity player = mc.player;
|
final PlayerEntity player = mc.player;
|
||||||
|
|
||||||
return this.renderModeForPlayer(player);
|
return this.getCableRenderModeForPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.text.NumberFormat;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
@@ -72,14 +73,16 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
|
|||||||
currentToolTip.add(ButtonToolTips.ItemsRequestable.text(formattedAmount));
|
currentToolTip.add(ButtonToolTips.ItemsRequestable.text(formattedAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderToolTip(matrixStack, currentToolTip, x, y, this.font);
|
this.renderToolTip(matrixStack, Lists.transform(currentToolTip, ITextComponent::func_241878_f), x, y,
|
||||||
|
this.font);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (stack.getCount() > bigNumber) {
|
} else if (stack.getCount() > bigNumber) {
|
||||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
|
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
|
||||||
currentToolTip.add(ButtonToolTips.ItemsStored.text(formattedAmount).mergeStyle(TextFormatting.GRAY));
|
currentToolTip.add(ButtonToolTips.ItemsStored.text(formattedAmount).mergeStyle(TextFormatting.GRAY));
|
||||||
|
|
||||||
this.renderToolTip(matrixStack, currentToolTip, x, y, this.font);
|
this.renderToolTip(matrixStack, Lists.transform(currentToolTip, ITextComponent::func_241878_f), x, y,
|
||||||
|
this.font);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,14 +158,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
|||||||
protected void drawGuiSlot(MatrixStack matrixStack, CustomSlotWidget slot, int mouseX, int mouseY,
|
protected void drawGuiSlot(MatrixStack matrixStack, CustomSlotWidget slot, int mouseX, int mouseY,
|
||||||
float partialTicks) {
|
float partialTicks) {
|
||||||
if (slot.isSlotEnabled()) {
|
if (slot.isSlotEnabled()) {
|
||||||
final int left = slot.xPos();
|
final int left = slot.getTooltipAreaX();
|
||||||
final int top = slot.yPos();
|
final int top = slot.getTooltipAreaY();
|
||||||
final int right = left + slot.getWidth();
|
final int right = left + slot.getTooltipAreaWidth();
|
||||||
final int bottom = top + slot.getHeight();
|
final int bottom = top + slot.getTooltipAreaHeight();
|
||||||
|
|
||||||
slot.drawContent(matrixStack, getMinecraft(), mouseX, mouseY, partialTicks);
|
slot.drawContent(matrixStack, getMinecraft(), mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
|
if (this.isPointInRegion(left, top, slot.getTooltipAreaWidth(), slot.getTooltipAreaHeight(), mouseX, mouseY)
|
||||||
&& slot.canClick(getPlayer())) {
|
&& slot.canClick(getPlayer())) {
|
||||||
RenderSystem.colorMask(true, true, true, false);
|
RenderSystem.colorMask(true, true, true, false);
|
||||||
this.fillGradient(matrixStack, left, top, right, bottom, -2130706433, -2130706433);
|
this.fillGradient(matrixStack, left, top, right, bottom, -2130706433, -2130706433);
|
||||||
@@ -175,26 +175,30 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawTooltip(MatrixStack matrixStack, ITooltip tooltip, int mouseX, int mouseY) {
|
private void drawTooltip(MatrixStack matrixStack, ITooltip tooltip, int mouseX, int mouseY) {
|
||||||
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
|
final int x = tooltip.getTooltipAreaX();
|
||||||
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
|
int y = tooltip.getTooltipAreaY();
|
||||||
|
|
||||||
if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) {
|
if (x < mouseX && x + tooltip.getTooltipAreaWidth() > mouseX && tooltip.isTooltipAreaVisible()) {
|
||||||
if (y < mouseY && y + tooltip.getHeight() > mouseY) {
|
if (y < mouseY && y + tooltip.getTooltipAreaHeight() > mouseY) {
|
||||||
if (y < 15) {
|
if (y < 15) {
|
||||||
y = 15;
|
y = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ITextComponent msg = tooltip.getMessage();
|
final ITextComponent msg = tooltip.getTooltipMessage();
|
||||||
this.drawTooltip(matrixStack, x + 11, y + 4, msg);
|
this.drawTooltip(matrixStack, x + 11, y + 4, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawTooltip(MatrixStack matrices, int x, int y, ITextComponent message) {
|
protected void drawTooltip(MatrixStack matrices, int x, int y, ITextComponent message) {
|
||||||
String[] lines = message.getString().split("\n"); // FIXME FABRIC
|
String tooltipText = message.getString();
|
||||||
List<ITextComponent> textLines = Arrays.stream(lines).map(StringTextComponent::new)
|
|
||||||
.collect(Collectors.toList());
|
if (!tooltipText.isEmpty()) {
|
||||||
this.drawTooltip(matrices, x, y, textLines);
|
String[] lines = tooltipText.split("\n"); // FIXME FABRIC
|
||||||
|
List<ITextComponent> textLines = Arrays.stream(lines).map(StringTextComponent::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
this.drawTooltip(matrices, x, y, textLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME FABRIC: move out to json (?)
|
// FIXME FABRIC: move out to json (?)
|
||||||
@@ -214,7 +218,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
|||||||
styledLines.add(lines.get(i).deepCopy().modifyStyle(s -> style));
|
styledLines.add(lines.get(i).deepCopy().modifyStyle(s -> style));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderTooltip(matrices, styledLines, x, y);
|
this.func_243308_b(matrices, styledLines, x, y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,8 +285,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CustomSlotWidget slot : this.guiSlots) {
|
for (CustomSlotWidget slot : this.guiSlots) {
|
||||||
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
|
if (this.isPointInRegion(slot.getTooltipAreaX(), slot.getTooltipAreaY(), slot.getTooltipAreaWidth(),
|
||||||
&& slot.canClick(getPlayer())) {
|
slot.getTooltipAreaHeight(), xCoord, yCoord) && slot.canClick(getPlayer())) {
|
||||||
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
|
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,18 @@ import net.minecraft.inventory.container.Slot;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A proxy for a slot that will always return an itemstack with size 1, if there
|
* A proxy for a slot that will always return an itemstack with size 1, if there
|
||||||
* is an item in the slot. Used to prevent the default item count from
|
* is an item in the slot. Used to prevent the default item count from
|
||||||
* rendering.
|
* rendering.
|
||||||
*/
|
*/
|
||||||
class Size1Slot extends SlotItemHandler {
|
class Size1Slot extends Slot {
|
||||||
|
|
||||||
private final SlotItemHandler delegate;
|
private final Slot delegate;
|
||||||
|
|
||||||
public Size1Slot(SlotItemHandler delegate) {
|
public Size1Slot(Slot delegate) {
|
||||||
super(delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
|
super(delegate.inventory, delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
|||||||
this.searchField.setMaxStringLength(25);
|
this.searchField.setMaxStringLength(25);
|
||||||
this.searchField.setTextColor(0xFFFFFF);
|
this.searchField.setTextColor(0xFFFFFF);
|
||||||
this.searchField.setVisible(true);
|
this.searchField.setVisible(true);
|
||||||
this.searchField.setFocused2(true);
|
this.searchField.setResponder(str -> this.refreshList());
|
||||||
|
this.addListener(this.searchField);
|
||||||
|
this.changeFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,11 +133,8 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
this.searchField.setText("");
|
||||||
this.searchField.setText("");
|
|
||||||
this.refreshList();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,11 +172,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
|||||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.searchField.charTyped(character, key)) {
|
return super.charTyped(character, key);
|
||||||
this.refreshList();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -245,7 +240,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuilds the list of interfaces.
|
* Rebuilds the list of interfaces.
|
||||||
*
|
* <p>
|
||||||
* Respects a search term if present (ignores case) and adding only matching
|
* Respects a search term if present (ignores case) and adding only matching
|
||||||
* patterns.
|
* patterns.
|
||||||
*/
|
*/
|
||||||
@@ -338,12 +333,11 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to retrieve a cache for a with search term as keyword.
|
* Tries to retrieve a cache for a with search term as keyword.
|
||||||
*
|
* <p>
|
||||||
* If this cache should be empty, it will populate it with an earlier cache if
|
* If this cache should be empty, it will populate it with an earlier cache if
|
||||||
* available or at least the cache for the empty string.
|
* available or at least the cache for the empty string.
|
||||||
*
|
*
|
||||||
* @param searchTerm the corresponding search
|
* @param searchTerm the corresponding search
|
||||||
*
|
|
||||||
* @return a Set matching a superset of the search term
|
* @return a Set matching a superset of the search term
|
||||||
*/
|
*/
|
||||||
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package appeng.client.gui.implementations;
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.LongConsumer;
|
import java.util.function.LongConsumer;
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ import appeng.core.AEConfig;
|
|||||||
public class NumberEntryWidget implements ITickingWidget {
|
public class NumberEntryWidget implements ITickingWidget {
|
||||||
|
|
||||||
private static final ITextComponent PLUS = new StringTextComponent("+");
|
private static final ITextComponent PLUS = new StringTextComponent("+");
|
||||||
private static final ITextComponent MINUS = new StringTextComponent("+");
|
private static final ITextComponent MINUS = new StringTextComponent("-");
|
||||||
|
|
||||||
private final AEBaseScreen<?> parent;
|
private final AEBaseScreen<?> parent;
|
||||||
|
|
||||||
@@ -33,14 +35,7 @@ public class NumberEntryWidget implements ITickingWidget {
|
|||||||
|
|
||||||
private final NumberBox level;
|
private final NumberBox level;
|
||||||
private final NumberEntryType type;
|
private final NumberEntryType type;
|
||||||
private Button plus1;
|
private List<Button> buttons;
|
||||||
private Button plus10;
|
|
||||||
private Button plus100;
|
|
||||||
private Button plus1000;
|
|
||||||
private Button minus1;
|
|
||||||
private Button minus10;
|
|
||||||
private Button minus100;
|
|
||||||
private Button minus1000;
|
|
||||||
|
|
||||||
public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, NumberEntryType type,
|
public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, NumberEntryType type,
|
||||||
LongConsumer changeListener) {
|
LongConsumer changeListener) {
|
||||||
@@ -63,14 +58,7 @@ public class NumberEntryWidget implements ITickingWidget {
|
|||||||
|
|
||||||
public void setActive(boolean active) {
|
public void setActive(boolean active) {
|
||||||
this.level.setEnabled(active);
|
this.level.setEnabled(active);
|
||||||
this.plus1.active = active;
|
this.buttons.forEach(b -> b.active = active);
|
||||||
this.plus10.active = active;
|
|
||||||
this.plus100.active = active;
|
|
||||||
this.plus1000.active = active;
|
|
||||||
this.minus1.active = active;
|
|
||||||
this.minus10.active = active;
|
|
||||||
this.minus100.active = active;
|
|
||||||
this.minus1000.active = active;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextFieldBounds(int x, int y, int width) {
|
public void setTextFieldBounds(int x, int y, int width) {
|
||||||
@@ -93,18 +81,23 @@ public class NumberEntryWidget implements ITickingWidget {
|
|||||||
int left = parent.getGuiLeft() + x;
|
int left = parent.getGuiLeft() + x;
|
||||||
int top = parent.getGuiTop() + y;
|
int top = parent.getGuiTop() + y;
|
||||||
|
|
||||||
addButton.accept(this.plus1 = new Button(left, top, 22, 20, PLUS /* + a */, btn -> addQty(a)));
|
List<Button> buttons = new ArrayList<>(8);
|
||||||
addButton.accept(this.plus10 = new Button(left + 28, top, 28, 20, PLUS /* + b */, btn -> addQty(b)));
|
|
||||||
addButton.accept(this.plus100 = new Button(left + 62, top, 32, 20, PLUS /* + c */, btn -> addQty(c)));
|
buttons.add(new Button(left, top, 22, 20, makeLabel(PLUS, a), btn -> addQty(a)));
|
||||||
addButton.accept(this.plus1000 = new Button(left + 100, top, 38, 20, PLUS/* + d */, btn -> addQty(d)));
|
buttons.add(new Button(left + 28, top, 28, 20, makeLabel(PLUS, b), btn -> addQty(b)));
|
||||||
|
buttons.add(new Button(left + 62, top, 32, 20, makeLabel(PLUS, c), btn -> addQty(c)));
|
||||||
|
buttons.add(new Button(left + 100, top, 38, 20, makeLabel(PLUS, d), btn -> addQty(d)));
|
||||||
|
|
||||||
// Placing this here will give a sensible tab order
|
// Placing this here will give a sensible tab order
|
||||||
addChildren.accept(this.level);
|
addChildren.accept(this.level);
|
||||||
|
|
||||||
addButton.accept(this.minus1 = new Button(left, top + 42, 22, 20, MINUS /* + a */, btn -> addQty(-a)));
|
buttons.add(new Button(left, top + 42, 22, 20, makeLabel(MINUS, a), btn -> addQty(-a)));
|
||||||
addButton.accept(this.minus10 = new Button(left + 28, top + 42, 28, 20, MINUS /* + b */, btn -> addQty(-b)));
|
buttons.add(new Button(left + 28, top + 42, 28, 20, makeLabel(MINUS, b), btn -> addQty(-b)));
|
||||||
addButton.accept(this.minus100 = new Button(left + 62, top + 42, 32, 20, MINUS /* + c */, btn -> addQty(-c)));
|
buttons.add(new Button(left + 62, top + 42, 32, 20, makeLabel(MINUS, c), btn -> addQty(-c)));
|
||||||
addButton.accept(this.minus1000 = new Button(left + 100, top + 42, 38, 20, MINUS /* + d */, btn -> addQty(-d)));
|
buttons.add(new Button(left + 100, top + 42, 38, 20, makeLabel(MINUS, d), btn -> addQty(-d)));
|
||||||
|
|
||||||
|
this.buttons = buttons;
|
||||||
|
this.buttons.forEach(addButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addQty(final long i) {
|
private void addQty(final long i) {
|
||||||
@@ -134,4 +127,8 @@ public class NumberEntryWidget implements ITickingWidget {
|
|||||||
this.level.tick();
|
this.level.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ITextComponent makeLabel(ITextComponent prefix, int amount) {
|
||||||
|
return prefix.copyRaw().appendString(String.valueOf(amount));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import net.minecraft.util.text.StringTextComponent;
|
|||||||
import appeng.api.config.ActionItems;
|
import appeng.api.config.ActionItems;
|
||||||
import appeng.core.localization.ButtonToolTips;
|
import appeng.core.localization.ButtonToolTips;
|
||||||
|
|
||||||
public class ActionButton extends IconButton implements ITooltip {
|
public class ActionButton extends IconButton {
|
||||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||||
private final int iconIndex;
|
private final int iconIndex;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.AbstractGui;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
||||||
public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
|
public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
|
||||||
private final int x;
|
private final int x;
|
||||||
@@ -38,32 +39,32 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getMessage() {
|
public ITextComponent getTooltipMessage() {
|
||||||
return null;
|
return StringTextComponent.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int xPos() {
|
public int getTooltipAreaX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos() {
|
public int getTooltipAreaY() {
|
||||||
return this.y;
|
return this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getTooltipAreaWidth() {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getTooltipAreaHeight() {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isTooltipAreaVisible() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
package appeng.client.gui.widgets;
|
package appeng.client.gui.widgets;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AEBaseGui controlled Tooltip Interface.
|
* AEBaseGui controlled Tooltip Interface.
|
||||||
@@ -26,42 +29,45 @@ import net.minecraft.util.text.ITextComponent;
|
|||||||
public interface ITooltip {
|
public interface ITooltip {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the tooltip message.
|
* Returns the tooltip message.
|
||||||
|
*
|
||||||
|
* Should use {@link StringTextComponent#EMPTY} for no tooltip
|
||||||
*
|
*
|
||||||
* @return tooltip message
|
* @return tooltip message
|
||||||
*/
|
*/
|
||||||
ITextComponent getMessage();
|
@Nonnull
|
||||||
|
ITextComponent getTooltipMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* x Location for the object that triggers the tooltip.
|
* x Location for the object that triggers the tooltip.
|
||||||
*
|
*
|
||||||
* @return xPosition
|
* @return xPosition
|
||||||
*/
|
*/
|
||||||
int xPos();
|
int getTooltipAreaX();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* y Location for the object that triggers the tooltip.
|
* y Location for the object that triggers the tooltip.
|
||||||
*
|
*
|
||||||
* @return yPosition
|
* @return yPosition
|
||||||
*/
|
*/
|
||||||
int yPos();
|
int getTooltipAreaY();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Width of the object that triggers the tooltip.
|
* Width of the object that triggers the tooltip.
|
||||||
*
|
*
|
||||||
* @return width
|
* @return width
|
||||||
*/
|
*/
|
||||||
int getWidth();
|
int getTooltipAreaWidth();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height for the object that triggers the tooltip.
|
* Height for the object that triggers the tooltip.
|
||||||
*
|
*
|
||||||
* @return height
|
* @return height
|
||||||
*/
|
*/
|
||||||
int getHeight();
|
int getTooltipAreaHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if button being drawn
|
* @return true if button being drawn
|
||||||
*/
|
*/
|
||||||
boolean isVisible();
|
boolean isTooltipAreaVisible();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||||
|
|
||||||
@@ -97,27 +98,32 @@ public abstract class IconButton extends Button implements ITooltip {
|
|||||||
protected abstract int getIconIndex();
|
protected abstract int getIconIndex();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int xPos() {
|
public ITextComponent getTooltipMessage() {
|
||||||
|
return getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTooltipAreaX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos() {
|
public int getTooltipAreaY() {
|
||||||
return this.y;
|
return this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getTooltipAreaWidth() {
|
||||||
return this.halfSize ? 8 : 16;
|
return this.halfSize ? 8 : 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getTooltipAreaHeight() {
|
||||||
return this.halfSize ? 8 : 16;
|
return this.halfSize ? 8 : 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isTooltipAreaVisible() {
|
||||||
return this.visible;
|
return this.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class ProgressBar extends Widget implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getMessage() {
|
public ITextComponent getTooltipMessage() {
|
||||||
if (this.fullMsg != null) {
|
if (this.fullMsg != null) {
|
||||||
return this.fullMsg;
|
return this.fullMsg;
|
||||||
}
|
}
|
||||||
@@ -92,27 +92,27 @@ public class ProgressBar extends Widget implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int xPos() {
|
public int getTooltipAreaX() {
|
||||||
return this.x - 2;
|
return this.x - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos() {
|
public int getTooltipAreaY() {
|
||||||
return this.y - 2;
|
return this.y - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getTooltipAreaWidth() {
|
||||||
return this.width + 4;
|
return this.width + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getTooltipAreaHeight() {
|
||||||
return this.height + 4;
|
return this.height + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isTooltipAreaVisible() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getMessage() {
|
public ITextComponent getTooltipMessage() {
|
||||||
ITextComponent displayName = null;
|
ITextComponent displayName = null;
|
||||||
ITextComponent displayValue = null;
|
ITextComponent displayValue = null;
|
||||||
|
|
||||||
|
|||||||
@@ -99,27 +99,32 @@ public class TabButton extends Button implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int xPos() {
|
public ITextComponent getTooltipMessage() {
|
||||||
|
return getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTooltipAreaX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos() {
|
public int getTooltipAreaY() {
|
||||||
return this.y;
|
return this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getTooltipAreaWidth() {
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getTooltipAreaHeight() {
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isTooltipAreaVisible() {
|
||||||
return this.visible;
|
return this.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ToggleButton extends Button implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getMessage() {
|
public ITextComponent getTooltipMessage() {
|
||||||
if (this.displayName != null) {
|
if (this.displayName != null) {
|
||||||
String name = I18n.format(this.displayName);
|
String name = I18n.format(this.displayName);
|
||||||
String value = I18n.format(this.displayHint);
|
String value = I18n.format(this.displayHint);
|
||||||
@@ -106,27 +106,27 @@ public class ToggleButton extends Button implements ITooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int xPos() {
|
public int getTooltipAreaX() {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos() {
|
public int getTooltipAreaY() {
|
||||||
return this.y;
|
return this.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getTooltipAreaWidth() {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() {
|
public int getTooltipAreaHeight() {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isTooltipAreaVisible() {
|
||||||
return this.visible;
|
return this.visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,6 @@ import appeng.fluids.util.FluidSorters;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.prioritylist.IPartitionList;
|
import appeng.util.prioritylist.IPartitionList;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author BrockWS
|
|
||||||
* @version rv6 - 22/05/2018
|
|
||||||
* @since rv6 22/05/2018
|
|
||||||
*/
|
|
||||||
public class FluidRepo {
|
public class FluidRepo {
|
||||||
private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
|
private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
|
||||||
.createList();
|
.createList();
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ public class SlotDisconnected extends AppEngSlot {
|
|||||||
|
|
||||||
private final ClientDCInternalInv mySlot;
|
private final ClientDCInternalInv mySlot;
|
||||||
|
|
||||||
public SlotDisconnected(final ClientDCInternalInv me, final int which, final int x, final int y) {
|
public SlotDisconnected(final ClientDCInternalInv me, final int invSlot, final int x, final int y) {
|
||||||
super(me.getInventory(), which, x, y);
|
super(me.getInventory(), invSlot, x, y);
|
||||||
this.mySlot = me;
|
this.mySlot = me;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class SlotDisconnected extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,23 +21,22 @@ package appeng.client.me;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||||
|
|
||||||
/**
|
public class SlotFluidME extends Slot implements IMEFluidSlot {
|
||||||
* @author BrockWS
|
|
||||||
* @version rv6 - 22/05/2018
|
|
||||||
* @since rv6 22/05/2018
|
|
||||||
*/
|
|
||||||
public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
|
|
||||||
|
|
||||||
private InternalFluidSlotME slot;
|
private static final IInventory EMPTY_INVENTORY = new Inventory(0);
|
||||||
|
|
||||||
|
private final InternalFluidSlotME slot;
|
||||||
|
|
||||||
public SlotFluidME(InternalFluidSlotME slot) {
|
public SlotFluidME(InternalFluidSlotME slot) {
|
||||||
super(null, 0, slot.getxPosition(), slot.getyPosition());
|
super(EMPTY_INVENTORY, 0, slot.getxPosition(), slot.getyPosition());
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putStack(final ItemStack par1ItemStack) {
|
public void putStack(final ItemStack stack) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +84,7 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,23 +19,27 @@
|
|||||||
package appeng.client.me;
|
package appeng.client.me;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Inventory;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
|
||||||
public class SlotME extends SlotItemHandler {
|
public class SlotME extends Slot {
|
||||||
|
|
||||||
private final InternalSlotME mySlot;
|
private static final IInventory EMPTY_INVENTORY = new Inventory(0);
|
||||||
|
|
||||||
public SlotME(final InternalSlotME me) {
|
private final InternalSlotME slot;
|
||||||
super(null, 0, me.getxPosition(), me.getyPosition());
|
|
||||||
this.mySlot = me;
|
public SlotME(final InternalSlotME slot) {
|
||||||
|
super(EMPTY_INVENTORY, 0, slot.getxPosition(), slot.getyPosition());
|
||||||
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAEItemStack getAEStack() {
|
public IAEItemStack getAEStack() {
|
||||||
if (this.mySlot.hasPower()) {
|
if (this.slot.hasPower()) {
|
||||||
return this.mySlot.getAEStack();
|
return this.slot.getAEStack();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -47,15 +51,15 @@ public class SlotME extends SlotItemHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStack() {
|
public ItemStack getStack() {
|
||||||
if (this.mySlot.hasPower()) {
|
if (this.slot.hasPower()) {
|
||||||
return this.mySlot.getStack();
|
return this.slot.getStack();
|
||||||
}
|
}
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getHasStack() {
|
public boolean getHasStack() {
|
||||||
if (this.mySlot.hasPower()) {
|
if (this.slot.hasPower()) {
|
||||||
return !this.getStack().isEmpty();
|
return !this.getStack().isEmpty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package appeng.client.render;
|
package appeng.client.render;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
@@ -111,6 +113,6 @@ public enum FacingToRotation implements IStringSerializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getString() {
|
public String getString() {
|
||||||
return name().toLowerCase();
|
return name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.Collections;
|
|||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
import net.minecraft.client.renderer.model.BakedQuad;
|
||||||
@@ -100,7 +101,7 @@ class CableBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||||
new ResourceLocation(AppEng.MOD_ID, textureFolder + color.name().toLowerCase()));
|
new ResourceLocation(AppEng.MOD_ID, textureFolder + color.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,7 +342,7 @@ class CableBuilder {
|
|||||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -352,14 +353,14 @@ class CableBuilder {
|
|||||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
// Reset back to normal rendering for the rest
|
// Reset back to normal rendering for the rest
|
||||||
cubeBuilder.setRenderFullBright(false);
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
cubeBuilder.setTexture(texture);
|
cubeBuilder.setTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -368,6 +369,9 @@ class CableBuilder {
|
|||||||
cubeBuilder.setTexture(evenChannel);
|
cubeBuilder.setTexture(evenChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStraightSmartConnection(Direction facing, AEColor cableColor, int channels,
|
public void addStraightSmartConnection(Direction facing, AEColor cableColor, int channels,
|
||||||
@@ -385,7 +389,7 @@ class CableBuilder {
|
|||||||
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -394,6 +398,9 @@ class CableBuilder {
|
|||||||
cubeBuilder.setTexture(evenChannel);
|
cubeBuilder.setTexture(evenChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||||
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConstrainedSmartConnection(Direction facing, AEColor cableColor, int distanceFromEdge, int channels,
|
public void addConstrainedSmartConnection(Direction facing, AEColor cableColor, int distanceFromEdge, int channels,
|
||||||
@@ -416,7 +423,7 @@ class CableBuilder {
|
|||||||
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -425,6 +432,9 @@ class CableBuilder {
|
|||||||
cubeBuilder.setTexture(evenChannel);
|
cubeBuilder.setTexture(evenChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||||
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDenseCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
public void addDenseCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||||
@@ -448,7 +458,7 @@ class CableBuilder {
|
|||||||
addDenseCableSizedCube(facing, cubeBuilder);
|
addDenseCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
// Reset back to normal rendering for the rest
|
// Reset back to normal rendering for the rest
|
||||||
cubeBuilder.setRenderFullBright(false);
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
cubeBuilder.setTexture(texture);
|
cubeBuilder.setTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +494,7 @@ class CableBuilder {
|
|||||||
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -495,7 +505,7 @@ class CableBuilder {
|
|||||||
addDenseCableSizedCube(facing, cubeBuilder);
|
addDenseCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
// Reset back to normal rendering for the rest
|
// Reset back to normal rendering for the rest
|
||||||
cubeBuilder.setRenderFullBright(false);
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
cubeBuilder.setTexture(texture);
|
cubeBuilder.setTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +538,7 @@ class CableBuilder {
|
|||||||
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
TextureAtlasSprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||||
|
|
||||||
// Render the channel indicators brightly lit at night
|
// Render the channel indicators brightly lit at night
|
||||||
cubeBuilder.setRenderFullBright(true);
|
cubeBuilder.setEmissiveMaterial(true);
|
||||||
|
|
||||||
cubeBuilder.setTexture(oddChannel);
|
cubeBuilder.setTexture(oddChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||||
@@ -537,6 +547,9 @@ class CableBuilder {
|
|||||||
cubeBuilder.setTexture(evenChannel);
|
cubeBuilder.setTexture(evenChannel);
|
||||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||||
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
cubeBuilder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
private static void addDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
package appeng.client.render.cablebus;
|
package appeng.client.render.cablebus;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -30,6 +30,11 @@ import java.util.Random;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.cache.Weigher;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
import net.minecraft.client.renderer.model.BakedQuad;
|
||||||
@@ -47,10 +52,22 @@ import net.minecraftforge.client.model.data.IModelData;
|
|||||||
import appeng.api.parts.IPartModel;
|
import appeng.api.parts.IPartModel;
|
||||||
import appeng.api.util.AECableType;
|
import appeng.api.util.AECableType;
|
||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
|
import appeng.metrics.Metrics;
|
||||||
|
|
||||||
public class CableBusBakedModel implements IBakedModel {
|
public class CableBusBakedModel implements IBakedModel {
|
||||||
|
|
||||||
private static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
|
// The number of quads overall that will be cached
|
||||||
|
private static final int CACHE_QUAD_COUNT = 5000;
|
||||||
|
|
||||||
|
// Keep a weak-ref to the last created cache for reporting metrics
|
||||||
|
private static WeakReference<LoadingCache<CableBusRenderState, List<BakedQuad>>> cacheForMetrics = new WeakReference<>(
|
||||||
|
null);
|
||||||
|
|
||||||
|
static {
|
||||||
|
Metrics.cache("cable_bus_model_cache", () -> cacheForMetrics.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final LoadingCache<CableBusRenderState, List<BakedQuad>> cableModelCache;
|
||||||
|
|
||||||
private final CableBuilder cableBuilder;
|
private final CableBuilder cableBuilder;
|
||||||
|
|
||||||
@@ -66,6 +83,19 @@ public class CableBusBakedModel implements IBakedModel {
|
|||||||
this.facadeBuilder = facadeBuilder;
|
this.facadeBuilder = facadeBuilder;
|
||||||
this.partModels = partModels;
|
this.partModels = partModels;
|
||||||
this.particleTexture = particleTexture;
|
this.particleTexture = particleTexture;
|
||||||
|
this.cableModelCache = CacheBuilder.newBuilder()//
|
||||||
|
.recordStats()//
|
||||||
|
.maximumWeight(CACHE_QUAD_COUNT)//
|
||||||
|
.weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (key, value) -> value.size())//
|
||||||
|
.build(new CacheLoader<CableBusRenderState, List<BakedQuad>>() {
|
||||||
|
@Override
|
||||||
|
public List<BakedQuad> load(CableBusRenderState renderState) {
|
||||||
|
final List<BakedQuad> model = new ArrayList<>();
|
||||||
|
addCableQuads(renderState, model);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cacheForMetrics = new WeakReference<>(cableModelCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,11 +122,7 @@ public class CableBusBakedModel implements IBakedModel {
|
|||||||
if (layer == RenderType.getCutout()) {
|
if (layer == RenderType.getCutout()) {
|
||||||
|
|
||||||
// First, handle the cable at the center of the cable bus
|
// First, handle the cable at the center of the cable bus
|
||||||
final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k -> {
|
final List<BakedQuad> cableModel = cableModelCache.getUnchecked(renderState);
|
||||||
final List<BakedQuad> model = new ArrayList<>();
|
|
||||||
this.addCableQuads(renderState, model);
|
|
||||||
return model;
|
|
||||||
});
|
|
||||||
quads.addAll(cableModel);
|
quads.addAll(cableModel);
|
||||||
|
|
||||||
// Then handle attachments
|
// Then handle attachments
|
||||||
@@ -341,8 +367,4 @@ public class CableBusBakedModel implements IBakedModel {
|
|||||||
return ItemOverrideList.EMPTY;
|
return ItemOverrideList.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCache() {
|
|
||||||
CABLE_MODEL_CACHE.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public class CableBusModelLoader implements IModelLoader<CableBusModel> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||||
CableBusBakedModel.clearCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package appeng.client.render.cablebus;
|
package appeng.client.render.cablebus;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -74,7 +75,7 @@ public enum CableCoreType {
|
|||||||
|
|
||||||
public RenderMaterial getTexture(AEColor color) {
|
public RenderMaterial getTexture(AEColor color) {
|
||||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||||
new ResourceLocation(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase()));
|
new ResourceLocation(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class CubeBuilder {
|
|||||||
|
|
||||||
private boolean useStandardUV = false;
|
private boolean useStandardUV = false;
|
||||||
|
|
||||||
private boolean renderFullBright;
|
private boolean emissiveMaterial;
|
||||||
|
|
||||||
public CubeBuilder(List<BakedQuad> output) {
|
public CubeBuilder(List<BakedQuad> output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
@@ -379,7 +379,7 @@ public class CubeBuilder {
|
|||||||
if (e.getIndex() == 0) {
|
if (e.getIndex() == 0) {
|
||||||
builder.put(i, u, v);
|
builder.put(i, u, v);
|
||||||
break;
|
break;
|
||||||
} else if (e.getIndex() == 2 && renderFullBright) {
|
} else if (e.getIndex() == 2 && emissiveMaterial) {
|
||||||
// Force Brightness to 15, this is for full bright mode
|
// Force Brightness to 15, this is for full bright mode
|
||||||
// this vertex element will only be present in that case
|
// this vertex element will only be present in that case
|
||||||
final float lightMapU = (float) (15 * 0x20) / 0xFFFF;
|
final float lightMapU = (float) (15 * 0x20) / 0xFFFF;
|
||||||
@@ -434,8 +434,8 @@ public class CubeBuilder {
|
|||||||
this.setColorRGB((int) (r * 255) << 16 | (int) (g * 255) << 8 | (int) (b * 255));
|
this.setColorRGB((int) (r * 255) << 16 | (int) (g * 255) << 8 | (int) (b * 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderFullBright(boolean renderFullBright) {
|
public void setEmissiveMaterial(boolean renderFullBright) {
|
||||||
this.renderFullBright = renderFullBright;
|
this.emissiveMaterial = renderFullBright;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomUv(Direction facing, float u1, float v1, float u2, float v2) {
|
public void setCustomUv(Direction facing, float u1, float v1, float u2, float v2) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel {
|
|||||||
|
|
||||||
cb.setTexture(this.texture);
|
cb.setTexture(this.texture);
|
||||||
cb.useStandardUV();
|
cb.useStandardUV();
|
||||||
cb.setRenderFullBright(active);
|
cb.setEmissiveMaterial(active);
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
final int[] offs = QUAD_OFFSETS[i];
|
final int[] offs = QUAD_OFFSETS[i];
|
||||||
@@ -70,6 +70,10 @@ public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
cb.setEmissiveMaterial(false);
|
||||||
|
|
||||||
return cb.getOutput();
|
return cb.getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package appeng.client.render.crafting;
|
package appeng.client.render.crafting;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@@ -48,7 +50,7 @@ public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
|
|||||||
if (typeEl != null) {
|
if (typeEl != null) {
|
||||||
String typeName = deserializationContext.deserialize(typeEl, String.class);
|
String typeName = deserializationContext.deserialize(typeEl, String.class);
|
||||||
if (typeName != null) {
|
if (typeName != null) {
|
||||||
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase());
|
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unitType == null) {
|
if (unitType == null) {
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ class LightBakedModel extends CraftingCubeBakedModel {
|
|||||||
builder.addCube(x1, y1, z1, x2, y2, z2);
|
builder.addCube(x1, y1, z1, x2, y2, z2);
|
||||||
|
|
||||||
boolean powered = state.get(AbstractCraftingUnitBlock.POWERED);
|
boolean powered = state.get(AbstractCraftingUnitBlock.POWERED);
|
||||||
builder.setRenderFullBright(powered);
|
builder.setEmissiveMaterial(powered);
|
||||||
builder.setTexture(this.lightTexture);
|
builder.setTexture(this.lightTexture);
|
||||||
builder.addCube(x1, y1, z1, x2, y2, z2);
|
builder.addCube(x1, y1, z1, x2, y2, z2);
|
||||||
|
// Reset back to default
|
||||||
|
builder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class MonitorBakedModel extends CraftingCubeBakedModel {
|
|||||||
AEColor color = getColor(modelData);
|
AEColor color = getColor(modelData);
|
||||||
boolean powered = state.get(CraftingMonitorBlock.POWERED);
|
boolean powered = state.get(CraftingMonitorBlock.POWERED);
|
||||||
|
|
||||||
builder.setRenderFullBright(powered);
|
builder.setEmissiveMaterial(powered);
|
||||||
|
|
||||||
builder.setColorRGB(color.whiteVariant);
|
builder.setColorRGB(color.whiteVariant);
|
||||||
builder.setTexture(this.lightBrightTexture);
|
builder.setTexture(this.lightBrightTexture);
|
||||||
@@ -92,6 +92,8 @@ public class MonitorBakedModel extends CraftingCubeBakedModel {
|
|||||||
builder.setTexture(this.lightDarkTexture);
|
builder.setTexture(this.lightDarkTexture);
|
||||||
builder.addCube(x1, y1, z1, x2, y2, z2);
|
builder.addCube(x1, y1, z1, x2, y2, z2);
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
builder.setEmissiveMaterial(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AEColor getColor(IModelData modelData) {
|
private static AEColor getColor(IModelData modelData) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class EnergyParticleData implements IParticleData {
|
|||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
boolean forItem = reader.readBoolean();
|
boolean forItem = reader.readBoolean();
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase());
|
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase(Locale.ROOT));
|
||||||
return new EnergyParticleData(forItem, direction);
|
return new EnergyParticleData(forItem, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,8 @@ public class EnergyParticleData implements IParticleData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameters() {
|
public String getParameters() {
|
||||||
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false", direction.name().toLowerCase());
|
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false",
|
||||||
|
direction.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
import net.minecraft.client.renderer.model.BakedQuad;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
||||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||||
@@ -193,7 +191,7 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
|||||||
vec.setX(vec.getX() + 0.5f);
|
vec.setX(vec.getX() + 0.5f);
|
||||||
vec.setY(vec.getY() + 0.5f);
|
vec.setY(vec.getY() + 0.5f);
|
||||||
vec.setZ(vec.getZ() + 0.5f);
|
vec.setZ(vec.getZ() + 0.5f);
|
||||||
return new float[] { vec.getX(), vec.getY(), vec.getZ() };
|
return new float[] { snap(vec.getX()), snap(vec.getY()), snap(vec.getZ()) };
|
||||||
case 4:
|
case 4:
|
||||||
Vector4f vecc = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
Vector4f vecc = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
||||||
vecc.setX(vecc.getX() - 0.5f);
|
vecc.setX(vecc.getX() - 0.5f);
|
||||||
@@ -203,13 +201,32 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
|||||||
vecc.setX(vecc.getX() + 0.5f);
|
vecc.setX(vecc.getX() + 0.5f);
|
||||||
vecc.setY(vecc.getY() + 0.5f);
|
vecc.setY(vecc.getY() + 0.5f);
|
||||||
vecc.setZ(vecc.getZ() + 0.5f);
|
vecc.setZ(vecc.getZ() + 0.5f);
|
||||||
return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), vecc.getW() };
|
return new float[] { snap(vecc.getX()), snap(vecc.getY()), snap(vecc.getZ()), snap(vecc.getW()) };
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the same value used by Vanilla's AO lighter.
|
||||||
|
*/
|
||||||
|
private static final float EPS = 0.0001f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tries to snap the coordinate to the edges of the block frame, because
|
||||||
|
* Vanilla uses direct equals comparisons to 0 and 1 for checking if a face
|
||||||
|
* extends fully towards the edge. This is used primarily for AO calculations.
|
||||||
|
*/
|
||||||
|
private static float snap(float x) {
|
||||||
|
if (Math.abs(x) <= EPS) {
|
||||||
|
return 0f;
|
||||||
|
} else if (Math.abs(x - 1) <= EPS) {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
private float[] transformNormal(float[] fs) {
|
private float[] transformNormal(float[] fs) {
|
||||||
if (this.face == null) {
|
if (this.face == null) {
|
||||||
switch (fs.length) {
|
switch (fs.length) {
|
||||||
@@ -220,7 +237,7 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
|||||||
case 4:
|
case 4:
|
||||||
Vector4f vec4 = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
Vector4f vec4 = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
||||||
vec4.transform(this.f2r.getMat());
|
vec4.transform(this.f2r.getMat());
|
||||||
return new float[] { vec4.getX(), vec4.getY(), vec4.getZ(), 0 };
|
return new float[] { snap(vec4.getX()), snap(vec4.getY()), snap(vec4.getZ()), 0 };
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fs;
|
return fs;
|
||||||
|
|||||||
@@ -1,210 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Applied Energistics 2.
|
|
||||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package appeng.client.render.model;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
|
||||||
import net.minecraft.client.renderer.model.BlockFaceUV;
|
|
||||||
import net.minecraft.client.renderer.model.BlockModel;
|
|
||||||
import net.minecraft.client.renderer.model.BlockPart;
|
|
||||||
import net.minecraft.client.renderer.model.BlockPartFace;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.IModelTransform;
|
|
||||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
||||||
import net.minecraft.client.renderer.model.ItemOverride;
|
|
||||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
|
||||||
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
|
||||||
import net.minecraft.client.renderer.model.ModelBakery;
|
|
||||||
import net.minecraft.client.renderer.model.RenderMaterial;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.JSONUtils;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
|
||||||
import net.minecraftforge.client.model.IModelBuilder;
|
|
||||||
import net.minecraftforge.client.model.IModelConfiguration;
|
|
||||||
import net.minecraftforge.client.model.IModelLoader;
|
|
||||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
|
||||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
|
||||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
|
||||||
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
|
|
||||||
import net.minecraftforge.common.model.TransformationHelper;
|
|
||||||
|
|
||||||
public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapper> {
|
|
||||||
|
|
||||||
public static final UVLModelLoader INSTANCE = new UVLModelLoader();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UVLModelWrapper read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
|
||||||
modelContents.remove("loader");
|
|
||||||
BlockModel blockModel = UVLSERIALIZER.fromJson(modelContents, BlockModel.class);
|
|
||||||
return new UVLModelWrapper(blockModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Gson UVLSERIALIZER = (new GsonBuilder())
|
|
||||||
.registerTypeAdapter(BlockModel.class, new ModelLoaderRegistry.ExpandedBlockModelDeserializer())
|
|
||||||
.registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer())
|
|
||||||
.registerTypeAdapter(BlockPartFace.class, new BlockPartFaceOverrideSerializer())
|
|
||||||
.registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer())
|
|
||||||
.registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer())
|
|
||||||
.registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer())
|
|
||||||
.registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer())
|
|
||||||
.registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer()).create();
|
|
||||||
|
|
||||||
private static class BlockPartFaceOverrideSerializer extends BlockPartFace.Deserializer {
|
|
||||||
@Override
|
|
||||||
public BlockPartFace deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_,
|
|
||||||
JsonDeserializationContext p_deserialize_3_) throws JsonParseException {
|
|
||||||
BlockPartFace blockFace = super.deserialize(p_deserialize_1_, p_deserialize_2_, p_deserialize_3_);
|
|
||||||
Pair<Float, Float> uvl = this.parseUVL(p_deserialize_1_.getAsJsonObject());
|
|
||||||
if (uvl != null) {
|
|
||||||
return new BlockPartFaceWithUVL(blockFace.cullFace, blockFace.tintIndex, blockFace.texture,
|
|
||||||
blockFace.blockFaceUV, uvl.getLeft(), uvl.getRight());
|
|
||||||
}
|
|
||||||
return blockFace;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Pair<Float, Float> parseUVL(JsonObject object) {
|
|
||||||
if (!object.has("uvlightmap")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
object = object.get("uvlightmap").getAsJsonObject();
|
|
||||||
return new ImmutablePair<>(JSONUtils.getFloat(object, "sky", 0), JSONUtils.getFloat(object, "block", 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class BlockPartFaceWithUVL extends BlockPartFace {
|
|
||||||
|
|
||||||
private final float sky;
|
|
||||||
private final float block;
|
|
||||||
|
|
||||||
public BlockPartFaceWithUVL(@Nullable Direction cullFaceIn, int tintIndexIn, String textureIn,
|
|
||||||
BlockFaceUV blockFaceUVIn, float sky, float block) {
|
|
||||||
super(cullFaceIn, tintIndexIn, textureIn, blockFaceUVIn);
|
|
||||||
this.sky = sky;
|
|
||||||
this.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSky() {
|
|
||||||
return sky;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBlock() {
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class UVLModelWrapper implements IModelGeometry<UVLModelWrapper> {
|
|
||||||
private final BlockModel parent;
|
|
||||||
|
|
||||||
public UVLModelWrapper(BlockModel parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
|
||||||
Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
|
||||||
ItemOverrideList overrides, ResourceLocation modelLocation) {
|
|
||||||
TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
|
|
||||||
|
|
||||||
IModelBuilder<?> builder = IModelBuilder.of(owner, overrides, particle);
|
|
||||||
for (BlockPart blockpart : parent.getElements()) {
|
|
||||||
for (Direction direction : blockpart.mapFaces.keySet()) {
|
|
||||||
BlockPartFace blockpartface = blockpart.mapFaces.get(direction);
|
|
||||||
TextureAtlasSprite textureatlassprite1 = spriteGetter
|
|
||||||
.apply(owner.resolveTexture(blockpartface.texture));
|
|
||||||
BakedQuad quad = BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction,
|
|
||||||
modelTransform, modelLocation);
|
|
||||||
|
|
||||||
if (blockpartface instanceof BlockPartFaceWithUVL) {
|
|
||||||
BlockPartFaceWithUVL uvlFace = (BlockPartFaceWithUVL) blockpartface;
|
|
||||||
quad = applyPreBakedLighting(quad, textureatlassprite1, uvlFace.sky, uvlFace.block);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockpartface.cullFace == null) {
|
|
||||||
builder.addGeneralQuad(quad);
|
|
||||||
} else {
|
|
||||||
builder.addFaceQuad(modelTransform.getRotation().rotateTransform(blockpartface.cullFace), quad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BakedQuad applyPreBakedLighting(BakedQuad quad, TextureAtlasSprite sprite, float sky, float block) {
|
|
||||||
// FIXME: just piping through the quads and manipulating uv index 2 directly
|
|
||||||
// seems way easier than this
|
|
||||||
BakedQuadBuilder builder = new BakedQuadBuilder(sprite);
|
|
||||||
VertexLighterFlat trans = new VertexLighterFlat(Minecraft.getInstance().getBlockColors()) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z) {
|
|
||||||
lightmap[0] = block;
|
|
||||||
lightmap[1] = sky;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setQuadTint(int tint) {
|
|
||||||
// Tint requires a block state which we don't have at this point
|
|
||||||
}
|
|
||||||
};
|
|
||||||
MatrixStack identity = new MatrixStack();
|
|
||||||
trans.setTransform(identity.getLast());
|
|
||||||
trans.setParent(builder);
|
|
||||||
quad.pipe(trans);
|
|
||||||
builder.setQuadTint(quad.getTintIndex());
|
|
||||||
builder.setQuadOrientation(quad.getFace());
|
|
||||||
builder.setApplyDiffuseLighting(false);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner,
|
|
||||||
Function<ResourceLocation, IUnbakedModel> modelGetter,
|
|
||||||
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
|
|
||||||
return parent.getTextures(modelGetter, missingTextureErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -117,7 +117,7 @@ class SpatialPylonBakedModel implements IDynamicBakedModel {
|
|||||||
|
|
||||||
if ((flags
|
if ((flags
|
||||||
& SpatialPylonTileEntity.DISPLAY_POWERED_ENABLED) == SpatialPylonTileEntity.DISPLAY_POWERED_ENABLED) {
|
& SpatialPylonTileEntity.DISPLAY_POWERED_ENABLED) == SpatialPylonTileEntity.DISPLAY_POWERED_ENABLED) {
|
||||||
builder.setRenderFullBright(true);
|
builder.setEmissiveMaterial(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setTextures(this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.UP)),
|
builder.setTextures(this.textures.get(getTextureTypeFromSideInside(flags, ori, Direction.UP)),
|
||||||
@@ -135,6 +135,9 @@ class SpatialPylonBakedModel implements IDynamicBakedModel {
|
|||||||
builder.addCube(0, 0, 0, 16, 16, 16);
|
builder.addCube(0, 0, 0, 16, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset back to default
|
||||||
|
builder.setEmissiveMaterial(false);
|
||||||
|
|
||||||
return builder.getOutput();
|
return builder.getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package appeng.client.render.spatial;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -59,7 +60,7 @@ public class SpatialPylonModel implements BasicUnbakedModel<SpatialPylonModel> {
|
|||||||
|
|
||||||
private static RenderMaterial getTexturePath(SpatialPylonTextureType type) {
|
private static RenderMaterial getTexturePath(SpatialPylonTextureType type) {
|
||||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||||
new ResourceLocation(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase()));
|
new ResourceLocation(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package appeng.client.render.tesr;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
|
import appeng.client.render.renderable.ItemRenderable;
|
||||||
|
import appeng.tile.misc.ChargerTileEntity;
|
||||||
|
|
||||||
|
public final class ChargerTESR {
|
||||||
|
|
||||||
|
private ChargerTESR() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<ChargerTileEntity>> FACTORY = dispatcher -> new ModularTESR<>(
|
||||||
|
dispatcher, new ItemRenderable<>(ChargerTESR::getRenderedItem));
|
||||||
|
|
||||||
|
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerTileEntity tile) {
|
||||||
|
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
|
||||||
|
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -142,7 +142,7 @@ public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity>
|
|||||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
|
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
|
||||||
@Nonnull IModelData extraData) {
|
@Nonnull IModelData extraData) {
|
||||||
if (side != null) {
|
if (side != null) {
|
||||||
side = r.rotate(side); // This fixes the incorrect lightmap position
|
side = r.resultingRotate(side); // This fixes the incorrect lightmap position
|
||||||
}
|
}
|
||||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ public class SkyChestTESR extends TileEntityRenderer<SkyChestTileEntity> {
|
|||||||
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
|
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
|
||||||
this.singleLid = new ModelRenderer(64, 64, 0, 0);
|
this.singleLid = new ModelRenderer(64, 64, 0, 0);
|
||||||
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
||||||
this.singleLid.rotationPointY = 9.0F;
|
this.singleLid.rotationPointY = 10.0F;
|
||||||
this.singleLid.rotationPointZ = 1.0F;
|
this.singleLid.rotationPointZ = 1.0F;
|
||||||
this.singleLatch = new ModelRenderer(64, 64, 0, 0);
|
this.singleLatch = new ModelRenderer(64, 64, 0, 0);
|
||||||
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
||||||
this.singleLatch.rotationPointY = 8.0F;
|
this.singleLatch.rotationPointY = 9.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ public abstract class AEBaseContainer extends Container {
|
|||||||
private boolean sentCustomName;
|
private boolean sentCustomName;
|
||||||
private int ticksSinceCheck = 900;
|
private int ticksSinceCheck = 900;
|
||||||
private IAEItemStack clientRequestedTargetItem = null;
|
private IAEItemStack clientRequestedTargetItem = null;
|
||||||
// Slots that were created to represent the player inventory
|
|
||||||
private List<Slot> playerInventorySlots = null;
|
|
||||||
|
|
||||||
public AEBaseContainer(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileEntity myTile,
|
public AEBaseContainer(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileEntity myTile,
|
||||||
final IPart myPart) {
|
final IPart myPart) {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public final class ContainerLocator {
|
|||||||
public static ContainerLocator forPart(AEBasePart part) {
|
public static ContainerLocator forPart(AEBasePart part) {
|
||||||
IPartHost host = part.getHost();
|
IPartHost host = part.getHost();
|
||||||
DimensionalCoord pos = host.getLocation();
|
DimensionalCoord pos = host.getLocation();
|
||||||
return new ContainerLocator(Type.PART, -1, pos.getWorld().getWorld(), pos.getBlockPos(), part.getSide());
|
return new ContainerLocator(Type.PART, -1, pos.getWorld(), pos.getBlockPos(), part.getSide());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasItemIndex() {
|
public boolean hasItemIndex() {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class FormationPlaneContainer extends UpgradeableContainer {
|
|||||||
return helper.open(player, locator);
|
return helper.open(player, locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuiSync(6)
|
@GuiSync(7)
|
||||||
public YesNo placeMode;
|
public YesNo placeMode;
|
||||||
|
|
||||||
public FormationPlaneContainer(int id, final PlayerInventory ip, final FormationPlanePart te) {
|
public FormationPlaneContainer(int id, final PlayerInventory ip, final FormationPlanePart te) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import appeng.api.networking.security.IActionHost;
|
|||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
import appeng.container.ContainerLocator;
|
import appeng.container.ContainerLocator;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.CompressedNBTPacket;
|
import appeng.core.sync.packets.MEInterfaceUpdatePacket;
|
||||||
import appeng.helpers.DualityInterface;
|
import appeng.helpers.DualityInterface;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
import appeng.helpers.InventoryAction;
|
import appeng.helpers.InventoryAction;
|
||||||
@@ -177,7 +177,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
|
|||||||
|
|
||||||
if (!this.data.isEmpty()) {
|
if (!this.data.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
NetworkHandler.instance().sendTo(new CompressedNBTPacket(this.data),
|
NetworkHandler.instance().sendTo(new MEInterfaceUpdatePacket(this.data),
|
||||||
(ServerPlayerEntity) this.getPlayerInv().player);
|
(ServerPlayerEntity) this.getPlayerInv().player);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
// :P
|
// :P
|
||||||
|
|||||||
@@ -261,13 +261,19 @@ public class PatternTermContainer extends MEMonitorableContainer
|
|||||||
return new ItemStack[] { out };
|
return new ItemStack[] { out };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
boolean hasValue = false;
|
||||||
final ItemStack[] list = new ItemStack[3];
|
final ItemStack[] list = new ItemStack[3];
|
||||||
|
|
||||||
for (int i = 0; i < this.outputSlots.length; i++) {
|
for (int i = 0; i < this.outputSlots.length; i++) {
|
||||||
final ItemStack out = this.outputSlots[i].getStack();
|
final ItemStack out = this.outputSlots[i].getStack();
|
||||||
list[i] = out;
|
list[i] = out;
|
||||||
|
if (!out.isEmpty()) {
|
||||||
|
hasValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasValue) {
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ public class QuartzKnifeContainer extends AEBaseContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class QuartzKniveSlot extends OutputSlot {
|
private class QuartzKniveSlot extends OutputSlot {
|
||||||
QuartzKniveSlot(IItemHandler a, int b, int c, int d, int i) {
|
QuartzKniveSlot(IItemHandler inv, int invSlot, int x, int y, int iconIdx) {
|
||||||
super(a, b, c, d, i);
|
super(inv, invSlot, x, y, iconIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class AppEngCraftingSlot extends AppEngSlot {
|
|||||||
private int amountCrafted;
|
private int amountCrafted;
|
||||||
|
|
||||||
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory,
|
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory,
|
||||||
final IItemHandler par3IInventory, final int par4, final int par5, final int par6) {
|
final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(par3IInventory, par4, par5, par6);
|
super(inv, invSlot, x, y);
|
||||||
this.thePlayer = par1PlayerEntity;
|
this.thePlayer = par1PlayerEntity;
|
||||||
this.craftMatrix = par2IInventory;
|
this.craftMatrix = par2IInventory;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class AppEngCraftingSlot extends AppEngSlot {
|
|||||||
* armor slots.
|
* armor slots.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ import appeng.container.AEBaseContainer;
|
|||||||
import appeng.util.helpers.ItemHandlerUtil;
|
import appeng.util.helpers.ItemHandlerUtil;
|
||||||
|
|
||||||
public class AppEngSlot extends Slot {
|
public class AppEngSlot extends Slot {
|
||||||
private static IInventory emptyInventory = new Inventory(0);
|
private static final IInventory EMPTY_INVENTORY = new Inventory(0);
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
private final int index;
|
private final int invSlot;
|
||||||
|
|
||||||
private final int defX;
|
private final int defX;
|
||||||
private final int defY;
|
private final int defY;
|
||||||
@@ -46,10 +46,10 @@ public class AppEngSlot extends Slot {
|
|||||||
private CalculatedValidity isValid;
|
private CalculatedValidity isValid;
|
||||||
private boolean isDisplay = false;
|
private boolean isDisplay = false;
|
||||||
|
|
||||||
public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
public AppEngSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(emptyInventory, idx, x, y);
|
super(EMPTY_INVENTORY, invSlot, x, y);
|
||||||
this.itemHandler = inv;
|
this.itemHandler = inv;
|
||||||
this.index = idx;
|
this.invSlot = invSlot;
|
||||||
|
|
||||||
this.defX = x;
|
this.defX = x;
|
||||||
this.defY = y;
|
this.defY = y;
|
||||||
@@ -71,13 +71,13 @@ public class AppEngSlot extends Slot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearStack() {
|
public void clearStack() {
|
||||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, ItemStack.EMPTY);
|
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.invSlot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(@Nonnull final ItemStack par1ItemStack) {
|
public boolean isItemValid(@Nonnull final ItemStack stack) {
|
||||||
if (this.isSlotEnabled()) {
|
if (this.isSlotEnabled()) {
|
||||||
return this.itemHandler.isItemValid(this.index, par1ItemStack);
|
return this.itemHandler.isItemValid(this.invSlot, stack);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -98,13 +98,13 @@ public class AppEngSlot extends Slot {
|
|||||||
return this.getDisplayStack();
|
return this.getDisplayStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.itemHandler.getStackInSlot(this.index);
|
return this.itemHandler.getStackInSlot(this.invSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putStack(final ItemStack stack) {
|
public void putStack(final ItemStack stack) {
|
||||||
if (this.isSlotEnabled()) {
|
if (this.isSlotEnabled()) {
|
||||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, stack);
|
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.invSlot, stack);
|
||||||
this.onSlotChanged();
|
this.onSlotChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public class AppEngSlot extends Slot {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlotStackLimit() {
|
public int getSlotStackLimit() {
|
||||||
return this.itemHandler.getSlotLimit(this.index);
|
return this.itemHandler.getSlotLimit(this.invSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,9 +137,9 @@ public class AppEngSlot extends Slot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
if (this.isSlotEnabled()) {
|
if (this.isSlotEnabled()) {
|
||||||
return !this.itemHandler.extractItem(this.index, 1, true).isEmpty();
|
return !this.itemHandler.extractItem(this.invSlot, 1, true).isEmpty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ public class AppEngSlot extends Slot {
|
|||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack decrStackSize(int amount) {
|
public ItemStack decrStackSize(int amount) {
|
||||||
return this.itemHandler.extractItem(this.index, amount, false);
|
return this.itemHandler.extractItem(this.invSlot, amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,7 +166,7 @@ public class AppEngSlot extends Slot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getDisplayStack() {
|
public ItemStack getDisplayStack() {
|
||||||
return this.itemHandler.getStackInSlot(this.index);
|
return this.itemHandler.getStackInSlot(this.invSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getOpacityOfIcon() {
|
public float getOpacityOfIcon() {
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public class CraftingMatrixSlot extends AppEngSlot {
|
|||||||
private final AEBaseContainer c;
|
private final AEBaseContainer c;
|
||||||
private final IInventory wrappedInventory;
|
private final IInventory wrappedInventory;
|
||||||
|
|
||||||
public CraftingMatrixSlot(final AEBaseContainer c, final IItemHandler par1iInventory, final int par2,
|
public CraftingMatrixSlot(final AEBaseContainer c, final IItemHandler inv, final int invSlot, final int x,
|
||||||
final int par3, final int par4) {
|
final int y) {
|
||||||
super(par1iInventory, par2, par3, par4);
|
super(inv, invSlot, x, y);
|
||||||
this.c = c;
|
this.c = c;
|
||||||
this.wrappedInventory = new WrapperInvItemHandler(par1iInventory);
|
this.wrappedInventory = new WrapperInvItemHandler(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,17 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class DisabledSlot extends AppEngSlot {
|
public class DisabledSlot extends AppEngSlot {
|
||||||
|
|
||||||
public DisabledSlot(final IItemHandler par1iInventory, final int slotIndex, final int x, final int y) {
|
public DisabledSlot(final IItemHandler par1iInventory, final int invSlot, final int x, final int y) {
|
||||||
super(par1iInventory, slotIndex, x, y);
|
super(par1iInventory, invSlot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class FakeBlacklistSlot extends FakeTypeOnlySlot {
|
public class FakeBlacklistSlot extends FakeTypeOnlySlot {
|
||||||
|
|
||||||
public FakeBlacklistSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
public FakeBlacklistSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(inv, idx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class FakeCraftingMatrixSlot extends FakeSlot {
|
public class FakeCraftingMatrixSlot extends FakeSlot {
|
||||||
|
|
||||||
public FakeCraftingMatrixSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
public FakeCraftingMatrixSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(inv, idx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class FakeSlot extends AppEngSlot {
|
public class FakeSlot extends AppEngSlot {
|
||||||
|
|
||||||
public FakeSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
public FakeSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(inv, idx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,7 +39,7 @@ public class FakeSlot extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class FakeSlot extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class FakeTypeOnlySlot extends FakeSlot {
|
public class FakeTypeOnlySlot extends FakeSlot {
|
||||||
|
|
||||||
public FakeTypeOnlySlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
public FakeTypeOnlySlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(inv, idx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ public class InaccessibleSlot extends AppEngSlot {
|
|||||||
|
|
||||||
private ItemStack dspStack = ItemStack.EMPTY;
|
private ItemStack dspStack = ItemStack.EMPTY;
|
||||||
|
|
||||||
public InaccessibleSlot(final IItemHandler i, final int slotIdx, final int x, final int y) {
|
public InaccessibleSlot(final IItemHandler i, final int invSlot, final int x, final int y) {
|
||||||
super(i, slotIdx, x, y);
|
super(i, invSlot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack i) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public class InaccessibleSlot extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ public class MolecularAssemblerPatternSlot extends AppEngSlot {
|
|||||||
|
|
||||||
private final MolecularAssemblerContainer mac;
|
private final MolecularAssemblerContainer mac;
|
||||||
|
|
||||||
public MolecularAssemblerPatternSlot(final MolecularAssemblerContainer mac, final IItemHandler i, final int slotIdx,
|
public MolecularAssemblerPatternSlot(final MolecularAssemblerContainer mac, final IItemHandler inv,
|
||||||
final int x, final int y) {
|
final int invSlot, final int x, final int y) {
|
||||||
super(i, slotIdx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
this.mac = mac;
|
this.mac = mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack i) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return this.mac.isValidItemForSlot(this.getSlotIndex(), i);
|
return this.mac.isValidItemForSlot(this.getSlotIndex(), stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class NormalSlot extends AppEngSlot {
|
public class NormalSlot extends AppEngSlot {
|
||||||
|
|
||||||
public NormalSlot(final IItemHandler inv, final int slot, final int xPos, final int yPos) {
|
public NormalSlot(final IItemHandler inv, final int invSlot, final int xPos, final int yPos) {
|
||||||
super(inv, slot, xPos, yPos);
|
super(inv, invSlot, xPos, yPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ public class OptionalFakeSlot extends FakeSlot implements IOptionalSlot {
|
|||||||
private final IOptionalSlotHost host;
|
private final IOptionalSlotHost host;
|
||||||
private boolean renderDisabled = true;
|
private boolean renderDisabled = true;
|
||||||
|
|
||||||
public OptionalFakeSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
public OptionalFakeSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int invSlot,
|
||||||
final int y, final int offX, final int offY, final int groupNum) {
|
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||||
super(inv, idx, x + offX * 18, y + offY * 18);
|
super(inv, invSlot, x + offX * 18, y + offY * 18);
|
||||||
this.srcX = x;
|
this.srcX = x;
|
||||||
this.srcY = y;
|
this.srcY = y;
|
||||||
this.groupNum = groupNum;
|
this.groupNum = groupNum;
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ public class OptionalNormalSlot extends AppEngSlot implements IOptionalSlot {
|
|||||||
private final int groupNum;
|
private final int groupNum;
|
||||||
private final IOptionalSlotHost host;
|
private final IOptionalSlotHost host;
|
||||||
|
|
||||||
public OptionalNormalSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot,
|
public OptionalNormalSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int invSlot,
|
||||||
final int xPos, final int yPos, final int groupNum) {
|
final int xPos, final int yPos, final int groupNum) {
|
||||||
super(inv, slot, xPos, yPos);
|
super(inv, invSlot, xPos, yPos);
|
||||||
this.groupNum = groupNum;
|
this.groupNum = groupNum;
|
||||||
this.host = containerBus;
|
this.host = containerBus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ public class OptionalRestrictedInputSlot extends RestrictedInputSlot {
|
|||||||
private final int groupNum;
|
private final int groupNum;
|
||||||
private final IOptionalSlotHost host;
|
private final IOptionalSlotHost host;
|
||||||
|
|
||||||
public OptionalRestrictedInputSlot(final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host,
|
public OptionalRestrictedInputSlot(final PlacableItemType valid, final IItemHandler inv,
|
||||||
final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) {
|
final IOptionalSlotHost host, final int invSlot, final int x, final int y, final int grpNum,
|
||||||
super(valid, i, slotIndex, x, y, invPlayer);
|
final PlayerInventory invPlayer) {
|
||||||
|
super(valid, inv, invSlot, x, y, invPlayer);
|
||||||
this.groupNum = grpNum;
|
this.groupNum = grpNum;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class OptionalTypeOnlyFakeSlot extends OptionalFakeSlot {
|
public class OptionalTypeOnlyFakeSlot extends OptionalFakeSlot {
|
||||||
|
|
||||||
public OptionalTypeOnlyFakeSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx,
|
public OptionalTypeOnlyFakeSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int invSlot,
|
||||||
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
super(inv, containerBus, invSlot, x, y, offX, offY, groupNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class OutputSlot extends AppEngSlot {
|
public class OutputSlot extends AppEngSlot {
|
||||||
|
|
||||||
public OutputSlot(final IItemHandler a, final int b, final int c, final int d, final int i) {
|
public OutputSlot(final IItemHandler inv, final int invSlot, final int x, final int y, final int iconIndex) {
|
||||||
super(a, b, c, d);
|
super(inv, invSlot, x, y);
|
||||||
this.setIIcon(i);
|
this.setIIcon(iconIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack i) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class PatternOutputsSlot extends OptionalFakeSlot {
|
public class PatternOutputsSlot extends OptionalFakeSlot {
|
||||||
|
|
||||||
public PatternOutputsSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
public PatternOutputsSlot(final IItemHandler inv, final IOptionalSlotHost containerBus, final int invSlot,
|
||||||
final int y, final int offX, final int offY, final int groupNum) {
|
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
super(inv, containerBus, invSlot, x, y, offX, offY, groupNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class PlayerHotBarSlot extends AppEngSlot {
|
public class PlayerHotBarSlot extends AppEngSlot {
|
||||||
|
|
||||||
public PlayerHotBarSlot(final IItemHandler par1iInventory, final int par2, final int par3, final int par4) {
|
public PlayerHotBarSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(par1iInventory, par2, par3, par4);
|
super(inv, invSlot, x, y);
|
||||||
this.setPlayerSide(true);
|
this.setPlayerSide(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
|
|
||||||
public class PlayerInvSlot extends AppEngSlot {
|
public class PlayerInvSlot extends AppEngSlot {
|
||||||
|
|
||||||
public PlayerInvSlot(final IItemHandler par1iInventory, final int idx, final int x, final int y) {
|
public PlayerInvSlot(final IItemHandler inv, final int invSlot, final int x, final int y) {
|
||||||
super(par1iInventory, idx, x, y);
|
super(inv, invSlot, x, y);
|
||||||
|
|
||||||
this.setPlayerSide(true);
|
this.setPlayerSide(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
private boolean allowEdit = true;
|
private boolean allowEdit = true;
|
||||||
private int stackLimit = -1;
|
private int stackLimit = -1;
|
||||||
|
|
||||||
public RestrictedInputSlot(final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x,
|
public RestrictedInputSlot(final PlacableItemType valid, final IItemHandler inv, final int invSlot, final int x,
|
||||||
final int y, final PlayerInventory p) {
|
final int y, final PlayerInventory p) {
|
||||||
super(i, slotIndex, x, y);
|
super(inv, invSlot, x, y);
|
||||||
this.which = valid;
|
this.which = valid;
|
||||||
this.setIIcon(valid.IIcon);
|
this.setIIcon(valid.IIcon);
|
||||||
this.p = p;
|
this.p = p;
|
||||||
@@ -99,20 +99,20 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(final ItemStack i) {
|
public boolean isItemValid(final ItemStack stack) {
|
||||||
if (!this.getContainer().isValidForSlot(this, i)) {
|
if (!this.getContainer().isValidForSlot(this, stack)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.getItem() == Items.AIR) {
|
if (stack.getItem() == Items.AIR) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!super.isItemValid(i)) {
|
if (!super.isItemValid(stack)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
|
|
||||||
switch (this.which) {
|
switch (this.which) {
|
||||||
case ENCODED_CRAFTING_PATTERN:
|
case ENCODED_CRAFTING_PATTERN:
|
||||||
final ICraftingPatternDetails de = crafting.decodePattern(i, this.p.player.world);
|
final ICraftingPatternDetails de = crafting.decodePattern(stack, this.p.player.world);
|
||||||
if (de != null) {
|
if (de != null) {
|
||||||
return de.isCraftable();
|
return de.isCraftable();
|
||||||
}
|
}
|
||||||
@@ -135,19 +135,19 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||||
case ENCODED_PATTERN_W_OUTPUT:
|
case ENCODED_PATTERN_W_OUTPUT:
|
||||||
case ENCODED_PATTERN:
|
case ENCODED_PATTERN:
|
||||||
return crafting.isEncodedPattern(i);
|
return crafting.isEncodedPattern(stack);
|
||||||
case BLANK_PATTERN:
|
case BLANK_PATTERN:
|
||||||
return materials.blankPattern().isSameAs(i);
|
return materials.blankPattern().isSameAs(stack);
|
||||||
|
|
||||||
case PATTERN:
|
case PATTERN:
|
||||||
return materials.blankPattern().isSameAs(i) || crafting.isEncodedPattern(i);
|
return materials.blankPattern().isSameAs(stack) || crafting.isEncodedPattern(stack);
|
||||||
|
|
||||||
case INSCRIBER_PLATE:
|
case INSCRIBER_PLATE:
|
||||||
if (materials.namePress().isSameAs(i)) {
|
if (materials.namePress().isSameAs(stack)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
return InscriberRecipes.isValidOptionalIngredient(p.player.world, stack);
|
||||||
|
|
||||||
case INSCRIBER_INPUT:
|
case INSCRIBER_INPUT:
|
||||||
return true;/*
|
return true;/*
|
||||||
@@ -157,46 +157,48 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
|
|
||||||
case METAL_INGOTS:
|
case METAL_INGOTS:
|
||||||
|
|
||||||
return isMetalIngot(i);
|
return isMetalIngot(stack);
|
||||||
|
|
||||||
case VIEW_CELL:
|
case VIEW_CELL:
|
||||||
return items.viewCell().isSameAs(i);
|
return items.viewCell().isSameAs(stack);
|
||||||
case ORE:
|
case ORE:
|
||||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
return GrinderRecipes.isValidIngredient(p.player.world, stack);
|
||||||
case FUEL:
|
case FUEL:
|
||||||
return ForgeHooks.getBurnTime(i) > 0;
|
return ForgeHooks.getBurnTime(stack) > 0;
|
||||||
case POWERED_TOOL:
|
case POWERED_TOOL:
|
||||||
return Platform.isChargeable(i);
|
return Platform.isChargeable(stack);
|
||||||
case QE_SINGULARITY:
|
case QE_SINGULARITY:
|
||||||
return materials.qESingularity().isSameAs(i);
|
return materials.qESingularity().isSameAs(stack);
|
||||||
|
|
||||||
case RANGE_BOOSTER:
|
case RANGE_BOOSTER:
|
||||||
return materials.wirelessBooster().isSameAs(i);
|
return materials.wirelessBooster().isSameAs(stack);
|
||||||
|
|
||||||
case SPATIAL_STORAGE_CELLS:
|
case SPATIAL_STORAGE_CELLS:
|
||||||
return i.getItem() instanceof ISpatialStorageCell
|
return stack.getItem() instanceof ISpatialStorageCell
|
||||||
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
|
&& ((ISpatialStorageCell) stack.getItem()).isSpatialStorage(stack);
|
||||||
case STORAGE_CELLS:
|
case STORAGE_CELLS:
|
||||||
return Api.instance().registries().cell().isCellHandled(i);
|
return Api.instance().registries().cell().isCellHandled(stack);
|
||||||
case WORKBENCH_CELL:
|
case WORKBENCH_CELL:
|
||||||
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
|
return stack.getItem() instanceof ICellWorkbenchItem
|
||||||
|
&& ((ICellWorkbenchItem) stack.getItem()).isEditable(stack);
|
||||||
case STORAGE_COMPONENT:
|
case STORAGE_COMPONENT:
|
||||||
return i.getItem() instanceof IStorageComponent
|
return stack.getItem() instanceof IStorageComponent
|
||||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i);
|
&& ((IStorageComponent) stack.getItem()).isStorageComponent(stack);
|
||||||
case TRASH:
|
case TRASH:
|
||||||
if (Api.instance().registries().cell().isCellHandled(i)) {
|
if (Api.instance().registries().cell().isCellHandled(stack)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !(i.getItem() instanceof IStorageComponent
|
return !(stack.getItem() instanceof IStorageComponent
|
||||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i));
|
&& ((IStorageComponent) stack.getItem()).isStorageComponent(stack));
|
||||||
case ENCODABLE_ITEM:
|
case ENCODABLE_ITEM:
|
||||||
return i.getItem() instanceof INetworkEncodable
|
return stack.getItem() instanceof INetworkEncodable
|
||||||
|| Api.instance().registries().wireless().isWirelessTerminal(i);
|
|| Api.instance().registries().wireless().isWirelessTerminal(stack);
|
||||||
case BIOMETRIC_CARD:
|
case BIOMETRIC_CARD:
|
||||||
return i.getItem() instanceof IBiometricCard;
|
return stack.getItem() instanceof IBiometricCard;
|
||||||
case UPGRADES:
|
case UPGRADES:
|
||||||
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null;
|
return stack.getItem() instanceof IUpgradeModule
|
||||||
|
&& ((IUpgradeModule) stack.getItem()).getType(stack) != null;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -205,7 +207,7 @@ public class RestrictedInputSlot extends AppEngSlot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
public boolean canTakeStack(final PlayerEntity player) {
|
||||||
return this.isAllowEdit();
|
return this.isAllowEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import java.util.Set;
|
|||||||
import java.util.function.DoubleSupplier;
|
import java.util.function.DoubleSupplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -393,6 +395,19 @@ public final class AEConfig {
|
|||||||
return this.meteoriteDimensionWhitelist;
|
return this.meteoriteDimensionWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getImprovedFluidTag() {
|
||||||
|
return Strings.emptyToNull(COMMON.improvedFluidTag.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getImprovedFluidMultiplier() {
|
||||||
|
return COMMON.improvedFluidMultiplier.get().floatValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPrometheusMetricsServerPort() {
|
||||||
|
return COMMON.prometheusMetricsServer.get();
|
||||||
|
}
|
||||||
|
|
||||||
// Setters keep visibility as low as possible.
|
// Setters keep visibility as low as possible.
|
||||||
|
|
||||||
private static class ClientConfig {
|
private static class ClientConfig {
|
||||||
@@ -463,6 +478,7 @@ public final class AEConfig {
|
|||||||
public final BooleanValue removeCrashingItemsOnLoad;
|
public final BooleanValue removeCrashingItemsOnLoad;
|
||||||
public final ConfigValue<Integer> formationPlaneEntityLimit;
|
public final ConfigValue<Integer> formationPlaneEntityLimit;
|
||||||
public final ConfigValue<Integer> craftingCalculationTimePerTick;
|
public final ConfigValue<Integer> craftingCalculationTimePerTick;
|
||||||
|
public final ConfigValue<Integer> prometheusMetricsServer;
|
||||||
|
|
||||||
// Spatial IO/Dimension
|
// Spatial IO/Dimension
|
||||||
public final ConfigValue<Double> spatialPowerExponent;
|
public final ConfigValue<Double> spatialPowerExponent;
|
||||||
@@ -507,6 +523,11 @@ public final class AEConfig {
|
|||||||
public final ConfigValue<Integer> condenserMatterBallsPower;
|
public final ConfigValue<Integer> condenserMatterBallsPower;
|
||||||
public final ConfigValue<Integer> condenserSingularityPower;
|
public final ConfigValue<Integer> condenserSingularityPower;
|
||||||
|
|
||||||
|
// In-World Purification
|
||||||
|
// Settings for improved speed depending on fluid the crystal is in
|
||||||
|
public final ConfigValue<String> improvedFluidTag;
|
||||||
|
public final ConfigValue<Double> improvedFluidMultiplier;
|
||||||
|
|
||||||
public final Map<TickRates, ConfigValue<Integer>> tickRateMin = new HashMap<>();
|
public final Map<TickRates, ConfigValue<Integer>> tickRateMin = new HashMap<>();
|
||||||
public final Map<TickRates, ConfigValue<Integer>> tickRateMax = new HashMap<>();
|
public final Map<TickRates, ConfigValue<Integer>> tickRateMax = new HashMap<>();
|
||||||
|
|
||||||
@@ -542,6 +563,12 @@ public final class AEConfig {
|
|||||||
.define("removeCrashingItemsOnLoad", false);
|
.define("removeCrashingItemsOnLoad", false);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
builder.push("metrics");
|
||||||
|
prometheusMetricsServer = builder.comment(
|
||||||
|
"Enables the Prometheus Metrics exporting endpoint on 127.0.0.1 on this port number. 0 to disable.")
|
||||||
|
.define("prometheusMetricsServer", 0);
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
builder.push("automation");
|
builder.push("automation");
|
||||||
formationPlaneEntityLimit = builder.comment("TODO").define("formationPlaneEntityLimit", 128);
|
formationPlaneEntityLimit = builder.comment("TODO").define("formationPlaneEntityLimit", 128);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
@@ -617,6 +644,17 @@ public final class AEConfig {
|
|||||||
tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax()));
|
tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax()));
|
||||||
}
|
}
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
builder.comment("Settings for in-world purification of crystals.").push("inWorldPurification");
|
||||||
|
|
||||||
|
improvedFluidTag = builder.comment(
|
||||||
|
"A fluid tag that identifies fluids that improve crystal purification speed. Does not affect purification with water/lava.")
|
||||||
|
.define("improvedFluidTag", "");
|
||||||
|
improvedFluidMultiplier = builder
|
||||||
|
.comment("The speed multiplier to use when the crystals are submerged in the improved fluid.")
|
||||||
|
.defineInRange("improvedFluidMultiplier", 2.0, 1.0, 10.0);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package appeng.core;
|
package appeng.core;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@@ -35,15 +34,12 @@ import net.minecraft.item.crafting.IRecipeSerializer;
|
|||||||
import net.minecraft.particles.ParticleType;
|
import net.minecraft.particles.ParticleType;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
|
||||||
import net.minecraft.world.gen.feature.structure.Structure;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
|
||||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||||
@@ -56,29 +52,10 @@ import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
|||||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
import appeng.block.paint.PaintSplotchesModel;
|
|
||||||
import appeng.block.qnb.QnbFormedModel;
|
|
||||||
import appeng.bootstrap.components.IClientSetupComponent;
|
|
||||||
import appeng.bootstrap.components.IInitComponent;
|
import appeng.bootstrap.components.IInitComponent;
|
||||||
import appeng.bootstrap.components.IPostInitComponent;
|
import appeng.bootstrap.components.IPostInitComponent;
|
||||||
import appeng.capabilities.Capabilities;
|
import appeng.capabilities.Capabilities;
|
||||||
import appeng.client.ClientHelper;
|
import appeng.client.ClientHelper;
|
||||||
import appeng.client.render.DummyFluidItemModel;
|
|
||||||
import appeng.client.render.FacadeItemModel;
|
|
||||||
import appeng.client.render.SimpleModelLoader;
|
|
||||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
|
||||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
|
||||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
|
||||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
|
||||||
import appeng.client.render.model.BiometricCardModel;
|
|
||||||
import appeng.client.render.model.ColorApplicatorModel;
|
|
||||||
import appeng.client.render.model.DriveModel;
|
|
||||||
import appeng.client.render.model.GlassModel;
|
|
||||||
import appeng.client.render.model.MemoryCardModel;
|
|
||||||
import appeng.client.render.model.SkyCompassModel;
|
|
||||||
import appeng.client.render.model.UVLModelLoader;
|
|
||||||
import appeng.client.render.spatial.SpatialPylonModel;
|
|
||||||
import appeng.core.features.registries.PartModels;
|
|
||||||
import appeng.core.stats.AdvancementTriggers;
|
import appeng.core.stats.AdvancementTriggers;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.worlddata.WorldData;
|
import appeng.core.worlddata.WorldData;
|
||||||
@@ -89,8 +66,8 @@ import appeng.entity.TinyTNTPrimedEntity;
|
|||||||
import appeng.entity.TinyTNTPrimedRenderer;
|
import appeng.entity.TinyTNTPrimedRenderer;
|
||||||
import appeng.hooks.TickHandler;
|
import appeng.hooks.TickHandler;
|
||||||
import appeng.integration.Integrations;
|
import appeng.integration.Integrations;
|
||||||
|
import appeng.metrics.endpoint.PrometheusEndpoint;
|
||||||
import appeng.parts.PartPlacement;
|
import appeng.parts.PartPlacement;
|
||||||
import appeng.parts.automation.PlaneModelLoader;
|
|
||||||
import appeng.server.ServerHelper;
|
import appeng.server.ServerHelper;
|
||||||
|
|
||||||
@Mod(AppEng.MOD_ID)
|
@Mod(AppEng.MOD_ID)
|
||||||
@@ -114,16 +91,19 @@ public final class AppEng {
|
|||||||
}
|
}
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
|
||||||
|
startMetricsServer();
|
||||||
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AEConfig.COMMON_SPEC);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AEConfig.COMMON_SPEC);
|
||||||
|
|
||||||
proxy = DistExecutor.safeRunForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
proxy = DistExecutor.unsafeRunForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||||
|
|
||||||
CreativeTab.init();
|
CreativeTab.init();
|
||||||
new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
|
new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
|
||||||
|
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
registration = new Registration();
|
registration = new Registration();
|
||||||
|
modEventBus.addListener(this::bootstrap);
|
||||||
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
||||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||||
@@ -131,9 +111,6 @@ public final class AppEng {
|
|||||||
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
|
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
|
||||||
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
|
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
|
||||||
modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers);
|
modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers);
|
||||||
modEventBus.addGenericListener(Feature.class, registration::registerFeatures);
|
|
||||||
modEventBus.addGenericListener(Structure.class, registration::registerStructures);
|
|
||||||
modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
|
|
||||||
|
|
||||||
modEventBus.addListener(Integrations::enqueueIMC);
|
modEventBus.addListener(Integrations::enqueueIMC);
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
@@ -152,7 +129,15 @@ public final class AppEng {
|
|||||||
MinecraftForge.EVENT_BUS.register(new PartPlacement());
|
MinecraftForge.EVENT_BUS.register(new PartPlacement());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bootstrap(RegistryEvent.NewRegistry e) {
|
||||||
|
// This has to be here so it's not run in parallel with other registrations
|
||||||
|
AppEngBootstrap.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
private void commonSetup(FMLCommonSetupEvent event) {
|
private void commonSetup(FMLCommonSetupEvent event) {
|
||||||
|
// This must run here because the config is not available earlier
|
||||||
|
DeferredWorkQueue.runLater(AppEngBootstrap::enhanceBiomes);
|
||||||
|
|
||||||
ApiDefinitions definitions = Api.INSTANCE.definitions();
|
ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||||
definitions.getRegistry().getBootstrapComponents(IInitComponent.class)
|
definitions.getRegistry().getBootstrapComponents(IInitComponent.class)
|
||||||
.forEachRemaining(IInitComponent::initialize);
|
.forEachRemaining(IInitComponent::initialize);
|
||||||
@@ -166,6 +151,20 @@ public final class AppEng {
|
|||||||
registerNetworkHandler();
|
registerNetworkHandler();
|
||||||
|
|
||||||
AddonLoader.loadAddons(Api.INSTANCE);
|
AddonLoader.loadAddons(Api.INSTANCE);
|
||||||
|
|
||||||
|
startMetricsServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startMetricsServer() {
|
||||||
|
int prometheusPort = AEConfig.instance().getPrometheusMetricsServerPort();
|
||||||
|
if (prometheusPort != 0) {
|
||||||
|
try {
|
||||||
|
AELog.info("Starting Prometheus Metrics Server on Port %s", prometheusPort);
|
||||||
|
new PrometheusEndpoint("localhost", prometheusPort);
|
||||||
|
} catch (Exception e) {
|
||||||
|
AELog.warn("Failed to start Prometheus Metrics-Server: %s", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@@ -181,39 +180,6 @@ public final class AppEng {
|
|||||||
RenderingRegistry.registerEntityRenderingHandler(ChargedQuartzEntity.TYPE,
|
RenderingRegistry.registerEntityRenderingHandler(ChargedQuartzEntity.TYPE,
|
||||||
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||||
|
|
||||||
// TODO: Do not use the internal API
|
|
||||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
|
||||||
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
|
||||||
.forEachRemaining(IClientSetupComponent::setup);
|
|
||||||
|
|
||||||
addBuiltInModel("glass", GlassModel::new);
|
|
||||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
|
||||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
|
||||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
|
||||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
|
||||||
addBuiltInModel("drive", DriveModel::new);
|
|
||||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
|
||||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
|
||||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
|
||||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
|
||||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
|
||||||
addBuiltInModel("facade", FacadeItemModel::new);
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
|
||||||
EncodedPatternModelLoader.INSTANCE);
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
|
||||||
PlaneModelLoader.INSTANCE);
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"),
|
|
||||||
CraftingCubeModelLoader.INSTANCE);
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"),
|
|
||||||
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
|
||||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id),
|
|
||||||
new SimpleModelLoader<>(modelFactory));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package appeng.core;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.util.registry.WorldGenRegistries;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.gen.GenerationStage;
|
||||||
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.placement.NoPlacementConfig;
|
||||||
|
import net.minecraft.world.gen.placement.Placement;
|
||||||
|
import net.minecraft.world.gen.placement.TopSolidRangeConfig;
|
||||||
|
|
||||||
|
import appeng.api.features.AEFeature;
|
||||||
|
import appeng.mixins.feature.ConfiguredFeaturesAccessor;
|
||||||
|
import appeng.mixins.structure.ConfiguredStructureFeaturesAccessor;
|
||||||
|
import appeng.mixins.structure.StructureFeatureAccessor;
|
||||||
|
import appeng.spatial.SpatialStorageChunkGenerator;
|
||||||
|
import appeng.spatial.SpatialStorageDimensionIds;
|
||||||
|
import appeng.worldgen.BiomeModifier;
|
||||||
|
import appeng.worldgen.ChargedQuartzOreConfig;
|
||||||
|
import appeng.worldgen.ChargedQuartzOreFeature;
|
||||||
|
import appeng.worldgen.meteorite.MeteoriteStructure;
|
||||||
|
import appeng.worldgen.meteorite.MeteoriteStructurePiece;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks into the very early bootstrapping phase to register things before the
|
||||||
|
* first dynamic registry manager is created.
|
||||||
|
*/
|
||||||
|
public final class AppEngBootstrap {
|
||||||
|
|
||||||
|
private static boolean initialized;
|
||||||
|
private static ConfiguredFeature<?, ?> quartzOreFeature;
|
||||||
|
private static ConfiguredFeature<?, ?> chargedQuartzOreFeature;
|
||||||
|
|
||||||
|
private AppEngBootstrap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static void initialize() {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
registerStructures();
|
||||||
|
|
||||||
|
quartzOreFeature = registerQuartzOreFeature();
|
||||||
|
chargedQuartzOreFeature = registerChargedQuartzOreFeature();
|
||||||
|
|
||||||
|
registerDimension();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static void enhanceBiomes() {
|
||||||
|
// add to all standard biomes
|
||||||
|
// TODO: This means we'll not add these things to newly created biomes
|
||||||
|
WorldGenRegistries.field_243657_i.forEach(b -> {
|
||||||
|
addMeteoriteWorldGen(b);
|
||||||
|
addQuartzWorldGen(b, quartzOreFeature, chargedQuartzOreFeature);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerStructures() {
|
||||||
|
|
||||||
|
MeteoriteStructurePiece.register();
|
||||||
|
|
||||||
|
// Registering into the registry alone is INSUFFICIENT!
|
||||||
|
// There's a bidirectional map in the Structure class itself primarily for the
|
||||||
|
// purposes of NBT serialization
|
||||||
|
StructureFeatureAccessor.register(MeteoriteStructure.ID.toString(), MeteoriteStructure.INSTANCE,
|
||||||
|
GenerationStage.Decoration.TOP_LAYER_MODIFICATION);
|
||||||
|
|
||||||
|
ConfiguredStructureFeaturesAccessor.register(MeteoriteStructure.ID.toString(),
|
||||||
|
MeteoriteStructure.CONFIGURED_INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addMeteoriteWorldGen(Biome b) {
|
||||||
|
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BiomeModifier modifier = new BiomeModifier(b);
|
||||||
|
modifier.addStructureFeature(MeteoriteStructure.CONFIGURED_INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addQuartzWorldGen(Biome b, ConfiguredFeature<?, ?> quartzOre,
|
||||||
|
ConfiguredFeature<?, ?> chargedQuartz) {
|
||||||
|
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BiomeModifier modifier = new BiomeModifier(b);
|
||||||
|
|
||||||
|
modifier.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, quartzOre);
|
||||||
|
|
||||||
|
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||||
|
modifier.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, chargedQuartz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ConfiguredFeature<?, ?> registerQuartzOreFeature() {
|
||||||
|
// Tell Minecraft about our configured quartz ore feature
|
||||||
|
BlockState quartzOreState = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||||
|
return ConfiguredFeaturesAccessor.register(AppEng.makeId("quartz_ore").toString(), Feature.ORE
|
||||||
|
.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.field_241882_a, quartzOreState,
|
||||||
|
AEConfig.instance().getQuartzOresPerCluster()))
|
||||||
|
.withPlacement(Placement.field_242907_l/* RANGE */.configure(new TopSolidRangeConfig(12, 12, 72)))
|
||||||
|
.func_242728_a/* spreadHorizontally */()
|
||||||
|
.func_242731_b/* repeat */(AEConfig.instance().getQuartzOresClusterAmount()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ConfiguredFeature<?, ?> registerChargedQuartzOreFeature() {
|
||||||
|
// Tell Minecraft about our configured charged quartz ore feature
|
||||||
|
Registry.register(Registry.FEATURE, AppEng.makeId("charged_quartz_ore"), ChargedQuartzOreFeature.INSTANCE);
|
||||||
|
|
||||||
|
BlockState quartzOreState = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||||
|
BlockState chargedQuartzOreState = Api.instance().definitions().blocks().quartzOreCharged().block()
|
||||||
|
.getDefaultState();
|
||||||
|
return ConfiguredFeaturesAccessor.register(AppEng.makeId("charged_quartz_ore").toString(),
|
||||||
|
ChargedQuartzOreFeature.INSTANCE
|
||||||
|
.withConfiguration(new ChargedQuartzOreConfig(quartzOreState, chargedQuartzOreState,
|
||||||
|
AEConfig.instance().getSpawnChargedChance()))
|
||||||
|
.withPlacement(Placement.NOPE.configure(NoPlacementConfig.field_236556_b_)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerDimension() {
|
||||||
|
Registry.register(Registry.CHUNK_GENERATOR_CODEC, SpatialStorageDimensionIds.CHUNK_GENERATOR_ID,
|
||||||
|
SpatialStorageChunkGenerator.CODEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
@@ -55,11 +56,18 @@ public abstract class CommonHelper {
|
|||||||
|
|
||||||
public abstract void postInit();
|
public abstract void postInit();
|
||||||
|
|
||||||
public abstract CableRenderMode getRenderMode();
|
public abstract CableRenderMode getCableRenderMode();
|
||||||
|
|
||||||
public abstract void triggerUpdates();
|
public abstract void triggerUpdates();
|
||||||
|
|
||||||
public abstract void updateRenderMode(PlayerEntity player);
|
/**
|
||||||
|
* Sets the player that is currently interacting with a cable or part attached
|
||||||
|
* to a cable. This will return that player's cable render mode from calls to
|
||||||
|
* {@link #getCableRenderMode()}, until another player or null is set.
|
||||||
|
*
|
||||||
|
* @param player Null to revert to the default cable render mode.
|
||||||
|
*/
|
||||||
|
public abstract void setPartInteractionPlayer(@Nullable PlayerEntity player);
|
||||||
|
|
||||||
public abstract boolean isActionKey(@Nonnull final ActionKey key, InputMappings.Input input);
|
public abstract boolean isActionKey(@Nonnull final ActionKey key, InputMappings.Input input);
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@
|
|||||||
|
|
||||||
package appeng.core;
|
package appeng.core;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.ScreenManager;
|
import net.minecraft.client.gui.ScreenManager;
|
||||||
import net.minecraft.client.particle.ParticleManager;
|
import net.minecraft.client.particle.ParticleManager;
|
||||||
@@ -31,17 +32,7 @@ import net.minecraft.item.crafting.IRecipeSerializer;
|
|||||||
import net.minecraft.particles.ParticleType;
|
import net.minecraft.particles.ParticleType;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraft.world.gen.GenerationStage;
|
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
|
||||||
import net.minecraft.world.gen.feature.IFeatureConfig;
|
|
||||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
|
||||||
import net.minecraft.world.gen.feature.structure.Structure;
|
|
||||||
import net.minecraft.world.gen.placement.CountRangeConfig;
|
|
||||||
import net.minecraft.world.gen.placement.IPlacementConfig;
|
|
||||||
import net.minecraft.world.gen.placement.Placement;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||||
@@ -50,7 +41,8 @@ import net.minecraftforge.client.event.ModelRegistryEvent;
|
|||||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||||
|
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
@@ -59,14 +51,12 @@ import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
|||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.fml.network.IContainerFactory;
|
import net.minecraftforge.fml.network.IContainerFactory;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
|
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.definitions.IBlocks;
|
import appeng.api.definitions.IBlocks;
|
||||||
import appeng.api.definitions.IItems;
|
import appeng.api.definitions.IItems;
|
||||||
import appeng.api.definitions.IParts;
|
import appeng.api.definitions.IParts;
|
||||||
import appeng.api.features.AEFeature;
|
|
||||||
import appeng.api.features.IRegistryContainer;
|
import appeng.api.features.IRegistryContainer;
|
||||||
import appeng.api.features.IWirelessTermHandler;
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
import appeng.api.features.IWorldGen;
|
import appeng.api.features.IWorldGen;
|
||||||
@@ -79,7 +69,10 @@ import appeng.api.networking.security.ISecurityGrid;
|
|||||||
import appeng.api.networking.spatial.ISpatialCache;
|
import appeng.api.networking.spatial.ISpatialCache;
|
||||||
import appeng.api.networking.storage.IStorageGrid;
|
import appeng.api.networking.storage.IStorageGrid;
|
||||||
import appeng.api.networking.ticking.ITickManager;
|
import appeng.api.networking.ticking.ITickManager;
|
||||||
|
import appeng.block.paint.PaintSplotchesModel;
|
||||||
|
import appeng.block.qnb.QnbFormedModel;
|
||||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||||
|
import appeng.bootstrap.components.IClientSetupComponent;
|
||||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||||
import appeng.bootstrap.components.IItemColorRegistrationComponent;
|
import appeng.bootstrap.components.IItemColorRegistrationComponent;
|
||||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||||
@@ -118,6 +111,13 @@ import appeng.client.gui.implementations.UpgradeableScreen;
|
|||||||
import appeng.client.gui.implementations.VibrationChamberScreen;
|
import appeng.client.gui.implementations.VibrationChamberScreen;
|
||||||
import appeng.client.gui.implementations.WirelessScreen;
|
import appeng.client.gui.implementations.WirelessScreen;
|
||||||
import appeng.client.gui.implementations.WirelessTermScreen;
|
import appeng.client.gui.implementations.WirelessTermScreen;
|
||||||
|
import appeng.client.render.DummyFluidItemModel;
|
||||||
|
import appeng.client.render.FacadeItemModel;
|
||||||
|
import appeng.client.render.SimpleModelLoader;
|
||||||
|
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||||
|
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||||
|
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||||
|
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||||
import appeng.client.render.effects.ChargedOreFX;
|
import appeng.client.render.effects.ChargedOreFX;
|
||||||
import appeng.client.render.effects.CraftingFx;
|
import appeng.client.render.effects.CraftingFx;
|
||||||
import appeng.client.render.effects.EnergyFx;
|
import appeng.client.render.effects.EnergyFx;
|
||||||
@@ -126,6 +126,13 @@ import appeng.client.render.effects.LightningFX;
|
|||||||
import appeng.client.render.effects.MatterCannonFX;
|
import appeng.client.render.effects.MatterCannonFX;
|
||||||
import appeng.client.render.effects.ParticleTypes;
|
import appeng.client.render.effects.ParticleTypes;
|
||||||
import appeng.client.render.effects.VibrantFX;
|
import appeng.client.render.effects.VibrantFX;
|
||||||
|
import appeng.client.render.model.BiometricCardModel;
|
||||||
|
import appeng.client.render.model.ColorApplicatorModel;
|
||||||
|
import appeng.client.render.model.DriveModel;
|
||||||
|
import appeng.client.render.model.GlassModel;
|
||||||
|
import appeng.client.render.model.MemoryCardModel;
|
||||||
|
import appeng.client.render.model.SkyCompassModel;
|
||||||
|
import appeng.client.render.spatial.SpatialPylonModel;
|
||||||
import appeng.client.render.tesr.InscriberTESR;
|
import appeng.client.render.tesr.InscriberTESR;
|
||||||
import appeng.client.render.tesr.SkyChestTESR;
|
import appeng.client.render.tesr.SkyChestTESR;
|
||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
@@ -193,21 +200,14 @@ import appeng.me.cache.PathGridCache;
|
|||||||
import appeng.me.cache.SecurityCache;
|
import appeng.me.cache.SecurityCache;
|
||||||
import appeng.me.cache.SpatialPylonCache;
|
import appeng.me.cache.SpatialPylonCache;
|
||||||
import appeng.me.cache.TickManagerCache;
|
import appeng.me.cache.TickManagerCache;
|
||||||
import appeng.mixins.StructureAccessor;
|
import appeng.parts.automation.PlaneModelLoader;
|
||||||
import appeng.recipes.game.DisassembleRecipe;
|
import appeng.recipes.game.DisassembleRecipe;
|
||||||
import appeng.recipes.game.FacadeRecipe;
|
import appeng.recipes.game.FacadeRecipe;
|
||||||
import appeng.recipes.handlers.GrinderRecipe;
|
|
||||||
import appeng.recipes.handlers.GrinderRecipeSerializer;
|
import appeng.recipes.handlers.GrinderRecipeSerializer;
|
||||||
import appeng.recipes.handlers.InscriberRecipe;
|
|
||||||
import appeng.recipes.handlers.InscriberRecipeSerializer;
|
import appeng.recipes.handlers.InscriberRecipeSerializer;
|
||||||
import appeng.server.AECommand;
|
import appeng.server.AECommand;
|
||||||
import appeng.spatial.StorageCellBiome;
|
|
||||||
import appeng.spatial.StorageChunkGenerator;
|
|
||||||
import appeng.tile.AEBaseTileEntity;
|
import appeng.tile.AEBaseTileEntity;
|
||||||
import appeng.tile.crafting.MolecularAssemblerRenderer;
|
import appeng.tile.crafting.MolecularAssemblerRenderer;
|
||||||
import appeng.worldgen.ChargedQuartzOreConfig;
|
|
||||||
import appeng.worldgen.ChargedQuartzOreFeature;
|
|
||||||
import appeng.worldgen.meteorite.MeteoriteStructure;
|
|
||||||
|
|
||||||
final class Registration {
|
final class Registration {
|
||||||
|
|
||||||
@@ -239,6 +239,39 @@ final class Registration {
|
|||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void modelRegistryEvent(ModelRegistryEvent event) {
|
public void modelRegistryEvent(ModelRegistryEvent event) {
|
||||||
registerSpecialModels();
|
registerSpecialModels();
|
||||||
|
|
||||||
|
// TODO: Do not use the internal API
|
||||||
|
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||||
|
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
||||||
|
.forEachRemaining(IClientSetupComponent::setup);
|
||||||
|
|
||||||
|
addBuiltInModel("glass", GlassModel::new);
|
||||||
|
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||||
|
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||||
|
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||||
|
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||||
|
addBuiltInModel("drive", DriveModel::new);
|
||||||
|
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||||
|
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||||
|
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||||
|
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||||
|
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||||
|
addBuiltInModel("facade", FacadeItemModel::new);
|
||||||
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
||||||
|
EncodedPatternModelLoader.INSTANCE);
|
||||||
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
||||||
|
PlaneModelLoader.INSTANCE);
|
||||||
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"),
|
||||||
|
CraftingCubeModelLoader.INSTANCE);
|
||||||
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"),
|
||||||
|
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||||
|
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id),
|
||||||
|
new SimpleModelLoader<>(modelFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -628,70 +661,6 @@ final class Registration {
|
|||||||
new ResourceLocation(dimension));
|
new ResourceLocation(dimension));
|
||||||
}
|
}
|
||||||
|
|
||||||
ForgeRegistries.BIOMES.forEach(b -> {
|
|
||||||
addMeteoriteWorldGen(b);
|
|
||||||
addQuartzWorldGen(b);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addMeteoriteWorldGen(Biome b) {
|
|
||||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
b.func_235063_a_(MeteoriteStructure.INSTANCE.func_236391_a_(IFeatureConfig.NO_FEATURE_CONFIG));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addQuartzWorldGen(Biome b) {
|
|
||||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockState quartzOre = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
|
||||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
|
|
||||||
Feature.ORE
|
|
||||||
.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
|
|
||||||
quartzOre, AEConfig.instance().getQuartzOresPerCluster()))
|
|
||||||
.withPlacement(Placement.COUNT_RANGE.configure(
|
|
||||||
new CountRangeConfig(AEConfig.instance().getQuartzOresClusterAmount(), 12, 12, 72))));
|
|
||||||
|
|
||||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
|
||||||
|
|
||||||
BlockState chargedQuartzOre = Api.instance().definitions().blocks().quartzOreCharged().block()
|
|
||||||
.getDefaultState();
|
|
||||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION,
|
|
||||||
ChargedQuartzOreFeature.INSTANCE
|
|
||||||
.withConfiguration(new ChargedQuartzOreConfig(quartzOre, chargedQuartzOre,
|
|
||||||
AEConfig.instance().getSpawnChargedChance()))
|
|
||||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerFeatures(RegistryEvent.Register<Feature<?>> evt) {
|
|
||||||
IForgeRegistry<Feature<?>> r = evt.getRegistry();
|
|
||||||
|
|
||||||
r.register(ChargedQuartzOreFeature.INSTANCE.setRegistryName(AppEng.makeId("charged_quartz_ore")));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerStructures(RegistryEvent.Register<Structure<?>> evt) {
|
|
||||||
// Registering into the Forge registry is INSUFFICIENT!
|
|
||||||
// There's a bidirectional map in the Structure class itself primarily for the
|
|
||||||
// purposes of NBT serialization
|
|
||||||
StructureAccessor.register(MeteoriteStructure.ID.toString(),
|
|
||||||
MeteoriteStructure.INSTANCE.setRegistryName(MeteoriteStructure.ID),
|
|
||||||
GenerationStage.Decoration.TOP_LAYER_MODIFICATION);
|
|
||||||
|
|
||||||
Registry.register(Registry.CHUNK_GENERATOR_CODEC, AppEng.makeId("storage"), StorageChunkGenerator.CODEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerBiomes(RegistryEvent.Register<Biome> evt) {
|
|
||||||
evt.getRegistry().register(StorageCellBiome.INSTANCE.setRegistryName(AppEng.makeId("storage")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@@ -726,7 +695,7 @@ final class Registration {
|
|||||||
|
|
||||||
modEventBus.addListener(this::registerParticleFactories);
|
modEventBus.addListener(this::registerParticleFactories);
|
||||||
modEventBus.addListener(this::registerTextures);
|
modEventBus.addListener(this::registerTextures);
|
||||||
MinecraftForge.EVENT_BUS.addListener(this::modelRegistryEvent);
|
modEventBus.addListener(this::modelRegistryEvent);
|
||||||
modEventBus.addListener(this::registerItemColors);
|
modEventBus.addListener(this::registerItemColors);
|
||||||
modEventBus.addListener(this::handleModelBake);
|
modEventBus.addListener(this::handleModelBake);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,12 @@ public class ApiCrafting implements ICraftingHelper {
|
|||||||
// We use the shared itemstack for an identity lookup.
|
// We use the shared itemstack for an identity lookup.
|
||||||
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is);
|
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is);
|
||||||
|
|
||||||
return new CraftingPatternDetails(ais, world);
|
try {
|
||||||
|
return new CraftingPatternDetails(ais, world);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
AELog.warn("Could not decode an invalid pattern %s: %s", is, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean attemptRecovery(EncodedPatternItem patternItem, ItemStack itemStack, World world) {
|
private boolean attemptRecovery(EncodedPatternItem patternItem, ItemStack itemStack, World world) {
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ public class ApiPart implements IPartHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CableRenderMode getCableRenderMode() {
|
public CableRenderMode getCableRenderMode() {
|
||||||
return AppEng.proxy.getRenderMode();
|
return AppEng.proxy.getCableRenderMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ package appeng.core.api.definitions;
|
|||||||
|
|
||||||
import static appeng.block.AEBaseBlock.defaultProps;
|
import static appeng.block.AEBaseBlock.defaultProps;
|
||||||
|
|
||||||
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.DispenserBlock;
|
import net.minecraft.block.DispenserBlock;
|
||||||
import net.minecraft.block.SlabBlock;
|
import net.minecraft.block.SlabBlock;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
@@ -28,6 +30,7 @@ import net.minecraft.block.StairsBlock;
|
|||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.entity.EntityClassification;
|
import net.minecraft.entity.EntityClassification;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
@@ -39,6 +42,7 @@ import appeng.api.features.AEFeature;
|
|||||||
import appeng.block.AEBaseBlockItemChargeable;
|
import appeng.block.AEBaseBlockItemChargeable;
|
||||||
import appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType;
|
import appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType;
|
||||||
import appeng.block.crafting.CraftingMonitorBlock;
|
import appeng.block.crafting.CraftingMonitorBlock;
|
||||||
|
import appeng.block.crafting.CraftingMonitorBlockRendering;
|
||||||
import appeng.block.crafting.CraftingStorageBlock;
|
import appeng.block.crafting.CraftingStorageBlock;
|
||||||
import appeng.block.crafting.CraftingStorageItem;
|
import appeng.block.crafting.CraftingStorageItem;
|
||||||
import appeng.block.crafting.CraftingUnitBlock;
|
import appeng.block.crafting.CraftingUnitBlock;
|
||||||
@@ -94,9 +98,8 @@ import appeng.bootstrap.components.IInitComponent;
|
|||||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
import appeng.client.render.crafting.CraftingCubeRendering;
|
import appeng.client.render.crafting.CraftingCubeRendering;
|
||||||
import appeng.client.render.crafting.CraftingMonitorTESR;
|
import appeng.client.render.crafting.CraftingMonitorTESR;
|
||||||
import appeng.client.render.crafting.MonitorBakedModel;
|
|
||||||
import appeng.client.render.model.AutoRotatingBakedModel;
|
|
||||||
import appeng.client.render.spatial.SpatialPylonRendering;
|
import appeng.client.render.spatial.SpatialPylonRendering;
|
||||||
|
import appeng.client.render.tesr.ChargerTESR;
|
||||||
import appeng.client.render.tesr.ChestTileEntityRenderer;
|
import appeng.client.render.tesr.ChestTileEntityRenderer;
|
||||||
import appeng.client.render.tesr.CrankTESR;
|
import appeng.client.render.tesr.CrankTESR;
|
||||||
import appeng.client.render.tesr.DriveLedTileEntityRenderer;
|
import appeng.client.render.tesr.DriveLedTileEntityRenderer;
|
||||||
@@ -262,18 +265,20 @@ public final class ApiBlocks implements IBlocks {
|
|||||||
this.chiseledQuartzBlock = deco.block("chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES))
|
this.chiseledQuartzBlock = deco.block("chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS)
|
AbstractBlock.IExtendedPositionPredicate<EntityType<?>> neverAllowSpawn = (p1, p2, p3, p4) -> false;
|
||||||
.block("quartz_glass", () -> new QuartzGlassBlock(defaultProps(Material.GLASS).notSolid()))
|
this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS).block("quartz_glass", () -> {
|
||||||
.rendering(new BlockRenderingCustomizer() {
|
return new QuartzGlassBlock(defaultProps(Material.GLASS).notSolid().setAllowsSpawn(neverAllowSpawn));
|
||||||
@Override
|
}).rendering(new BlockRenderingCustomizer() {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@Override
|
||||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
@OnlyIn(Dist.CLIENT)
|
||||||
rendering.renderType(RenderType.getCutout());
|
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||||
}
|
rendering.renderType(RenderType.getCutout());
|
||||||
}).build();
|
}
|
||||||
|
}).build();
|
||||||
this.quartzVibrantGlass = deco
|
this.quartzVibrantGlass = deco
|
||||||
.block("quartz_vibrant_glass",
|
.block("quartz_vibrant_glass",
|
||||||
() -> new QuartzLampBlock(defaultProps(Material.GLASS).setLightLevel(b -> 15).notSolid()))
|
() -> new QuartzLampBlock(defaultProps(Material.GLASS).setLightLevel(b -> 15).notSolid()
|
||||||
|
.setAllowsSpawn(neverAllowSpawn)))
|
||||||
.addFeatures(AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS)
|
.addFeatures(AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS)
|
||||||
.rendering(new BlockRenderingCustomizer() {
|
.rendering(new BlockRenderingCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
@@ -371,7 +376,7 @@ public final class ApiBlocks implements IBlocks {
|
|||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void customize(TileEntityRendering<ChargerTileEntity> rendering) {
|
public void customize(TileEntityRendering<ChargerTileEntity> rendering) {
|
||||||
rendering.tileEntityRenderer(ChargerBlock.createTesr());
|
rendering.tileEntityRenderer(ChargerTESR.FACTORY);
|
||||||
}
|
}
|
||||||
}).build())
|
}).build())
|
||||||
.build();
|
.build();
|
||||||
@@ -532,20 +537,7 @@ public final class ApiBlocks implements IBlocks {
|
|||||||
rendering.tileEntityRenderer(CraftingMonitorTESR::new);
|
rendering.tileEntityRenderer(CraftingMonitorTESR::new);
|
||||||
}
|
}
|
||||||
}).build())
|
}).build())
|
||||||
.rendering(new BlockRenderingCustomizer() {
|
.rendering(new CraftingMonitorBlockRendering()).build();
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
|
||||||
rendering.renderType(RenderType.getCutout());
|
|
||||||
rendering.modelCustomizer((path, model) -> {
|
|
||||||
// The formed model handles rotations itself, the unformed one does not
|
|
||||||
if (model instanceof MonitorBakedModel) {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
return new AutoRotatingBakedModel(model);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).build();
|
|
||||||
|
|
||||||
this.molecularAssembler = registry
|
this.molecularAssembler = registry
|
||||||
.block("molecular_assembler", () -> new MolecularAssemblerBlock(defaultProps(Material.IRON).notSolid()))
|
.block("molecular_assembler", () -> new MolecularAssemblerBlock(defaultProps(Material.IRON).notSolid()))
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ import java.util.function.Consumer;
|
|||||||
import net.minecraft.entity.EntityClassification;
|
import net.minecraft.entity.EntityClassification;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.ItemModelsProperties;
|
||||||
|
import net.minecraft.item.Rarity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
@@ -35,6 +38,8 @@ import appeng.api.util.AEColoredItemDefinition;
|
|||||||
import appeng.bootstrap.FeatureFactory;
|
import appeng.bootstrap.FeatureFactory;
|
||||||
import appeng.bootstrap.IItemRendering;
|
import appeng.bootstrap.IItemRendering;
|
||||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||||
|
import appeng.bootstrap.components.IClientSetupComponent;
|
||||||
|
import appeng.core.AppEng;
|
||||||
import appeng.core.features.ActivityState;
|
import appeng.core.features.ActivityState;
|
||||||
import appeng.core.features.ColoredItemDefinition;
|
import appeng.core.features.ColoredItemDefinition;
|
||||||
import appeng.core.features.ItemStackSrc;
|
import appeng.core.features.ItemStackSrc;
|
||||||
@@ -51,6 +56,7 @@ import appeng.hooks.BlockToolDispenseItemBehavior;
|
|||||||
import appeng.hooks.MatterCannonDispenseItemBehavior;
|
import appeng.hooks.MatterCannonDispenseItemBehavior;
|
||||||
import appeng.items.materials.MaterialType;
|
import appeng.items.materials.MaterialType;
|
||||||
import appeng.items.misc.CrystalSeedItem;
|
import appeng.items.misc.CrystalSeedItem;
|
||||||
|
import appeng.items.misc.CrystalSeedRendering;
|
||||||
import appeng.items.misc.EncodedPatternItem;
|
import appeng.items.misc.EncodedPatternItem;
|
||||||
import appeng.items.misc.PaintBallItem;
|
import appeng.items.misc.PaintBallItem;
|
||||||
import appeng.items.misc.PaintBallItemRendering;
|
import appeng.items.misc.PaintBallItemRendering;
|
||||||
@@ -210,7 +216,22 @@ public final class ApiItems implements IItems {
|
|||||||
.addFeatures(AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS).build();
|
.addFeatures(AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS).build();
|
||||||
this.colorApplicator = powerTools.item("color_applicator", ColorApplicatorItem::new).props(chargedDefaults)
|
this.colorApplicator = powerTools.item("color_applicator", ColorApplicatorItem::new).props(chargedDefaults)
|
||||||
.addFeatures(AEFeature.COLOR_APPLICATOR).dispenserBehavior(BlockToolDispenseItemBehavior::new)
|
.addFeatures(AEFeature.COLOR_APPLICATOR).dispenserBehavior(BlockToolDispenseItemBehavior::new)
|
||||||
.rendering(new ColorApplicatorItemRendering()).build();
|
.bootstrap(item -> new IClientSetupComponent() {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void setup() {
|
||||||
|
ColorApplicatorItem colorApplicatorItem = (ColorApplicatorItem) item;
|
||||||
|
ItemModelsProperties.func_239418_a_(item, new ResourceLocation(AppEng.MOD_ID, "colored"),
|
||||||
|
(itemStack, world, entity) -> {
|
||||||
|
// If the stack has no color, don't use the colored model since the impact of
|
||||||
|
// calling getColor for every quad is extremely high, if the stack tries to
|
||||||
|
// re-search its
|
||||||
|
// inventory for a new paintball everytime
|
||||||
|
AEColor col = colorApplicatorItem.getActiveColor(itemStack);
|
||||||
|
return (col != null) ? 1 : 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).rendering(new ColorApplicatorItemRendering()).build();
|
||||||
|
|
||||||
this.biometricCard = registry.item("biometric_card", BiometricCardItem::new)
|
this.biometricCard = registry.item("biometric_card", BiometricCardItem::new)
|
||||||
.props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build();
|
.props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build();
|
||||||
@@ -221,7 +242,8 @@ public final class ApiItems implements IItems {
|
|||||||
.features(AEFeature.NETWORK_TOOL).build();
|
.features(AEFeature.NETWORK_TOOL).build();
|
||||||
|
|
||||||
this.cellCreative = registry.item("creative_storage_cell", CreativeStorageCellItem::new)
|
this.cellCreative = registry.item("creative_storage_cell", CreativeStorageCellItem::new)
|
||||||
.props(props -> props.maxStackSize(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build();
|
.props(props -> props.maxStackSize(1).rarity(Rarity.EPIC))
|
||||||
|
.features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build();
|
||||||
this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxStackSize(1))
|
this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxStackSize(1))
|
||||||
.features(AEFeature.VIEW_CELL).build();
|
.features(AEFeature.VIEW_CELL).build();
|
||||||
|
|
||||||
@@ -278,19 +300,19 @@ public final class ApiItems implements IItems {
|
|||||||
this.certusCrystalSeed = registry
|
this.certusCrystalSeed = registry
|
||||||
.item("certus_crystal_seed",
|
.item("certus_crystal_seed",
|
||||||
props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
|
props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
|
||||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||||
this.fluixCrystalSeed = registry
|
this.fluixCrystalSeed = registry
|
||||||
.item("fluix_crystal_seed",
|
.item("fluix_crystal_seed",
|
||||||
props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
|
props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
|
||||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||||
this.netherQuartzSeed = registry
|
this.netherQuartzSeed = registry
|
||||||
.item("nether_quartz_seed",
|
.item("nether_quartz_seed",
|
||||||
props -> new CrystalSeedItem(props, materials.purifiedNetherQuartzCrystal().item()))
|
props -> new CrystalSeedItem(props, materials.purifiedNetherQuartzCrystal().item()))
|
||||||
.features(AEFeature.CRYSTAL_SEEDS).build();
|
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
|
||||||
|
|
||||||
GrowingCrystalEntity.TYPE = registry
|
GrowingCrystalEntity.TYPE = registry
|
||||||
.<GrowingCrystalEntity>entity("growing_crystal", GrowingCrystalEntity::new, EntityClassification.MISC)
|
.<GrowingCrystalEntity>entity("growing_crystal", GrowingCrystalEntity::new, EntityClassification.MISC)
|
||||||
.customize(builder -> builder.size(0.25F, 0.25F)).build();
|
.customize(builder -> builder.size(0.25F, 0.4F)).build();
|
||||||
|
|
||||||
// rv1
|
// rv1
|
||||||
this.encodedPattern = registry.item("encoded_pattern", EncodedPatternItem::new)
|
this.encodedPattern = registry.item("encoded_pattern", EncodedPatternItem::new)
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
|
|
||||||
import appeng.api.events.LocatableEventAnnounce;
|
import appeng.api.events.LocatableEventAnnounce;
|
||||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||||
import appeng.api.features.ILocatable;
|
import appeng.api.features.ILocatable;
|
||||||
import appeng.api.features.ILocatableRegistry;
|
import appeng.api.features.ILocatableRegistry;
|
||||||
|
import appeng.core.AELog;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public final class LocatableRegistry implements ILocatableRegistry {
|
public final class LocatableRegistry implements ILocatableRegistry {
|
||||||
@@ -35,18 +35,19 @@ public final class LocatableRegistry implements ILocatableRegistry {
|
|||||||
|
|
||||||
public LocatableRegistry() {
|
public LocatableRegistry() {
|
||||||
this.set = new HashMap<>();
|
this.set = new HashMap<>();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.addListener(this::updateLocatable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
private void updateLocatable(final LocatableEventAnnounce e) {
|
||||||
public void updateLocatable(final LocatableEventAnnounce e) {
|
|
||||||
if (Platform.isClient()) {
|
if (Platform.isClient()) {
|
||||||
return; // IGNORE!
|
return; // IGNORE!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.change == LocatableEvent.REGISTER) {
|
if (e.change == LocatableEvent.REGISTER) {
|
||||||
|
AELog.debug("Registering locatable %s: %s", e.target.getLocatableSerial(), e.target);
|
||||||
this.set.put(e.target.getLocatableSerial(), e.target);
|
this.set.put(e.target.getLocatableSerial(), e.target);
|
||||||
} else if (e.change == LocatableEvent.UNREGISTER) {
|
} else if (e.change == LocatableEvent.UNREGISTER) {
|
||||||
|
AELog.debug("Unregistering locatable %s: %s", e.target.getLocatableSerial(), e.target);
|
||||||
this.set.remove(e.target.getLocatableSerial());
|
this.set.remove(e.target.getLocatableSerial());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ public class MovableTileRegistry implements IMovableRegistry {
|
|||||||
private final List<IMovableHandler> handlers = new ArrayList<>();
|
private final List<IMovableHandler> handlers = new ArrayList<>();
|
||||||
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
||||||
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
|
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||||
private final ITag<Block> blockTagWhiteList;
|
private final ITag.INamedTag<Block> blockTagWhiteList;
|
||||||
private final ITag<Block> blockTagBlackList;
|
private final ITag.INamedTag<Block> blockTagBlackList;
|
||||||
|
|
||||||
public MovableTileRegistry() {
|
public MovableTileRegistry() {
|
||||||
this.blockTagWhiteList = BlockTags.getCollection().getOrCreate(TAG_WHITELIST);
|
this.blockTagWhiteList = BlockTags.makeWrapperTag(TAG_WHITELIST.toString());
|
||||||
this.blockTagBlackList = BlockTags.getCollection().getOrCreate(TAG_BLACKLIST);
|
this.blockTagBlackList = BlockTags.makeWrapperTag(TAG_BLACKLIST.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import appeng.core.sync.packets.BlockTransitionEffectPacket;
|
|||||||
import appeng.core.sync.packets.ClickPacket;
|
import appeng.core.sync.packets.ClickPacket;
|
||||||
import appeng.core.sync.packets.CompassRequestPacket;
|
import appeng.core.sync.packets.CompassRequestPacket;
|
||||||
import appeng.core.sync.packets.CompassResponsePacket;
|
import appeng.core.sync.packets.CompassResponsePacket;
|
||||||
import appeng.core.sync.packets.CompressedNBTPacket;
|
|
||||||
import appeng.core.sync.packets.ConfigButtonPacket;
|
import appeng.core.sync.packets.ConfigButtonPacket;
|
||||||
import appeng.core.sync.packets.ConfigValuePacket;
|
import appeng.core.sync.packets.ConfigValuePacket;
|
||||||
import appeng.core.sync.packets.CraftRequestPacket;
|
import appeng.core.sync.packets.CraftRequestPacket;
|
||||||
@@ -39,6 +38,7 @@ import appeng.core.sync.packets.ItemTransitionEffectPacket;
|
|||||||
import appeng.core.sync.packets.JEIRecipePacket;
|
import appeng.core.sync.packets.JEIRecipePacket;
|
||||||
import appeng.core.sync.packets.LightningPacket;
|
import appeng.core.sync.packets.LightningPacket;
|
||||||
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
|
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
|
||||||
|
import appeng.core.sync.packets.MEInterfaceUpdatePacket;
|
||||||
import appeng.core.sync.packets.MEInventoryUpdatePacket;
|
import appeng.core.sync.packets.MEInventoryUpdatePacket;
|
||||||
import appeng.core.sync.packets.MatterCannonPacket;
|
import appeng.core.sync.packets.MatterCannonPacket;
|
||||||
import appeng.core.sync.packets.MockExplosionPacket;
|
import appeng.core.sync.packets.MockExplosionPacket;
|
||||||
@@ -101,7 +101,7 @@ public class BasePacketHandler {
|
|||||||
|
|
||||||
PACKET_ASSEMBLER_ANIMATION(AssemblerAnimationPacket.class, AssemblerAnimationPacket::new),
|
PACKET_ASSEMBLER_ANIMATION(AssemblerAnimationPacket.class, AssemblerAnimationPacket::new),
|
||||||
|
|
||||||
PACKET_COMPRESSED_NBT(CompressedNBTPacket.class, CompressedNBTPacket::new),
|
PACKET_ME_INTERFACE_UPDATE(MEInterfaceUpdatePacket.class, MEInterfaceUpdatePacket::new),
|
||||||
|
|
||||||
PACKET_PAINTED_ENTITY(PaintedEntityPacket.class, PaintedEntityPacket::new),
|
PACKET_PAINTED_ENTITY(PaintedEntityPacket.class, PaintedEntityPacket::new),
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
|
|||||||
|
|
||||||
data.writeInt(this.getPacketID());
|
data.writeInt(this.getPacketID());
|
||||||
data.writeBlockPos(pos);
|
data.writeBlockPos(pos);
|
||||||
int blockStateId = GameData.getBlockStateIDMap().get(blockState);
|
int blockStateId = GameData.getBlockStateIDMap().getId(blockState);
|
||||||
if (blockStateId == -1) {
|
if (blockStateId == -1) {
|
||||||
AELog.warn("Failed to find numeric id for block state %s", blockState);
|
AELog.warn("Failed to find numeric id for block state %s", blockState);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,27 @@
|
|||||||
|
|
||||||
package appeng.core.sync.packets;
|
package appeng.core.sync.packets;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||||
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.item.crafting.ShapedRecipe;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
@@ -40,8 +52,10 @@ import appeng.api.networking.storage.IStorageGrid;
|
|||||||
import appeng.api.storage.IMEMonitor;
|
import appeng.api.storage.IMEMonitor;
|
||||||
import appeng.api.storage.channels.IItemStorageChannel;
|
import appeng.api.storage.channels.IItemStorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
import appeng.container.implementations.PatternTermContainer;
|
||||||
import appeng.core.Api;
|
import appeng.core.Api;
|
||||||
import appeng.core.sync.BasePacket;
|
import appeng.core.sync.BasePacket;
|
||||||
|
import appeng.core.sync.BasePacketHandler;
|
||||||
import appeng.core.sync.network.INetworkInfo;
|
import appeng.core.sync.network.INetworkInfo;
|
||||||
import appeng.helpers.IContainerCraftingPacket;
|
import appeng.helpers.IContainerCraftingPacket;
|
||||||
import appeng.items.storage.ViewCellItem;
|
import appeng.items.storage.ViewCellItem;
|
||||||
@@ -54,152 +68,289 @@ import appeng.util.prioritylist.IPartitionList;
|
|||||||
|
|
||||||
public class JEIRecipePacket extends BasePacket {
|
public class JEIRecipePacket extends BasePacket {
|
||||||
|
|
||||||
private ItemStack[][] recipe;
|
/**
|
||||||
|
* Transmit only a recipe ID.
|
||||||
|
*/
|
||||||
|
private static final int INLINE_RECIPE_NONE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmit the information about the recipe we actually need. This is
|
||||||
|
* explicitly limited since this is untrusted client->server info.
|
||||||
|
*/
|
||||||
|
private static final int INLINE_RECIPE_SHAPED = 2;
|
||||||
|
|
||||||
|
private ResourceLocation recipeId;
|
||||||
|
/**
|
||||||
|
* This is optional, in case the client already knows it could not resolve the
|
||||||
|
* recipe id.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private IRecipe<?> recipe;
|
||||||
|
private boolean crafting;
|
||||||
|
|
||||||
public JEIRecipePacket(final PacketBuffer stream) {
|
public JEIRecipePacket(final PacketBuffer stream) {
|
||||||
final CompoundNBT comp = stream.readCompoundTag();
|
this.crafting = stream.readBoolean();
|
||||||
if (comp != null) {
|
final String id = stream.readString(Short.MAX_VALUE);
|
||||||
this.recipe = new ItemStack[9][];
|
this.recipeId = new ResourceLocation(id);
|
||||||
for (int x = 0; x < this.recipe.length; x++) {
|
|
||||||
final ListNBT list = comp.getList("#" + x, 10);
|
|
||||||
if (list.size() > 0) {
|
|
||||||
this.recipe[x] = new ItemStack[list.size()];
|
|
||||||
for (int y = 0; y < list.size(); y++) {
|
|
||||||
this.recipe[x][y] = ItemStack.read(list.getCompound(y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// api
|
int inlineRecipeType = stream.readVarInt();
|
||||||
public JEIRecipePacket(final CompoundNBT recipe) {
|
switch (inlineRecipeType) {
|
||||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
case INLINE_RECIPE_NONE:
|
||||||
|
break;
|
||||||
data.writeInt(this.getPacketID());
|
case INLINE_RECIPE_SHAPED:
|
||||||
|
recipe = IRecipeSerializer.CRAFTING_SHAPED.read(this.recipeId, stream);
|
||||||
data.writeCompoundTag(recipe);
|
break;
|
||||||
|
default:
|
||||||
this.configureWrite(data);
|
throw new IllegalArgumentException("Invalid inline recipe type.");
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
|
||||||
final ServerPlayerEntity pmp = (ServerPlayerEntity) player;
|
|
||||||
final Container con = pmp.openContainer;
|
|
||||||
|
|
||||||
if (!(con instanceof IContainerCraftingPacket)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
|
||||||
final IGridNode node = cct.getNetworkNode();
|
|
||||||
|
|
||||||
if (node == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final IGrid grid = node.getGrid();
|
|
||||||
if (grid == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
|
||||||
final IEnergyGrid energy = grid.getCache(IEnergyGrid.class);
|
|
||||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
|
||||||
final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class);
|
|
||||||
final IItemHandler craftMatrix = cct.getInventoryByName("crafting");
|
|
||||||
final IItemHandler playerInventory = cct.getInventoryByName("player");
|
|
||||||
|
|
||||||
if (inv != null && this.recipe != null && security != null) {
|
|
||||||
final IMEMonitor<IAEItemStack> storage = inv
|
|
||||||
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
|
||||||
final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells());
|
|
||||||
|
|
||||||
for (int x = 0; x < craftMatrix.getSlots(); x++) {
|
|
||||||
ItemStack currentItem = craftMatrix.getStackInSlot(x);
|
|
||||||
|
|
||||||
// prepare slots
|
|
||||||
if (!currentItem.isEmpty()) {
|
|
||||||
// already the correct item?
|
|
||||||
ItemStack newItem = this.canUseInSlot(x, currentItem);
|
|
||||||
|
|
||||||
// put away old item
|
|
||||||
if (newItem != currentItem && security.hasPermission(player, SecurityPermissions.INJECT)) {
|
|
||||||
final IAEItemStack in = AEItemStack.fromItemStack(currentItem);
|
|
||||||
final IAEItemStack out = cct.useRealItems()
|
|
||||||
? Platform.poweredInsert(energy, storage, in, cct.getActionSource())
|
|
||||||
: null;
|
|
||||||
if (out != null) {
|
|
||||||
currentItem = out.createItemStack();
|
|
||||||
} else {
|
|
||||||
currentItem = ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentItem.isEmpty() && this.recipe[x] != null) {
|
|
||||||
// for each variant
|
|
||||||
for (int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++) {
|
|
||||||
final IAEItemStack request = AEItemStack.fromItemStack(this.recipe[x][y]);
|
|
||||||
if (request != null) {
|
|
||||||
// try ae
|
|
||||||
if ((filter == null || filter.isListed(request))
|
|
||||||
&& security.hasPermission(player, SecurityPermissions.EXTRACT)) {
|
|
||||||
request.setStackSize(1);
|
|
||||||
IAEItemStack out;
|
|
||||||
|
|
||||||
if (cct.useRealItems()) {
|
|
||||||
out = Platform.poweredExtraction(energy, storage, request, cct.getActionSource());
|
|
||||||
} else {
|
|
||||||
// Query the crafting grid if there is a pattern providing the item
|
|
||||||
if (!crafting.getCraftingFor(request, null, 0, null).isEmpty()) {
|
|
||||||
out = request;
|
|
||||||
} else {
|
|
||||||
// Fall back using an existing item
|
|
||||||
out = storage.extractItems(request, Actionable.SIMULATE, cct.getActionSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out != null) {
|
|
||||||
currentItem = out.createItemStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// try inventory
|
|
||||||
if (currentItem.isEmpty()) {
|
|
||||||
AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory);
|
|
||||||
|
|
||||||
if (cct.useRealItems()) {
|
|
||||||
currentItem = ad.removeItems(1, this.recipe[x][y], null);
|
|
||||||
} else {
|
|
||||||
currentItem = ad.simulateRemove(1, this.recipe[x][y], null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ItemHandlerUtil.setStackInSlot(craftMatrix, x, currentItem);
|
|
||||||
}
|
|
||||||
con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Sends a recipe identified by the given recipe ID to the server for either
|
||||||
* @param slot
|
* filling a crafting grid or a pattern.
|
||||||
* @param is itemstack
|
|
||||||
* @return is if it can be used, else EMPTY
|
|
||||||
*/
|
*/
|
||||||
private ItemStack canUseInSlot(int slot, ItemStack is) {
|
public JEIRecipePacket(final ResourceLocation recipeId, final boolean crafting) {
|
||||||
if (this.recipe[slot] != null) {
|
PacketBuffer data = createCommonHeader(recipeId, crafting, INLINE_RECIPE_NONE);
|
||||||
for (ItemStack option : this.recipe[slot]) {
|
this.configureWrite(data);
|
||||||
if (is.isItemEqual(option)) {
|
}
|
||||||
return is;
|
|
||||||
|
/**
|
||||||
|
* Sends a recipe to the server for either filling a crafting grid or a pattern.
|
||||||
|
* <p>
|
||||||
|
* Prefer the id-based constructor above whereever possible.
|
||||||
|
*/
|
||||||
|
public JEIRecipePacket(final ShapedRecipe recipe, final boolean crafting) {
|
||||||
|
PacketBuffer data = createCommonHeader(recipe.getId(), crafting, INLINE_RECIPE_SHAPED);
|
||||||
|
IRecipeSerializer.CRAFTING_SHAPED.write(data, recipe);
|
||||||
|
this.configureWrite(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PacketBuffer createCommonHeader(ResourceLocation recipeId, boolean crafting, int inlineRecipeType) {
|
||||||
|
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||||
|
|
||||||
|
data.writeInt(this.getPacketID());
|
||||||
|
data.writeBoolean(crafting);
|
||||||
|
data.writeResourceLocation(recipeId);
|
||||||
|
data.writeVarInt(inlineRecipeType);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Servside handler for this packet.
|
||||||
|
* <p>
|
||||||
|
* Makes use of {@link Preconditions#checkArgument(boolean)} as the
|
||||||
|
* {@link BasePacketHandler} is catching them and in general these cases should
|
||||||
|
* never happen except in an error case and should be logged then.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||||
|
// Setup and verification
|
||||||
|
final ServerPlayerEntity pmp = (ServerPlayerEntity) player;
|
||||||
|
final Container con = pmp.openContainer;
|
||||||
|
Preconditions.checkArgument(con instanceof IContainerCraftingPacket);
|
||||||
|
|
||||||
|
IRecipe<?> recipe = player.getEntityWorld().getRecipeManager().getRecipe(this.recipeId).orElse(null);
|
||||||
|
if (recipe == null && this.recipe != null) {
|
||||||
|
// Certain recipes (i.e. AE2 facades) are represented in JEI as ShapedRecipe's,
|
||||||
|
// while in reality they
|
||||||
|
// are special recipes. Those recipes are sent across the wire...
|
||||||
|
recipe = this.recipe;
|
||||||
|
}
|
||||||
|
Preconditions.checkArgument(recipe != null);
|
||||||
|
|
||||||
|
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||||
|
final IGridNode node = cct.getNetworkNode();
|
||||||
|
|
||||||
|
Preconditions.checkArgument(node != null);
|
||||||
|
|
||||||
|
final IGrid grid = node.getGrid();
|
||||||
|
Preconditions.checkArgument(grid != null);
|
||||||
|
|
||||||
|
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||||
|
Preconditions.checkArgument(inv != null);
|
||||||
|
|
||||||
|
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||||
|
Preconditions.checkArgument(security != null);
|
||||||
|
|
||||||
|
final IEnergyGrid energy = grid.getCache(IEnergyGrid.class);
|
||||||
|
final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class);
|
||||||
|
final IItemHandler craftMatrix = cct.getInventoryByName("crafting");
|
||||||
|
final IItemHandler playerInventory = cct.getInventoryByName("player");
|
||||||
|
|
||||||
|
final IMEMonitor<IAEItemStack> storage = inv
|
||||||
|
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||||
|
final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells());
|
||||||
|
final NonNullList<Ingredient> ingredients = this.ensure3by3CraftingMatrix(recipe);
|
||||||
|
|
||||||
|
// Handle each slot
|
||||||
|
for (int x = 0; x < craftMatrix.getSlots(); x++) {
|
||||||
|
ItemStack currentItem = craftMatrix.getStackInSlot(x);
|
||||||
|
Ingredient ingredient = ingredients.get(x);
|
||||||
|
|
||||||
|
// prepare slots
|
||||||
|
if (!currentItem.isEmpty()) {
|
||||||
|
// already the correct item? True, skip everything else
|
||||||
|
ItemStack newItem = this.canUseInSlot(ingredient, currentItem);
|
||||||
|
|
||||||
|
// put away old item, if not correct
|
||||||
|
if (newItem != currentItem && security.hasPermission(player, SecurityPermissions.INJECT)) {
|
||||||
|
final IAEItemStack in = AEItemStack.fromItemStack(currentItem);
|
||||||
|
final IAEItemStack out = cct.useRealItems()
|
||||||
|
? Platform.poweredInsert(energy, storage, in, cct.getActionSource())
|
||||||
|
: null;
|
||||||
|
if (out != null) {
|
||||||
|
currentItem = out.createItemStack();
|
||||||
|
} else {
|
||||||
|
currentItem = ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find item or pattern from the network
|
||||||
|
if (currentItem.isEmpty() && security.hasPermission(player, SecurityPermissions.EXTRACT)) {
|
||||||
|
IAEItemStack out;
|
||||||
|
|
||||||
|
if (cct.useRealItems()) {
|
||||||
|
IAEItemStack request = findBestMatchingItemStack(ingredient, filter, storage, cct);
|
||||||
|
out = request != null
|
||||||
|
? Platform.poweredExtraction(energy, storage, request.setStackSize(1),
|
||||||
|
cct.getActionSource())
|
||||||
|
: null;
|
||||||
|
} else {
|
||||||
|
out = findBestMatchingPattern(ingredient, filter, crafting, storage, cct);
|
||||||
|
if (out == null) {
|
||||||
|
out = findBestMatchingItemStack(ingredient, filter, storage, cct);
|
||||||
|
}
|
||||||
|
if (out == null && ingredient.getMatchingStacks().length > 0) {
|
||||||
|
out = AEItemStack.fromItemStack(ingredient.getMatchingStacks()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null) {
|
||||||
|
currentItem = out.createItemStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If still nothing, search the player inventory.
|
||||||
|
if (currentItem.isEmpty()) {
|
||||||
|
ItemStack[] matchingStacks = ingredient.getMatchingStacks();
|
||||||
|
for (ItemStack matchingStack : matchingStacks) {
|
||||||
|
if (currentItem.isEmpty()) {
|
||||||
|
AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory);
|
||||||
|
|
||||||
|
if (cct.useRealItems()) {
|
||||||
|
currentItem = ad.removeItems(1, matchingStack, null);
|
||||||
|
} else {
|
||||||
|
currentItem = ad.simulateRemove(1, matchingStack, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemHandlerUtil.setStackInSlot(craftMatrix, x, currentItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.crafting) {
|
||||||
|
this.handleProcessing(con, cct, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand any recipe to a 3x3 matrix.
|
||||||
|
* <p>
|
||||||
|
* Will throw an {@link IllegalArgumentException} in case it has more than 9 or
|
||||||
|
* a shaped recipe is either wider or higher than 3. ingredients.
|
||||||
|
*/
|
||||||
|
private NonNullList<Ingredient> ensure3by3CraftingMatrix(IRecipe<?> recipe) {
|
||||||
|
NonNullList<Ingredient> ingredients = recipe.getIngredients();
|
||||||
|
NonNullList<Ingredient> expandedIngredients = NonNullList.withSize(9, Ingredient.EMPTY);
|
||||||
|
|
||||||
|
Preconditions.checkArgument(ingredients.size() <= 9);
|
||||||
|
|
||||||
|
// shaped recipes can be smaller than 3x3, expand to 3x3 to match the crafting
|
||||||
|
// matrix
|
||||||
|
if (recipe instanceof IShapedRecipe) {
|
||||||
|
IShapedRecipe<?> shapedRecipe = (IShapedRecipe<?>) recipe;
|
||||||
|
int width = shapedRecipe.getRecipeWidth();
|
||||||
|
int height = shapedRecipe.getRecipeHeight();
|
||||||
|
Preconditions.checkArgument(width <= 3 && height <= 3);
|
||||||
|
|
||||||
|
for (int h = 0; h < height; h++) {
|
||||||
|
for (int w = 0; w < width; w++) {
|
||||||
|
int source = w + h * width;
|
||||||
|
int target = w + h * 3;
|
||||||
|
Ingredient i = ingredients.get(source);
|
||||||
|
expandedIngredients.set(target, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ItemStack.EMPTY;
|
// Anything else should be a flat list
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < ingredients.size(); i++) {
|
||||||
|
expandedIngredients.set(i, ingredients.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return expandedIngredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param is itemstack
|
||||||
|
* @return is if it can be used, else EMPTY
|
||||||
|
*/
|
||||||
|
private ItemStack canUseInSlot(Ingredient ingredient, ItemStack is) {
|
||||||
|
return Arrays.stream(ingredient.getMatchingStacks()).filter(p -> p.isItemEqual(is)).findFirst()
|
||||||
|
.orElse(ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the first matching itemstack with the highest stored amount.
|
||||||
|
*/
|
||||||
|
private IAEItemStack findBestMatchingItemStack(Ingredient ingredients, IPartitionList<IAEItemStack> filter,
|
||||||
|
IMEMonitor<IAEItemStack> storage, IContainerCraftingPacket cct) {
|
||||||
|
return Arrays.stream(ingredients.getMatchingStacks()).map(AEItemStack::fromItemStack) //
|
||||||
|
.filter(r -> r != null && (filter == null || filter.isListed(r))) //
|
||||||
|
.map(s -> {
|
||||||
|
// Determine the stored count
|
||||||
|
IAEItemStack stored = storage.extractItems(s.copy().setStackSize(Long.MAX_VALUE),
|
||||||
|
Actionable.SIMULATE, cct.getActionSource());
|
||||||
|
return Pair.of(s, stored != null ? stored.getStackSize() : 0);
|
||||||
|
}).min((left, right) -> Long.compare(right.getSecond(), left.getSecond()))//
|
||||||
|
.map(Pair::getFirst).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tries to find the first pattern matching the list of ingredients.
|
||||||
|
* <p>
|
||||||
|
* As additional condition, it sorts by the stored amount to return the one with
|
||||||
|
* the highest stored amount.
|
||||||
|
*/
|
||||||
|
private IAEItemStack findBestMatchingPattern(Ingredient ingredients, IPartitionList<IAEItemStack> filter,
|
||||||
|
ICraftingGrid crafting, IMEMonitor<IAEItemStack> storage, IContainerCraftingPacket cct) {
|
||||||
|
return Arrays.stream(ingredients.getMatchingStacks()).map(AEItemStack::fromItemStack)
|
||||||
|
.filter(r -> r != null && (filter == null || filter.isListed(r)))
|
||||||
|
.map(s -> s.setCraftable(!crafting.getCraftingFor(s, null, 0, null).isEmpty()))
|
||||||
|
.filter(IAEItemStack::isCraftable).map(s -> {
|
||||||
|
final IAEItemStack stored = storage.extractItems(s, Actionable.SIMULATE, cct.getActionSource());
|
||||||
|
return s.setStackSize(stored != null ? stored.getStackSize() : 0);
|
||||||
|
}).min((left, right) -> {
|
||||||
|
final int craftable = Boolean.compare(left.isCraftable(), right.isCraftable());
|
||||||
|
return craftable != 0 ? craftable : Long.compare(right.getStackSize(), left.getStackSize());
|
||||||
|
}).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleProcessing(Container con, IContainerCraftingPacket cct, IRecipe<?> recipe) {
|
||||||
|
if (con instanceof PatternTermContainer) {
|
||||||
|
PatternTermContainer patternTerm = (PatternTermContainer) con;
|
||||||
|
if (!patternTerm.craftingMode) {
|
||||||
|
final IItemHandler output = cct.getInventoryByName("output");
|
||||||
|
ItemHandlerUtil.setStackInSlot(output, 0, recipe.getRecipeOutput());
|
||||||
|
ItemHandlerUtil.setStackInSlot(output, 1, ItemStack.EMPTY);
|
||||||
|
ItemHandlerUtil.setStackInSlot(output, 2, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user