Compare commits

..

32 Commits

Author SHA1 Message Date
Sebastian Hartte 53f7046f93 Metrics WIP 2020-09-10 18:55:22 +02:00
yueh 44544c598f Fixes #4253: Just transfer the recipe id instead of every ingredient. (#4689)
* Fixes #4253: Just transfer the recipe id instead of every ingredient.
* If possible handle any IRecipe for processing mode
* Improvements and support for AE2 facades.
* Switched to using JEI's displayed stacks (which means we can remove the shapeless variant).

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
2020-09-09 14:08:24 +02:00
Sebastian Hartte bcee2ec427 Slightly increased the height of the item hitbox for crystals to make their pickup by annihilation planes less "clippy". 2020-09-09 02:23:58 +02:00
Sebastian Hartte 9e41d543f5 Merge remote-tracking branch 'origin/8.0.x-1.16.1' 2020-09-09 00:59:58 +02:00
Sebastian Hartte 0f469e9df6 Bumped Forge version. 2020-09-07 23:34:56 +02:00
Sebastian Hartte 12ca8d109a Merge remote-tracking branch 'origin/8.0.x-1.16.1' 2020-09-02 02:55:12 +02:00
shartte b756d68be1 Implemented a cache with maximum quad-count it will cache for the cable bus, (#4670)
which also fixes concurrent access to the hashmap.
2020-09-01 18:20:51 +02:00
Sebastian Hartte 60b07e5ca5 Merge branch '8.0.x-1.16.1' 2020-09-01 01:07:47 +02:00
shartte 957bc4c5cc Fixes removal of facades not invalidating the cached server-side collision boxes. (#4663) 2020-08-31 23:10:25 +02:00
yueh e90dd2f9c6 Serialize the complete NBT data to avoid mismatches (#4665)
This might increase the network traffic a bit, but the amount of mods actually using the share tag seems to be very limited.
For now it is worth the risk as it solves the problem. In case we run into actual issues, there might still be other solutions, which will be way more complex and can potentially introduce additional problems.
2020-08-31 23:09:14 +02:00
Sebastian Hartte 9719c7ffc3 Bump to Forge 33.0.22 2020-08-29 23:13:29 +02:00
Sebastian Hartte 319d92a371 Merge branch '8.0.x-1.16.1' 2020-08-29 22:18:12 +02:00
Masakitenchi 3a0552c56e Update zh_cn.json (#4653) 2020-08-28 10:49:11 +02:00
Sebastian Hartte 8a0dd192e5 Added Modmaven repository to README.md 2020-08-26 23:19:42 +02:00
Sebastian Hartte a97b35f3d0 Merge branch '8.0.x-1.16.1' 2020-08-26 11:39:20 +02:00
Sebastian Hartte 1394ab0863 Merge branch '8.0.x-1.16.1' 2020-08-24 23:54:57 +02:00
Sebastian Hartte 159f4c7f14 Merge branch '8.0.x-1.16.1' 2020-08-24 22:33:38 +02:00
Sebastian Hartte ee7fe9f40d Merge branch '8.0.x-1.16.1' 2020-08-24 01:06:50 +02:00
Sebastian Hartte 9c9a49f9e7 Merge branch '8.0.x-1.16.1' 2020-08-23 20:48:19 +02:00
Sebastian Hartte b7949e4134 Re-Enabled JEI and TOP in dev. 2020-08-22 19:56:37 +02:00
Sebastian Hartte ea95913ec8 Merge branch '8.0.x-1.16.1' 2020-08-22 19:38:36 +02:00
shartte 33d7f02323 Fixes #4590: Crystal seeds (other than certus) don't display their growth stages. (#4619) 2020-08-19 16:43:47 +02:00
shartte b8d4f0cffa Fixes #4611: Use of client-side only method for Tiny TNT explosion. (#4612) 2020-08-18 01:35:31 +02:00
yueh 7e1bfdb5ac Added step to publish to modmaven (#4607) 2020-08-17 22:28:01 +02:00
shartte 1f9707e256 Fixes #4602: Prevent encoding invalid patterns and handle corrupted patterns a little more gracefully. (#4608) 2020-08-17 21:50:28 +02:00
shartte 954ce1442e Fixes #4598: Incorrectly rotated face for determining block lightlevel in ME Chest renderer. (#4599) 2020-08-17 21:43:16 +02:00
Sebastian Hartte ee67c5ea50 Use different naming for fullbright, and always reset it back after setting it. 2020-08-16 14:05:10 +02:00
Sebastian Hartte 73735c5cd5 Remove use of func_244388_a, which is client-only. 2020-08-15 17:29:36 +02:00
Sebastian Hartte c1713f1682 Bump to Forge 33.0.5 2020-08-15 14:32:53 +02:00
Sebastian Hartte f455fd1994 Initial port to 1.16.2 2020-08-13 23:29:55 +02:00
Sebastian Hartte 1657c88681 Initial port to 1.16.2 2020-08-13 23:15:09 +02:00
Sebastian Hartte fd67e0e5c6 Initial port to 1.16.2 2020-08-13 23:14:49 +02:00
144 changed files with 1905 additions and 823 deletions
+11 -3
View File
@@ -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'
}
} }
} }
+7 -6
View File
@@ -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.108 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
######################################################### #########################################################
+2 -2
View File
@@ -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}")
@@ -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;
} }
@@ -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()) {
@@ -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
@@ -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;
} }
@@ -70,7 +70,6 @@ import appeng.client.gui.widgets.Scrollbar;
import appeng.client.me.InternalSlotME; import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected; import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME; import appeng.client.me.SlotME;
import appeng.client.render.FluidStackSizeRenderer;
import appeng.client.render.StackSizeRenderer; import appeng.client.render.StackSizeRenderer;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngCraftingSlot; import appeng.container.slot.AppEngCraftingSlot;
@@ -79,7 +78,6 @@ import appeng.container.slot.AppEngSlot.CalculatedValidity;
import appeng.container.slot.CraftingTermSlot; import appeng.container.slot.CraftingTermSlot;
import appeng.container.slot.DisabledSlot; import appeng.container.slot.DisabledSlot;
import appeng.container.slot.FakeSlot; import appeng.container.slot.FakeSlot;
import appeng.container.slot.IMEFluidSlot;
import appeng.container.slot.IOptionalSlot; import appeng.container.slot.IOptionalSlot;
import appeng.container.slot.InaccessibleSlot; import appeng.container.slot.InaccessibleSlot;
import appeng.container.slot.OutputSlot; import appeng.container.slot.OutputSlot;
@@ -90,6 +88,8 @@ import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.InventoryActionPacket; import appeng.core.sync.packets.InventoryActionPacket;
import appeng.core.sync.packets.SwapSlotsPacket; import appeng.core.sync.packets.SwapSlotsPacket;
import appeng.fluids.client.render.FluidStackSizeRenderer;
import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerScreen<T> { public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerScreen<T> {
@@ -218,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);
} }
@@ -37,8 +37,8 @@ import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource; import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.util.FluidSorters;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.FluidSorters;
import appeng.util.prioritylist.IPartitionList; import appeng.util.prioritylist.IPartitionList;
public class FluidRepo { public class FluidRepo {
@@ -27,7 +27,7 @@ import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.IMEFluidSlot; import appeng.fluids.container.slots.IMEFluidSlot;
public class SlotFluidME extends Slot implements IMEFluidSlot { public class SlotFluidME extends Slot implements IMEFluidSlot {
@@ -45,7 +45,7 @@ import net.minecraftforge.client.model.ItemLayerModel;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import appeng.items.misc.FluidDummyItem; import appeng.fluids.items.FluidDummyItem;
/** /**
* This baked model class is used as a dispatcher to redirect the renderer to * This baked model class is used as a dispatcher to redirect the renderer to
@@ -342,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);
@@ -353,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);
@@ -369,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,
@@ -386,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);
@@ -395,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,
@@ -417,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);
@@ -426,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,
@@ -449,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);
} }
@@ -485,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);
@@ -496,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);
} }
@@ -529,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);
@@ -538,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,6 +18,7 @@
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;
@@ -51,12 +52,21 @@ 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 {
// The number of quads overall that will be cached // The number of quads overall that will be cached
private static final int CACHE_QUAD_COUNT = 5000; 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 LoadingCache<CableBusRenderState, List<BakedQuad>> cableModelCache;
private final CableBuilder cableBuilder; private final CableBuilder cableBuilder;
@@ -74,6 +84,7 @@ public class CableBusBakedModel implements IBakedModel {
this.partModels = partModels; this.partModels = partModels;
this.particleTexture = particleTexture; this.particleTexture = particleTexture;
this.cableModelCache = CacheBuilder.newBuilder()// this.cableModelCache = CacheBuilder.newBuilder()//
.recordStats()//
.maximumWeight(CACHE_QUAD_COUNT)// .maximumWeight(CACHE_QUAD_COUNT)//
.weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (key, value) -> value.size())// .weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (key, value) -> value.size())//
.build(new CacheLoader<CableBusRenderState, List<BakedQuad>>() { .build(new CacheLoader<CableBusRenderState, List<BakedQuad>>() {
@@ -84,6 +95,7 @@ public class CableBusBakedModel implements IBakedModel {
return model; return model;
} }
}); });
cacheForMetrics = new WeakReference<>(cableModelCache);
} }
@Override @Override
@@ -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();
} }
@@ -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) {
@@ -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();
} }
@@ -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() {
+11
View File
@@ -404,6 +404,10 @@ public final class AEConfig {
return COMMON.improvedFluidMultiplier.get().floatValue(); 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 {
@@ -474,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;
@@ -558,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();
+28 -6
View File
@@ -34,13 +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.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;
@@ -67,6 +66,7 @@ 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.server.ServerHelper; import appeng.server.ServerHelper;
@@ -91,6 +91,8 @@ 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);
@@ -101,6 +103,7 @@ public final class AppEng {
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);
@@ -108,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);
@@ -129,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);
@@ -143,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)
@@ -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);
}
}
+13 -101
View File
@@ -22,7 +22,6 @@ 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;
@@ -33,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;
@@ -62,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;
@@ -100,12 +87,6 @@ import appeng.client.gui.implementations.CraftingCPUScreen;
import appeng.client.gui.implementations.CraftingStatusScreen; import appeng.client.gui.implementations.CraftingStatusScreen;
import appeng.client.gui.implementations.CraftingTermScreen; import appeng.client.gui.implementations.CraftingTermScreen;
import appeng.client.gui.implementations.DriveScreen; import appeng.client.gui.implementations.DriveScreen;
import appeng.client.gui.implementations.FluidFormationPlaneScreen;
import appeng.client.gui.implementations.FluidIOScreen;
import appeng.client.gui.implementations.FluidInterfaceScreen;
import appeng.client.gui.implementations.FluidLevelEmitterScreen;
import appeng.client.gui.implementations.FluidStorageBusScreen;
import appeng.client.gui.implementations.FluidTerminalScreen;
import appeng.client.gui.implementations.FormationPlaneScreen; import appeng.client.gui.implementations.FormationPlaneScreen;
import appeng.client.gui.implementations.GrinderScreen; import appeng.client.gui.implementations.GrinderScreen;
import appeng.client.gui.implementations.IOPortScreen; import appeng.client.gui.implementations.IOPortScreen;
@@ -165,12 +146,6 @@ import appeng.container.implementations.CraftingCPUContainer;
import appeng.container.implementations.CraftingStatusContainer; import appeng.container.implementations.CraftingStatusContainer;
import appeng.container.implementations.CraftingTermContainer; import appeng.container.implementations.CraftingTermContainer;
import appeng.container.implementations.DriveContainer; import appeng.container.implementations.DriveContainer;
import appeng.container.implementations.FluidFormationPlaneContainer;
import appeng.container.implementations.FluidIOContainer;
import appeng.container.implementations.FluidInterfaceContainer;
import appeng.container.implementations.FluidLevelEmitterContainer;
import appeng.container.implementations.FluidStorageBusContainer;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.container.implementations.FormationPlaneContainer; import appeng.container.implementations.FormationPlaneContainer;
import appeng.container.implementations.GrinderContainer; import appeng.container.implementations.GrinderContainer;
import appeng.container.implementations.IOPortContainer; import appeng.container.implementations.IOPortContainer;
@@ -198,12 +173,24 @@ import appeng.container.implementations.WirelessTermContainer;
import appeng.core.features.registries.P2PTunnelRegistry; import appeng.core.features.registries.P2PTunnelRegistry;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.core.features.registries.cell.BasicCellHandler; import appeng.core.features.registries.cell.BasicCellHandler;
import appeng.core.features.registries.cell.BasicFluidCellGuiHandler;
import appeng.core.features.registries.cell.BasicItemCellGuiHandler; import appeng.core.features.registries.cell.BasicItemCellGuiHandler;
import appeng.core.features.registries.cell.CreativeCellHandler; import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.stats.AdvancementTriggers; import appeng.core.stats.AdvancementTriggers;
import appeng.core.stats.AeStats; import appeng.core.stats.AeStats;
import appeng.fluids.client.gui.FluidFormationPlaneScreen;
import appeng.fluids.client.gui.FluidIOScreen;
import appeng.fluids.client.gui.FluidInterfaceScreen;
import appeng.fluids.client.gui.FluidLevelEmitterScreen;
import appeng.fluids.client.gui.FluidStorageBusScreen;
import appeng.fluids.client.gui.FluidTerminalScreen;
import appeng.fluids.container.FluidFormationPlaneContainer;
import appeng.fluids.container.FluidIOContainer;
import appeng.fluids.container.FluidInterfaceContainer;
import appeng.fluids.container.FluidLevelEmitterContainer;
import appeng.fluids.container.FluidStorageBusContainer;
import appeng.fluids.container.FluidTerminalContainer;
import appeng.fluids.registries.BasicFluidCellGuiHandler;
import appeng.items.parts.FacadeItem; import appeng.items.parts.FacadeItem;
import appeng.me.cache.CraftingGridCache; import appeng.me.cache.CraftingGridCache;
import appeng.me.cache.EnergyGridCache; import appeng.me.cache.EnergyGridCache;
@@ -213,22 +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.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.GrinderRecipeSerializer; import appeng.recipes.handlers.GrinderRecipeSerializer;
import appeng.recipes.handlers.InscriberRecipeSerializer; import appeng.recipes.handlers.InscriberRecipeSerializer;
import appeng.server.AECommand; import appeng.server.AECommand;
import appeng.spatial.SpatialStorageBiome;
import appeng.spatial.SpatialStorageChunkGenerator;
import appeng.spatial.SpatialStorageDimensionIds;
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;
import appeng.worldgen.meteorite.MeteoriteStructurePiece;
final class Registration { final class Registration {
@@ -682,73 +661,6 @@ final class Registration {
new ResourceLocation(dimension)); new ResourceLocation(dimension));
} }
MeteoriteStructurePiece.register();
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, SpatialStorageDimensionIds.CHUNK_GENERATOR_ID,
SpatialStorageChunkGenerator.CODEC);
}
public void registerBiomes(RegistryEvent.Register<Biome> evt) {
evt.getRegistry().register(SpatialStorageBiome.INSTANCE.setRegistryName(SpatialStorageDimensionIds.BIOME_ID));
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
@@ -47,10 +47,10 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.crafting.CraftingLink; import appeng.crafting.CraftingLink;
import appeng.items.misc.FluidDummyItem; import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.FluidList;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidStack;
import appeng.util.fluid.FluidList;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList; import appeng.util.item.ItemList;
@@ -22,6 +22,7 @@ import static appeng.block.AEBaseBlock.defaultProps;
import net.minecraft.block.AbstractBlock; 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;
@@ -51,7 +52,6 @@ import appeng.block.grindstone.GrinderBlock;
import appeng.block.misc.CellWorkbenchBlock; import appeng.block.misc.CellWorkbenchBlock;
import appeng.block.misc.ChargerBlock; import appeng.block.misc.ChargerBlock;
import appeng.block.misc.CondenserBlock; import appeng.block.misc.CondenserBlock;
import appeng.block.misc.FluidInterfaceBlock;
import appeng.block.misc.InscriberBlock; import appeng.block.misc.InscriberBlock;
import appeng.block.misc.InscriberRendering; import appeng.block.misc.InscriberRendering;
import appeng.block.misc.InterfaceBlock; import appeng.block.misc.InterfaceBlock;
@@ -123,6 +123,8 @@ import appeng.decorative.solid.QuartzPillarBlock;
import appeng.decorative.solid.SkyStoneBlock; import appeng.decorative.solid.SkyStoneBlock;
import appeng.decorative.solid.SkyStoneBlock.SkystoneType; import appeng.decorative.solid.SkyStoneBlock.SkystoneType;
import appeng.entity.TinyTNTPrimedEntity; import appeng.entity.TinyTNTPrimedEntity;
import appeng.fluids.block.FluidInterfaceBlock;
import appeng.fluids.tile.FluidInterfaceTileEntity;
import appeng.hooks.TinyTNTDispenseItemBehavior; import appeng.hooks.TinyTNTDispenseItemBehavior;
import appeng.tile.crafting.CraftingMonitorTileEntity; import appeng.tile.crafting.CraftingMonitorTileEntity;
import appeng.tile.crafting.CraftingStorageTileEntity; import appeng.tile.crafting.CraftingStorageTileEntity;
@@ -134,7 +136,6 @@ import appeng.tile.grindstone.GrinderTileEntity;
import appeng.tile.misc.CellWorkbenchTileEntity; import appeng.tile.misc.CellWorkbenchTileEntity;
import appeng.tile.misc.ChargerTileEntity; import appeng.tile.misc.ChargerTileEntity;
import appeng.tile.misc.CondenserTileEntity; import appeng.tile.misc.CondenserTileEntity;
import appeng.tile.misc.FluidInterfaceTileEntity;
import appeng.tile.misc.InscriberTileEntity; import appeng.tile.misc.InscriberTileEntity;
import appeng.tile.misc.InterfaceTileEntity; import appeng.tile.misc.InterfaceTileEntity;
import appeng.tile.misc.LightDetectorTileEntity; import appeng.tile.misc.LightDetectorTileEntity;
@@ -39,7 +39,6 @@ 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.bootstrap.components.IClientSetupComponent;
import appeng.client.render.FluidDummyItemColor;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.ActivityState; import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition; import appeng.core.features.ColoredItemDefinition;
@@ -50,17 +49,18 @@ import appeng.debug.EraserItem;
import appeng.debug.MeteoritePlacerItem; import appeng.debug.MeteoritePlacerItem;
import appeng.debug.ReplicatorCardItem; import appeng.debug.ReplicatorCardItem;
import appeng.entity.GrowingCrystalEntity; import appeng.entity.GrowingCrystalEntity;
import appeng.fluids.items.BasicFluidStorageCell;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.items.FluidDummyItemColor;
import appeng.hooks.BlockToolDispenseItemBehavior; 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.CrystalSeedRendering;
import appeng.items.misc.EncodedPatternItem; import appeng.items.misc.EncodedPatternItem;
import appeng.items.misc.FluidDummyItem;
import appeng.items.misc.PaintBallItem; import appeng.items.misc.PaintBallItem;
import appeng.items.misc.PaintBallItemRendering; import appeng.items.misc.PaintBallItemRendering;
import appeng.items.parts.FacadeItem; import appeng.items.parts.FacadeItem;
import appeng.items.storage.BasicFluidStorageCell;
import appeng.items.storage.BasicStorageCellItem; import appeng.items.storage.BasicStorageCellItem;
import appeng.items.storage.CreativeStorageCellItem; import appeng.items.storage.CreativeStorageCellItem;
import appeng.items.storage.SpatialStorageCellItem; import appeng.items.storage.SpatialStorageCellItem;
@@ -312,7 +312,7 @@ public final class ApiItems implements IItems {
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)
@@ -33,24 +33,25 @@ 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;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.fluids.parts.FluidAnnihilationPlanePart;
import appeng.fluids.parts.FluidExportBusPart;
import appeng.fluids.parts.FluidFormationPlanePart;
import appeng.fluids.parts.FluidImportBusPart;
import appeng.fluids.parts.FluidInterfacePart;
import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.parts.FluidTerminalPart;
import appeng.items.parts.ColoredPartItem; import appeng.items.parts.ColoredPartItem;
import appeng.items.parts.PartItem; import appeng.items.parts.PartItem;
import appeng.items.parts.PartItemRendering; import appeng.items.parts.PartItemRendering;
import appeng.items.parts.PartModelsHelper; import appeng.items.parts.PartModelsHelper;
import appeng.parts.automation.AnnihilationPlanePart; import appeng.parts.automation.AnnihilationPlanePart;
import appeng.parts.automation.ExportBusPart; import appeng.parts.automation.ExportBusPart;
import appeng.parts.automation.FluidAnnihilationPlanePart;
import appeng.parts.automation.FluidExportBusPart;
import appeng.parts.automation.FluidFormationPlanePart;
import appeng.parts.automation.FluidImportBusPart;
import appeng.parts.automation.FluidLevelEmitterPart;
import appeng.parts.automation.FormationPlanePart; import appeng.parts.automation.FormationPlanePart;
import appeng.parts.automation.IdentityAnnihilationPlanePart; import appeng.parts.automation.IdentityAnnihilationPlanePart;
import appeng.parts.automation.ImportBusPart; import appeng.parts.automation.ImportBusPart;
import appeng.parts.automation.LevelEmitterPart; import appeng.parts.automation.LevelEmitterPart;
import appeng.parts.misc.CableAnchorPart; import appeng.parts.misc.CableAnchorPart;
import appeng.parts.misc.FluidInterfacePart;
import appeng.parts.misc.FluidStorageBusPart;
import appeng.parts.misc.InterfacePart; import appeng.parts.misc.InterfacePart;
import appeng.parts.misc.InvertedToggleBusPart; import appeng.parts.misc.InvertedToggleBusPart;
import appeng.parts.misc.StorageBusPart; import appeng.parts.misc.StorageBusPart;
@@ -70,7 +71,6 @@ import appeng.parts.p2p.RedstoneP2PTunnelPart;
import appeng.parts.reporting.ConversionMonitorPart; import appeng.parts.reporting.ConversionMonitorPart;
import appeng.parts.reporting.CraftingTerminalPart; import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.DarkPanelPart; import appeng.parts.reporting.DarkPanelPart;
import appeng.parts.reporting.FluidTerminalPart;
import appeng.parts.reporting.InterfaceTerminalPart; import appeng.parts.reporting.InterfaceTerminalPart;
import appeng.parts.reporting.PanelPart; import appeng.parts.reporting.PanelPart;
import appeng.parts.reporting.PatternTerminalPart; import appeng.parts.reporting.PatternTerminalPart;
@@ -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
@@ -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);
} }
@@ -38,8 +38,6 @@ import appeng.container.implementations.CellWorkbenchContainer;
import appeng.container.implementations.CraftConfirmContainer; import appeng.container.implementations.CraftConfirmContainer;
import appeng.container.implementations.CraftingCPUContainer; import appeng.container.implementations.CraftingCPUContainer;
import appeng.container.implementations.CraftingStatusContainer; import appeng.container.implementations.CraftingStatusContainer;
import appeng.container.implementations.FluidLevelEmitterContainer;
import appeng.container.implementations.FluidStorageBusContainer;
import appeng.container.implementations.LevelEmitterContainer; import appeng.container.implementations.LevelEmitterContainer;
import appeng.container.implementations.NetworkToolContainer; import appeng.container.implementations.NetworkToolContainer;
import appeng.container.implementations.PatternTermContainer; import appeng.container.implementations.PatternTermContainer;
@@ -49,6 +47,8 @@ import appeng.container.implementations.SecurityStationContainer;
import appeng.container.implementations.StorageBusContainer; import appeng.container.implementations.StorageBusContainer;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.fluids.container.FluidLevelEmitterContainer;
import appeng.fluids.container.FluidStorageBusContainer;
import appeng.helpers.IMouseWheelItem; import appeng.helpers.IMouseWheelItem;
public class ConfigValuePacket extends BasePacket { public class ConfigValuePacket extends BasePacket {
@@ -29,10 +29,10 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.container.interfaces.IFluidSyncContainer;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.util.fluid.AEFluidStack; import appeng.fluids.container.IFluidSyncContainer;
import appeng.fluids.util.AEFluidStack;
public class FluidSlotPacket extends BasePacket { public class FluidSlotPacket extends BasePacket {
private final Map<Integer, IAEFluidStack> list; private final Map<Integer, IAEFluidStack> list;
@@ -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);
}
}
} }
} }
@@ -37,10 +37,10 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkDirection; import net.minecraftforge.fml.network.NetworkDirection;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.FluidTerminalScreen;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.util.fluid.AEFluidStack; import appeng.fluids.client.gui.FluidTerminalScreen;
import appeng.fluids.util.AEFluidStack;
/** /**
* @author BrockWS * @author BrockWS
@@ -19,11 +19,9 @@
package appeng.core.sync.packets; package appeng.core.sync.packets;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.GZIPOutputStream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -23,11 +23,11 @@ import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.util.fluid.AEFluidStack; import appeng.fluids.container.FluidTerminalContainer;
import appeng.fluids.util.AEFluidStack;
/** /**
* @author BrockWS * @author BrockWS
@@ -157,4 +157,8 @@ final class StorageData extends WorldSavedData implements IWorldGridStorageData
return tag; return tag;
} }
public int size() {
return storage.size();
}
} }
@@ -28,12 +28,13 @@ import com.google.common.base.Preconditions;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import appeng.metrics.Metrics;
import appeng.services.CompassService; import appeng.services.CompassService;
import appeng.services.compass.CompassThreadFactory; import appeng.services.compass.CompassThreadFactory;
/** /**
* Singleton access to anything related to world-based data. * Singleton access to anything related to world-based data.
* * <p>
* Data will change depending which world is loaded. Will probably not affect * Data will change depending which world is loaded. Will probably not affect
* SMP at all since only one world is loaded, but SSP more, cause they play on * SMP at all since only one world is loaded, but SSP more, cause they play on
* different worlds. * different worlds.
@@ -53,8 +54,15 @@ public final class WorldData implements IWorldData {
@Nullable @Nullable
private static MinecraftServer server; private static MinecraftServer server;
static {
Metrics.gauge("grid_storage_count", () -> {
WorldData worldData = (WorldData) instance;
return worldData != null ? worldData.storageData.size() : 0;
});
}
private final IWorldPlayerData playerData; private final IWorldPlayerData playerData;
private final IWorldGridStorageData storageData; private final StorageData storageData;
private final IWorldCompassData compassData; private final IWorldCompassData compassData;
private WorldData(@Nonnull final ServerWorld overworld) { private WorldData(@Nonnull final ServerWorld overworld) {
@@ -80,7 +88,6 @@ public final class WorldData implements IWorldData {
/** /**
* @return ae2 data related to a specific world * @return ae2 data related to a specific world
*
* @deprecated do not use singletons which are dependent on specific world state * @deprecated do not use singletons which are dependent on specific world state
*/ */
@Deprecated @Deprecated
@@ -102,7 +109,7 @@ public final class WorldData implements IWorldData {
/** /**
* Requires to start up from external from here * Requires to start up from external from here
* * <p>
* drawback of the singleton build style * drawback of the singleton build style
*/ */
public static void onServerStarting(MinecraftServer server) { public static void onServerStarting(MinecraftServer server) {
@@ -28,6 +28,7 @@ import net.minecraft.loot.RandomValueRange;
import net.minecraft.loot.conditions.SurvivesExplosion; import net.minecraft.loot.conditions.SurvivesExplosion;
import net.minecraft.loot.functions.ApplyBonus; import net.minecraft.loot.functions.ApplyBonus;
import net.minecraft.loot.functions.SetCount; import net.minecraft.loot.functions.SetCount;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
@@ -62,12 +63,13 @@ public class BlockDropProvider extends BlockLootTables implements IAE2DataProvid
@Override @Override
public void act(@Nonnull DirectoryCache cache) throws IOException { public void act(@Nonnull DirectoryCache cache) throws IOException {
for (Map.Entry<ResourceLocation, Block> entry : ForgeRegistries.BLOCKS.getEntries()) { for (Map.Entry<RegistryKey<Block>, Block> entry : ForgeRegistries.BLOCKS.getEntries()) {
LootTable.Builder builder; LootTable.Builder builder;
if (entry.getKey().getNamespace().equals(AppEng.MOD_ID)) { if (entry.getKey().func_240901_a_().getNamespace().equals(AppEng.MOD_ID)) {
builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue()); builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue());
IDataProvider.save(GSON, cache, toJson(builder), getPath(outputFolder, entry.getKey())); IDataProvider.save(GSON, cache, toJson(builder),
getPath(outputFolder, entry.getKey().func_240901_a_()));
} }
} }
} }
@@ -129,7 +129,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
// is a debug tool, we'll not care about being terribly efficient here // is a debug tool, we'll not care about being terribly efficient here
ChunkPos.getAllInBox(new ChunkPos(spawned.getPos()), 1).forEach(cp -> { ChunkPos.getAllInBox(new ChunkPos(spawned.getPos()), 1).forEach(cp -> {
Chunk c = world.getChunk(cp.x, cp.z); Chunk c = world.getChunk(cp.x, cp.z);
player.connection.sendPacket(new SChunkDataPacket(c, 65535, false)); // 65535 == full chunk player.connection.sendPacket(new SChunkDataPacket(c, 65535)); // 65535 == full chunk
}); });
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
@@ -40,7 +40,6 @@ import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.Explosion.Mode;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.block.misc; package appeng.fluids.block;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -33,8 +33,8 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidInterfaceContainer; import appeng.fluids.container.FluidInterfaceContainer;
import appeng.tile.misc.FluidInterfaceTileEntity; import appeng.fluids.tile.FluidInterfaceTileEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class FluidInterfaceBlock extends AEBaseTileBlock<FluidInterfaceTileEntity> { public class FluidInterfaceBlock extends AEBaseTileBlock<FluidInterfaceTileEntity> {
@@ -1,19 +1,19 @@
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import appeng.client.gui.implementations.UpgradeableScreen; import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.client.gui.widgets.TabButton; import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidFormationPlaneContainer;
import appeng.container.implementations.PriorityContainer; import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket; import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.client.gui.widgets.FluidSlotWidget;
import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.fluids.container.FluidFormationPlaneContainer;
import appeng.fluids.util.IAEFluidTank;
public class FluidFormationPlaneScreen extends UpgradeableScreen<FluidFormationPlaneContainer> { public class FluidFormationPlaneScreen extends UpgradeableScreen<FluidFormationPlaneContainer> {
public FluidFormationPlaneScreen(FluidFormationPlaneContainer container, PlayerInventory playerInventory, public FluidFormationPlaneScreen(FluidFormationPlaneContainer container, PlayerInventory playerInventory,
@@ -16,18 +16,18 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import appeng.client.gui.implementations.UpgradeableScreen; import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.container.implementations.FluidIOContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.parts.automation.FluidImportBusPart; import appeng.fluids.client.gui.widgets.FluidSlotWidget;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.fluids.container.FluidIOContainer;
import appeng.fluids.parts.FluidImportBusPart;
import appeng.fluids.util.IAEFluidTank;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@@ -25,16 +25,16 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.implementations.UpgradeableScreen; import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.FluidTankWidget;
import appeng.client.gui.widgets.TabButton; import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidInterfaceContainer;
import appeng.container.implementations.PriorityContainer; import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket; import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.DualityFluidInterface; import appeng.fluids.client.gui.widgets.FluidSlotWidget;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.client.gui.widgets.FluidTankWidget;
import appeng.fluids.container.FluidInterfaceContainer;
import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.util.IAEFluidTank;
public class FluidInterfaceScreen extends UpgradeableScreen<FluidInterfaceContainer> { public class FluidInterfaceScreen extends UpgradeableScreen<FluidInterfaceContainer> {
public FluidInterfaceScreen(FluidInterfaceContainer container, PlayerInventory playerInventory, public FluidInterfaceScreen(FluidInterfaceContainer container, PlayerInventory playerInventory,
@@ -1,5 +1,5 @@
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@@ -11,12 +11,12 @@ import appeng.api.config.Settings;
import appeng.client.gui.NumberEntryType; import appeng.client.gui.NumberEntryType;
import appeng.client.gui.implementations.NumberEntryWidget; import appeng.client.gui.implementations.NumberEntryWidget;
import appeng.client.gui.implementations.UpgradeableScreen; import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.ServerSettingToggleButton; import appeng.client.gui.widgets.ServerSettingToggleButton;
import appeng.container.implementations.FluidLevelEmitterContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
import appeng.fluids.container.FluidLevelEmitterContainer;
public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitterContainer> { public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitterContainer> {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@@ -30,18 +30,18 @@ import appeng.api.config.Settings;
import appeng.api.config.StorageFilter; import appeng.api.config.StorageFilter;
import appeng.client.gui.implementations.UpgradeableScreen; import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.ActionButton; import appeng.client.gui.widgets.ActionButton;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.client.gui.widgets.ServerSettingToggleButton; import appeng.client.gui.widgets.ServerSettingToggleButton;
import appeng.client.gui.widgets.SettingToggleButton; import appeng.client.gui.widgets.SettingToggleButton;
import appeng.client.gui.widgets.TabButton; import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidStorageBusContainer;
import appeng.container.implementations.PriorityContainer; import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.SwitchGuisPacket; import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.client.gui.widgets.FluidSlotWidget;
import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.fluids.container.FluidStorageBusContainer;
import appeng.fluids.util.IAEFluidTank;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.gui.implementations; package appeng.fluids.client.gui;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
@@ -51,14 +51,14 @@ import appeng.client.gui.widgets.SettingToggleButton;
import appeng.client.me.FluidRepo; import appeng.client.me.FluidRepo;
import appeng.client.me.InternalFluidSlotME; import appeng.client.me.InternalFluidSlotME;
import appeng.client.me.SlotFluidME; import appeng.client.me.SlotFluidME;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.container.slot.IMEFluidSlot;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.InventoryActionPacket; import appeng.core.sync.packets.InventoryActionPacket;
import appeng.fluids.container.FluidTerminalContainer;
import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
@@ -176,7 +176,7 @@ public class FluidTerminalScreen extends AEBaseMEScreen<FluidTerminalContainer>
list.add(new StringTextComponent(formattedAmount)); list.add(new StringTextComponent(formattedAmount));
list.add(new StringTextComponent(modName)); list.add(new StringTextComponent(modName));
this.renderTooltip(matrixStack, list, mouseX, mouseY); this.func_243308_b(matrixStack, list, mouseX, mouseY);
return; return;
} }
@@ -1,6 +1,7 @@
package appeng.client.gui.widgets; package appeng.fluids.client.gui.widgets;
import java.util.Collections; import java.util.Collections;
import java.util.Optional;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
@@ -14,7 +15,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
@@ -24,8 +24,8 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.CustomSlotWidget; import appeng.client.gui.widgets.CustomSlotWidget;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.FluidSlotPacket; import appeng.core.sync.packets.FluidSlotPacket;
import appeng.util.fluid.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
public class FluidSlotWidget extends CustomSlotWidget { public class FluidSlotWidget extends CustomSlotWidget {
private final IAEFluidTank fluids; private final IAEFluidTank fluids;
@@ -73,7 +73,7 @@ public class FluidSlotWidget extends CustomSlotWidget {
if (clickStack.isEmpty() || mouseButton == 1) { if (clickStack.isEmpty() || mouseButton == 1) {
this.setFluidStack(null); this.setFluidStack(null);
} else if (mouseButton == 0) { } else if (mouseButton == 0) {
final LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained(clickStack); final Optional<FluidStack> fluidOpt = FluidUtil.getFluidContained(clickStack);
fluidOpt.ifPresent(fluid -> { fluidOpt.ifPresent(fluid -> {
this.setFluidStack(AEFluidStack.fromFluidStack(fluid)); this.setFluidStack(AEFluidStack.fromFluidStack(fluid));
}); });
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.gui.widgets; package appeng.fluids.client.gui.widgets;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
@@ -35,7 +35,7 @@ import net.minecraftforge.fluids.FluidAttributes;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.client.gui.widgets.ITooltip; import appeng.client.gui.widgets.ITooltip;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class FluidTankWidget extends Widget implements ITooltip { public class FluidTankWidget extends Widget implements ITooltip {
@@ -1,5 +1,5 @@
package appeng.client.gui.widgets; package appeng.fluids.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
@@ -7,7 +7,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.IOptionalSlotHost; import appeng.container.slot.IOptionalSlotHost;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
public class OptionalFluidSlotWidget extends FluidSlotWidget { public class OptionalFluidSlotWidget extends FluidSlotWidget {
private final IOptionalSlotHost containerBus; private final IOptionalSlotHost containerBus;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.client.render; package appeng.fluids.client.render;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@@ -1,26 +1,25 @@
package appeng.container.implementations; package appeng.fluids.container;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener; import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.container.guisync.FluidSyncHelper;
import appeng.container.implementations.UpgradeableContainer; import appeng.container.implementations.UpgradeableContainer;
import appeng.container.interfaces.IFluidSyncContainer; import appeng.fluids.helper.FluidSyncHelper;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidStack;
import appeng.util.fluid.IAEFluidTank;
public abstract class FluidConfigurableContainer extends UpgradeableContainer implements IFluidSyncContainer { public abstract class FluidConfigurableContainer extends UpgradeableContainer implements IFluidSyncContainer {
private FluidSyncHelper sync = null; private FluidSyncHelper sync = null;
@@ -40,7 +39,7 @@ public abstract class FluidConfigurableContainer extends UpgradeableContainer im
@Override @Override
protected ItemStack transferStackToContainer(ItemStack input) { protected ItemStack transferStackToContainer(ItemStack input) {
LazyOptional<FluidStack> fsOpt = FluidUtil.getFluidContained(input); Optional<FluidStack> fsOpt = FluidUtil.getFluidContained(input);
if (fsOpt.isPresent()) { if (fsOpt.isPresent()) {
final IAEFluidTank t = this.getFluidConfigInventory(); final IAEFluidTank t = this.getFluidConfigInventory();
final IAEFluidStack stack = AEFluidStack.fromFluidStack(fsOpt.orElse(null)); final IAEFluidStack stack = AEFluidStack.fromFluidStack(fsOpt.orElse(null));
@@ -1,5 +1,5 @@
package appeng.container.implementations; package appeng.fluids.container;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@@ -11,9 +11,10 @@ import appeng.api.config.SecurityPermissions;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.implementations.ContainerHelper;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.parts.automation.FluidFormationPlanePart; import appeng.fluids.parts.FluidFormationPlanePart;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
public class FluidFormationPlaneContainer extends FluidConfigurableContainer { public class FluidFormationPlaneContainer extends FluidConfigurableContainer {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.container.implementations; package appeng.fluids.container;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@@ -25,8 +25,9 @@ import net.minecraft.network.PacketBuffer;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.parts.automation.SharedFluidBusPart; import appeng.container.implementations.ContainerHelper;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.parts.SharedFluidBusPart;
import appeng.fluids.util.IAEFluidTank;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.container.implementations; package appeng.fluids.container;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@@ -31,11 +31,12 @@ import appeng.api.config.SecurityPermissions;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.FluidSyncHelper; import appeng.container.implementations.ContainerHelper;
import appeng.helpers.DualityFluidInterface; import appeng.fluids.helper.DualityFluidInterface;
import appeng.helpers.IFluidInterfaceHost; import appeng.fluids.helper.FluidSyncHelper;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.IAEFluidTank;
public class FluidInterfaceContainer extends FluidConfigurableContainer { public class FluidInterfaceContainer extends FluidConfigurableContainer {
@@ -1,4 +1,4 @@
package appeng.container.implementations; package appeng.fluids.container;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@@ -13,9 +13,10 @@ import appeng.api.config.Settings;
import appeng.client.gui.implementations.NumberEntryWidget; import appeng.client.gui.implementations.NumberEntryWidget;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.parts.automation.FluidLevelEmitterPart; import appeng.container.implementations.ContainerHelper;
import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.IAEFluidTank;
public class FluidLevelEmitterContainer extends FluidConfigurableContainer { public class FluidLevelEmitterContainer extends FluidConfigurableContainer {
public static ContainerType<FluidLevelEmitterContainer> TYPE; public static ContainerType<FluidLevelEmitterContainer> TYPE;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.container.implementations; package appeng.fluids.container;
import java.util.Iterator; import java.util.Iterator;
@@ -38,11 +38,12 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api; import appeng.core.Api;
import appeng.parts.misc.FluidStorageBusPart; import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.IAEFluidTank;
import appeng.util.iterators.NullIterator; import appeng.util.iterators.NullIterator;
/** /**
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.container.implementations; package appeng.fluids.container;
import java.io.IOException; import java.io.IOException;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
@@ -63,18 +63,19 @@ import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket; import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
import appeng.core.sync.packets.TargetFluidStackPacket; import appeng.core.sync.packets.TargetFluidStackPacket;
import appeng.fluids.util.AEFluidStack;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.me.helpers.ChannelPowerSrc; import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidStack;
/** /**
* @author BrockWS * @author BrockWS
@@ -1,5 +1,5 @@
package appeng.container.interfaces; package appeng.fluids.container;
import java.util.Map; import java.util.Map;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.container.slot; package appeng.fluids.container.slots;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.helpers; package appeng.fluids.helper;
import java.util.Optional; import java.util.Optional;
@@ -59,6 +59,9 @@ import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities; import appeng.capabilities.Capabilities;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
@@ -68,9 +71,6 @@ import appeng.me.storage.NullInventory;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidInventory;
import appeng.util.fluid.IAEFluidInventory;
import appeng.util.fluid.IAEFluidTank;
public class DualityFluidInterface public class DualityFluidInterface
implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost { implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost {
@@ -16,19 +16,20 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.items.contents; package appeng.fluids.helper;
import java.util.Optional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.items.FluidDummyItem;
import appeng.items.contents.CellConfig; import appeng.items.contents.CellConfig;
import appeng.items.misc.FluidDummyItem;
/** /**
* @author DrummerMC * @author DrummerMC
@@ -46,7 +47,7 @@ public class FluidCellConfig extends CellConfig {
if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) {
super.insertItem(slot, stack, simulate); super.insertItem(slot, stack, simulate);
} }
LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack); Optional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack);
if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) {
return stack; return stack;
} }
@@ -64,7 +65,7 @@ public class FluidCellConfig extends CellConfig {
if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) {
super.setStackInSlot(slot, stack); super.setStackInSlot(slot, stack);
} }
LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack); Optional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack);
if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) {
return; return;
} }
@@ -82,7 +83,7 @@ public class FluidCellConfig extends CellConfig {
if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) { if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) {
super.isItemValid(slot, stack); super.isItemValid(slot, stack);
} }
LazyOptional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack); Optional<FluidStack> fluidOpt = FluidUtil.getFluidContained(stack);
if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) { if (!fluidOpt.isPresent() || !Api.instance().definitions().items().dummyFluidItem().maybeStack(1).isPresent()) {
return false; return false;
} }
@@ -1,5 +1,5 @@
package appeng.container.guisync; package appeng.fluids.helper;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -11,8 +11,8 @@ import net.minecraft.inventory.container.IContainerListener;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.FluidSlotPacket; import appeng.core.sync.packets.FluidSlotPacket;
import appeng.util.fluid.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
import appeng.util.fluid.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
public class FluidSyncHelper { public class FluidSyncHelper {
private final IAEFluidTank inv; private final IAEFluidTank inv;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.helpers; package appeng.fluids.helper;
import java.util.EnumSet; import java.util.EnumSet;
@@ -25,7 +25,6 @@ import net.minecraft.util.Direction;
import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionHost;
import appeng.helpers.DualityFluidInterface;
import appeng.me.helpers.IGridProxyable; import appeng.me.helpers.IGridProxyable;
public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgradeableHost { public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgradeableHost {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.items.storage; package appeng.fluids.items;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -26,8 +26,9 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.Api; import appeng.core.Api;
import appeng.items.contents.FluidCellConfig; import appeng.fluids.helper.FluidCellConfig;
import appeng.items.materials.MaterialType; import appeng.items.materials.MaterialType;
import appeng.items.storage.AbstractStorageCell;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
/** /**
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.items.misc; package appeng.fluids.items;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
@@ -1,4 +1,4 @@
package appeng.client.render; package appeng.fluids.items;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@@ -7,8 +7,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import appeng.items.misc.FluidDummyItem;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class FluidDummyItemColor implements IItemColor { public class FluidDummyItemColor implements IItemColor {
@@ -1,5 +1,5 @@
package appeng.parts.automation; package appeng.fluids.parts;
import java.util.List; import java.util.List;
@@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ITag; import net.minecraft.tags.ITag;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -44,17 +43,21 @@ import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.core.sync.packets.BlockTransitionEffectPacket; import appeng.core.sync.packets.BlockTransitionEffectPacket;
import appeng.fluids.util.AEFluidStack;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
import appeng.parts.BasicStatePart; import appeng.parts.BasicStatePart;
import appeng.parts.automation.PlaneConnectionHelper;
import appeng.parts.automation.PlaneConnections;
import appeng.parts.automation.PlaneModelData;
import appeng.parts.automation.PlaneModels;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidStack;
public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridTickable { public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridTickable {
public static final ResourceLocation TAG_BLACKLIST = new ResourceLocation(AppEng.MOD_ID, public static final ITag.INamedTag<Fluid> TAG_BLACKLIST = FluidTags
"blacklisted/fluid_annihilation_plane"); .makeWrapperTag(AppEng.makeId("blacklisted/fluid_annihilation_plane").toString());
private static final PlaneModels MODELS = new PlaneModels("part/fluid_annihilation_plane", private static final PlaneModels MODELS = new PlaneModels("part/fluid_annihilation_plane",
"part/fluid_annihilation_plane_on"); "part/fluid_annihilation_plane_on");
@@ -210,8 +213,7 @@ public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridT
} }
private boolean isFluidBlacklisted(Fluid fluid) { private boolean isFluidBlacklisted(Fluid fluid) {
ITag<Fluid> tag = FluidTags.getCollection().getOrCreate(TAG_BLACKLIST); return TAG_BLACKLIST.contains(fluid);
return fluid.isIn(tag);
} }
} }
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.automation; package appeng.fluids.parts;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -1,5 +1,5 @@
package appeng.parts.automation; package appeng.fluids.parts;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -45,15 +45,18 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidFormationPlaneContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.container.FluidFormationPlaneContainer;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.storage.MEInventoryHandler; import appeng.me.storage.MEInventoryHandler;
import appeng.parts.automation.AbstractFormationPlanePart;
import appeng.parts.automation.PlaneModelData;
import appeng.parts.automation.PlaneModels;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidInventory;
import appeng.util.fluid.IAEFluidInventory;
import appeng.util.fluid.IAEFluidTank;
import appeng.util.prioritylist.PrecisePriorityList; import appeng.util.prioritylist.PrecisePriorityList;
public class FluidFormationPlanePart extends AbstractFormationPlanePart<IAEFluidStack> implements IAEFluidInventory { public class FluidFormationPlanePart extends AbstractFormationPlanePart<IAEFluidStack> implements IAEFluidInventory {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.misc; package appeng.fluids.parts;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -39,10 +39,10 @@ import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.util.AEFluidStack;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.IGridProxyable; import appeng.me.helpers.IGridProxyable;
import appeng.me.storage.ITickingMonitor; import appeng.me.storage.ITickingMonitor;
import appeng.util.fluid.AEFluidStack;
/** /**
* Wraps an Fluid Handler in such a way that it can be used as an IMEInventory * Wraps an Fluid Handler in such a way that it can be used as an IMEInventory
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.automation; package appeng.fluids.parts;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -44,11 +44,11 @@ import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidStack;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
import appeng.parts.PartModel; import appeng.parts.PartModel;
import appeng.util.fluid.AEFluidStack;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.misc; package appeng.fluids.parts;
import java.util.EnumSet; import java.util.EnumSet;
@@ -51,11 +51,11 @@ import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidInterfaceContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.helpers.DualityFluidInterface; import appeng.fluids.container.FluidInterfaceContainer;
import appeng.helpers.IFluidInterfaceHost; import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected; import appeng.helpers.Reflected;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
@@ -1,5 +1,5 @@
package appeng.parts.automation; package appeng.fluids.parts;
import java.util.Random; import java.util.Random;
@@ -37,17 +37,18 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidLevelEmitterContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.fluids.container.FluidLevelEmitterContainer;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.parts.PartModel; import appeng.parts.PartModel;
import appeng.parts.automation.UpgradeablePart;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidInventory;
import appeng.util.fluid.IAEFluidInventory;
import appeng.util.fluid.IAEFluidTank;
public class FluidLevelEmitterPart extends UpgradeablePart public class FluidLevelEmitterPart extends UpgradeablePart
implements IStackWatcherHost, IConfigManagerHost, IAEFluidInventory, IMEMonitorHandlerReceiver<IAEFluidStack> { implements IStackWatcherHost, IConfigManagerHost, IAEFluidInventory, IMEMonitorHandlerReceiver<IAEFluidStack> {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.misc; package appeng.fluids.parts;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -65,10 +65,13 @@ import appeng.api.util.AEPartLocation;
import appeng.capabilities.Capabilities; import appeng.capabilities.Capabilities;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidStorageBusContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.fluids.container.FluidStorageBusContainer;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.helpers.IInterfaceHost; import appeng.helpers.IInterfaceHost;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
@@ -76,10 +79,8 @@ import appeng.me.helpers.MachineSource;
import appeng.me.storage.ITickingMonitor; import appeng.me.storage.ITickingMonitor;
import appeng.me.storage.MEInventoryHandler; import appeng.me.storage.MEInventoryHandler;
import appeng.parts.PartModel; import appeng.parts.PartModel;
import appeng.parts.misc.SharedStorageBusPart;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidInventory;
import appeng.util.fluid.IAEFluidInventory;
import appeng.util.fluid.IAEFluidTank;
import appeng.util.prioritylist.FuzzyPriorityList; import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList; import appeng.util.prioritylist.PrecisePriorityList;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.reporting; package appeng.fluids.parts;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
@@ -24,10 +24,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.fluids.container.FluidTerminalContainer;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
import appeng.parts.PartModel; import appeng.parts.PartModel;
import appeng.parts.reporting.AbstractTerminalPart;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.parts.automation; package appeng.fluids.parts;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -39,12 +39,13 @@ import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidIOContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.container.FluidIOContainer;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.parts.automation.UpgradeablePart;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.fluid.AEFluidInventory;
import appeng.util.fluid.IAEFluidTank;
/** /**
* @author BrockWS * @author BrockWS
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.core.features.registries.cell; package appeng.fluids.registries;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -31,8 +31,8 @@ import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.container.FluidTerminalContainer;
public class BasicFluidCellGuiHandler implements ICellGuiHandler { public class BasicFluidCellGuiHandler implements ICellGuiHandler {
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.tile.misc; package appeng.fluids.tile;
import java.util.EnumSet; import java.util.EnumSet;
@@ -45,10 +45,10 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.implementations.FluidInterfaceContainer;
import appeng.core.Api; import appeng.core.Api;
import appeng.helpers.DualityFluidInterface; import appeng.fluids.container.FluidInterfaceContainer;
import appeng.helpers.IFluidInterfaceHost; import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
import appeng.tile.grid.AENetworkTileEntity; import appeng.tile.grid.AENetworkTileEntity;
@@ -1,5 +1,5 @@
package appeng.util.fluid; package appeng.fluids.util;
import java.util.Objects; import java.util.Objects;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -38,7 +38,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEFluidStack;
import appeng.core.Api; import appeng.core.Api;
import appeng.items.misc.FluidDummyItem; import appeng.fluids.items.FluidDummyItem;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEStack; import appeng.util.item.AEStack;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
import java.util.Comparator; import java.util.Comparator;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
@FunctionalInterface @FunctionalInterface
public interface IAEFluidInventory { public interface IAEFluidInventory {
@@ -1,5 +1,5 @@
package appeng.util.fluid; package appeng.fluids.util;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>. * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/ */
package appeng.util.fluid; package appeng.fluids.util;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -57,6 +57,7 @@ import appeng.core.AppEng;
import appeng.core.sync.packets.PaintedEntityPacket; import appeng.core.sync.packets.PaintedEntityPacket;
import appeng.crafting.CraftingJob; import appeng.crafting.CraftingJob;
import appeng.me.Grid; import appeng.me.Grid;
import appeng.metrics.Metrics;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseTileEntity;
import appeng.util.IWorldCallable; import appeng.util.IWorldCallable;
import appeng.util.Platform; import appeng.util.Platform;
@@ -77,6 +78,11 @@ public class TickHandler {
return INSTANCE; return INSTANCE;
} }
static {
Metrics.gauge("ticking_network_count", () -> INSTANCE.server.networks.size());
Metrics.gauge("crafting_job_count", INSTANCE.craftingJobs::size);
}
public static void setup(IEventBus eventBus) { public static void setup(IEventBus eventBus) {
eventBus.addListener(INSTANCE::onServerTick); eventBus.addListener(INSTANCE::onServerTick);
eventBus.addListener(INSTANCE::onWorldTick); eventBus.addListener(INSTANCE::onWorldTick);
@@ -18,6 +18,8 @@
package appeng.integration.abstraction; package appeng.integration.abstraction;
import mezz.jei.api.runtime.IJeiRuntime;
import appeng.integration.IIntegrationModule; import appeng.integration.IIntegrationModule;
/** /**
@@ -25,6 +27,10 @@ import appeng.integration.IIntegrationModule;
*/ */
public interface IJEI extends IIntegrationModule { public interface IJEI extends IIntegrationModule {
default IJeiRuntime getRuntime() {
return null;
}
default String getSearchText() { default String getSearchText() {
return ""; return "";
} }
@@ -0,0 +1,47 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2020 Team Appliedenergistics, 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.integration.modules.jei;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.crafting.IRecipe;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper;
import appeng.container.implementations.CraftingTermContainer;
public class CraftingRecipeTransferHandler extends RecipeTransferHandler<CraftingTermContainer> {
CraftingRecipeTransferHandler(Class<CraftingTermContainer> containerClass, IRecipeTransferHandlerHelper helper) {
super(containerClass, helper);
}
@Override
protected IRecipeTransferError doTransferRecipe(CraftingTermContainer container, IRecipe<?> recipe,
IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer) {
return null;
}
@Override
protected boolean isCrafting() {
return true;
}
}
@@ -111,6 +111,8 @@ class FacadeRegistryPlugin implements IRecipeManagerPlugin {
ingredients.set(7, Ingredient.fromStacks(cableAnchor)); ingredients.set(7, Ingredient.fromStacks(cableAnchor));
ingredients.set(4, Ingredient.fromStacks(textureItem)); ingredients.set(4, Ingredient.fromStacks(textureItem));
result.setCount(4);
return new ShapedRecipe(id, "", 3, 3, ingredients, result); return new ShapedRecipe(id, "", 3, 3, ingredients, result);
} }
@@ -82,11 +82,15 @@ public class JEIPlugin implements IModPlugin {
@Override @Override
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) { public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
// Allow recipe transfer from JEI to crafting and pattern terminal
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(CraftingTermContainer.class), // Allow vanilla crafting recipe transfer from JEI to crafting terminal
VanillaRecipeCategoryUid.CRAFTING); registration.addRecipeTransferHandler(
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(PatternTermContainer.class), new CraftingRecipeTransferHandler(CraftingTermContainer.class, registration.getTransferHelper()),
VanillaRecipeCategoryUid.CRAFTING); VanillaRecipeCategoryUid.CRAFTING);
// Universal handler for processing to try and handle all IRecipe
registration.addUniversalRecipeTransferHandler(
new PatternRecipeTransferHandler(PatternTermContainer.class, registration.getTransferHelper()));
} }
@Override @Override
@@ -37,6 +37,10 @@ class JeiRuntimeAdapter implements IJEI {
return true; return true;
} }
public IJeiRuntime getRuntime() {
return runtime;
}
@Override @Override
public String getSearchText() { public String getSearchText() {
return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText()); return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText());
@@ -0,0 +1,58 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2020 Team Appliedenergistics, 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.integration.modules.jei;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.crafting.IRecipe;
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper;
import appeng.container.implementations.PatternTermContainer;
public class PatternRecipeTransferHandler extends RecipeTransferHandler<PatternTermContainer> {
PatternRecipeTransferHandler(Class<PatternTermContainer> containerClass, IRecipeTransferHandlerHelper helper) {
super(containerClass, helper);
}
protected IRecipeTransferError doTransferRecipe(PatternTermContainer container, IRecipe<?> recipe,
IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer) {
if (container.isCraftingMode()
&& recipeLayout.getRecipeCategory().getUid() != VanillaRecipeCategoryUid.CRAFTING) {
return this.helper
.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.requires_processing_mode"));
}
if (recipe.getRecipeOutput().isEmpty()) {
return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.no_output"));
}
return null;
}
@Override
protected boolean isCrafting() {
return false;
}
}
@@ -18,101 +18,128 @@
package appeng.integration.modules.jei; package appeng.integration.modules.jei;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
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.Ingredient;
import net.minecraft.item.crafting.ShapedRecipe;
import net.minecraft.item.crafting.ShapelessRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.ingredient.IGuiIngredient; import mezz.jei.api.gui.ingredient.IGuiIngredient;
import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper;
import appeng.container.slot.CraftingMatrixSlot;
import appeng.container.slot.FakeCraftingMatrixSlot;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.JEIRecipePacket; import appeng.core.sync.packets.JEIRecipePacket;
import appeng.util.Platform; import appeng.helpers.IContainerCraftingPacket;
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> { abstract class RecipeTransferHandler<T extends Container & IContainerCraftingPacket>
implements IRecipeTransferHandler<T> {
private final Class<T> containerClass; private final Class<T> containerClass;
protected final IRecipeTransferHandlerHelper helper;
RecipeTransferHandler(Class<T> containerClass) { RecipeTransferHandler(Class<T> containerClass, IRecipeTransferHandlerHelper helper) {
this.containerClass = containerClass; this.containerClass = containerClass;
this.helper = helper;
} }
@Override @Override
public Class<T> getContainerClass() { public final Class<T> getContainerClass() {
return this.containerClass; return this.containerClass;
} }
@Nullable
@Override @Override
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player, public final IRecipeTransferError transferRecipe(T container, Object recipe, IRecipeLayout recipeLayout,
boolean maxTransfer, boolean doTransfer) { PlayerEntity player, boolean maxTransfer, boolean doTransfer) {
if (!doTransfer) { if (!(recipe instanceof IRecipe)) {
return null; return this.helper.createInternalError();
}
final IRecipe<?> irecipe = (IRecipe<?>) recipe;
final ResourceLocation recipeId = irecipe.getId();
if (recipeId == null) {
return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.missing_id"));
} }
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks() // Check that the recipe can actually be looked up via the manager, i.e. our
.getGuiIngredients(); // facade recipes
// have an ID, but are never registered with the recipe manager.
final CompoundNBT recipe = new CompoundNBT(); boolean canSendReference = true;
if (!player.getEntityWorld().getRecipeManager().getRecipe(recipeId).isPresent()) {
int slotIndex = 0; // Validate that the recipe is a shapeless or shapedrecipe, since we can
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet()) { // serialize those
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue(); if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) {
if (!ingredient.isInput()) { return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.missing_id"));
continue;
} }
canSendReference = false;
}
for (final Slot slot : container.inventorySlots) { if (!irecipe.canFit(3, 3)) {
if (slot instanceof CraftingMatrixSlot || slot instanceof FakeCraftingMatrixSlot) { return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.recipe_too_large"));
if (slot.getSlotIndex() == slotIndex) { }
final ListNBT tags = new ListNBT();
final List<ItemStack> list = new ArrayList<>();
final ItemStack displayed = ingredient.getDisplayedIngredient();
// prefer currently displayed item final IRecipeTransferError error = doTransferRecipe(container, irecipe, recipeLayout, player, maxTransfer);
if (displayed != null && !displayed.isEmpty()) {
list.add(displayed); if (error != null) {
return error;
}
if (doTransfer) {
if (canSendReference) {
NetworkHandler.instance().sendToServer(new JEIRecipePacket(recipeId, isCrafting()));
} else {
// To avoid earlier problems of too large packets being sent that crashed the
// client,
// as a fallback when the recipe ID could not be resolved, we'll just send the
// displayed
// items.
NonNullList<Ingredient> flatIngredients = NonNullList.withSize(9, Ingredient.EMPTY);
ItemStack output = ItemStack.EMPTY;
// Determine the first JEI slot that has an actual input, we'll use this to
// offset the
// crafting grid target slot
int firstInputSlot = recipeLayout.getItemStacks().getGuiIngredients().entrySet().stream()
.filter(e -> e.getValue().isInput()).mapToInt(Map.Entry::getKey).min().orElse(0);
// Now map the actual ingredients into the output/input
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> entry : recipeLayout.getItemStacks()
.getGuiIngredients().entrySet()) {
IGuiIngredient<ItemStack> item = entry.getValue();
if (item.getDisplayedIngredient() == null) {
continue;
}
int inputIndex = entry.getKey() - firstInputSlot;
if (item.isInput() && inputIndex < flatIngredients.size()) {
ItemStack displayedIngredient = item.getDisplayedIngredient();
if (displayedIngredient != null) {
flatIngredients.set(inputIndex, Ingredient.fromStacks(displayedIngredient));
} }
} else if (!item.isInput() && output.isEmpty()) {
// prefer pure crystals. output = item.getDisplayedIngredient();
for (ItemStack stack : ingredient.getAllIngredients()) {
if (Platform.isRecipePrioritized(stack)) {
list.add(0, stack);
} else {
list.add(stack);
}
}
for (final ItemStack is : list) {
final CompoundNBT tag = new CompoundNBT();
is.write(tag);
tags.add(tag);
}
recipe.put("#" + slot.getSlotIndex(), tags);
break;
} }
} }
ShapedRecipe fallbackRecipe = new ShapedRecipe(recipeId, "", 3, 3, flatIngredients, output);
NetworkHandler.instance().sendToServer(new JEIRecipePacket(fallbackRecipe, isCrafting()));
} }
slotIndex++;
} }
NetworkHandler.instance().sendToServer(new JEIRecipePacket(recipe));
return null; return null;
} }
protected abstract IRecipeTransferError doTransferRecipe(T container, IRecipe<?> recipe, IRecipeLayout recipeLayout,
PlayerEntity player, boolean maxTransfer);
protected abstract boolean isCrafting();
} }
@@ -58,7 +58,8 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
/** /**
* Block tag used to explicitly whitelist blocks for use in facades. * Block tag used to explicitly whitelist blocks for use in facades.
*/ */
private static final ResourceLocation TAG_WHITELISTED = new ResourceLocation(AppEng.MOD_ID, "whitelisted/facades"); private static final ITag.INamedTag<Block> BLOCK_WHITELIST = BlockTags
.makeWrapperTag(AppEng.makeId("whitelisted/facades").toString());
private static final String NBT_ITEM_ID = "item"; private static final String NBT_ITEM_ID = "item";
@@ -105,8 +106,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
BlockState blockState = block.getDefaultState(); BlockState blockState = block.getDefaultState();
final boolean areTileEntitiesEnabled = AEConfig.instance().isFeatureEnabled(AEFeature.TILE_ENTITY_FACADES); final boolean areTileEntitiesEnabled = AEConfig.instance().isFeatureEnabled(AEFeature.TILE_ENTITY_FACADES);
ITag<Block> whitelistTag = BlockTags.getCollection().getOrCreate(TAG_WHITELISTED); final boolean isWhiteListed = BLOCK_WHITELIST.contains(block);
final boolean isWhiteListed = block.isIn(whitelistTag);
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL; final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
final BlockState defaultState = block.getDefaultState(); final BlockState defaultState = block.getDefaultState();
@@ -0,0 +1,54 @@
package appeng.metrics;
import java.util.function.Supplier;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheStats;
/**
* Cache Metrics simplify reporting of metrics for a Guava {@link Cache}.
*/
public class CacheMetrics extends Metric {
private final Supplier<Cache<?, ?>> cacheSupplier;
// Pre-allocate these to avoid repeated concatenation during reporting
private final String sizeId;
private final String hitCountId;
private final String missCountId;
private final String loadSuccessCountId;
private final String loadExceptionCountId;
private final String totalLoadTimeId;
private final String evictionCountId;
public CacheMetrics(String id, Supplier<Cache<?, ?>> cacheSupplier) {
super(id);
this.cacheSupplier = cacheSupplier;
this.sizeId = id + ".size";
this.hitCountId = id + ".hit-count";
this.missCountId = id + ".miss-count";
this.loadSuccessCountId = id + ".load-success-count";
this.loadExceptionCountId = id + ".load-exception-count";
this.totalLoadTimeId = id + ".total-load-time";
this.evictionCountId = id + ".eviction-count";
}
@Override
public void accept(MetricVisitor visitor) {
Cache<?, ?> cache = this.cacheSupplier.get();
if (cache != null) {
visitor.visitGauge(sizeId, cache.size()); // Thread-safe
CacheStats stats = cache.stats(); // Thread-safe
visitor.visitGauge(hitCountId, stats.hitCount());
visitor.visitGauge(missCountId, stats.missCount());
visitor.visitGauge(loadSuccessCountId, stats.loadSuccessCount());
visitor.visitGauge(loadExceptionCountId, stats.loadExceptionCount());
visitor.visitGauge(totalLoadTimeId, stats.totalLoadTime());
visitor.visitGauge(evictionCountId, stats.evictionCount());
}
}
}
+31
View File
@@ -0,0 +1,31 @@
package appeng.metrics;
import java.util.function.Supplier;
/**
* A Gauge is a Metric that will simply read the current value of something when
* the metrics are being reported.
*/
class Gauge extends Metric {
private final Supplier<Number> valueSupplier;
public Gauge(String id, Supplier<Number> valueSupplier) {
super(id);
this.valueSupplier = valueSupplier;
}
public Supplier<Number> getValueSupplier() {
return valueSupplier;
}
public Number getValue() {
return valueSupplier.get();
}
@Override
public void accept(MetricVisitor visitor) {
visitor.visitGauge(getId(), getValue());
}
}
+34
View File
@@ -0,0 +1,34 @@
package appeng.metrics;
import java.util.Objects;
abstract class Metric {
private final String id;
public Metric(String id) {
this.id = Objects.requireNonNull(id);
}
public String getId() {
return id;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Metric metric = (Metric) o;
return id.equals(metric.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
public abstract void accept(MetricVisitor visitor);
}

Some files were not shown because too many files have changed in this diff Show More