Compare commits

..

4 Commits

Author SHA1 Message Date
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
101 changed files with 2028 additions and 838 deletions
+1 -9
View File
@@ -55,15 +55,7 @@ jobs:
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1
- name: Publish to modmaven
env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }}
MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }}
run: ./gradlew publishMavenPublicationToModmavenRepository --no-daemon --max-workers 1
run: ./gradlew publish --no-daemon --max-workers 1
- name: Prepare artifact metadata
id: prepare_artifact_metadata
run: |
-15
View File
@@ -190,13 +190,6 @@ publishing {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
// ForgeGradle will generate wild dependency definitions, see https://github.com/MinecraftForge/ForgeGradle/issues/584
// Since we don't actually depend on anything, just remove the entire node.
pom.withXml {
asNode().remove(asNode().dependencies)
}
from components.java
artifact sourcesJar
artifact javadocJar
@@ -212,13 +205,5 @@ publishing {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
}
maven {
credentials {
username System.getenv("MODMAVEN_USER")
password System.getenv("MODMAVEN_PASSWORD")
}
name = "modmaven"
url = "https://modmaven.k-4u.nl/artifactory/local-releases/"
}
}
}
+5 -4
View File
@@ -9,13 +9,14 @@ artifact_basename=appliedenergistics2
# Minecraft Versions #
#########################################################
minecraft_release=1.16
minecraft_version=1.16.1
minecraft_version=1.16.2
mcp_mappings=20200723-1.16.1
forge_version=32.0.108
forge_version=33.0.5
#########################################################
# Provided APIs #
#########################################################
jei_minecraft_version=1.16.1
jei_version=7.0.0.6
top_version=3.0.1-beta-4
hwyla_version=1.10.8-B72_1.15.2
@@ -24,8 +25,8 @@ ctm_version=MC1.15.2-1.1.0.9
#########################################################
# Deployment #
#########################################################
website_version=1.16.1
curse_versions=1.16.1
website_version=1.16.2
curse_versions=1.16.2
curseforge_project=223794
#########################################################
+3 -3
View File
@@ -29,12 +29,12 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// 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"
// Runtime, Mods
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
// FIXME 1.16.2 runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}:${jei_version}")
// FIXME 1.16.2 runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
//runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}")
// unit test dependencies
@@ -53,8 +53,6 @@ public interface ICraftingHelper {
* @param stack If null, a new item will be created to hold the encoded pattern.
* Otherwise the given item must already contains an encoded
* pattern that will be overwritten.
* @throws IllegalArgumentException If either in or out contain only empty
* ItemStacks.
* @return A new encoded pattern, or the given stack with the pattern encoded in
* it.
*/
@@ -75,8 +73,6 @@ public interface ICraftingHelper {
* operation by the ME system.
* @param allowSubstitutes Controls whether the ME system will allow the use of
* equivalent items to craft this recipe.
* @throws IllegalArgumentException If either in or out contain only empty
* ItemStacks.
*/
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
boolean allowSubstitutes);
@@ -23,23 +23,13 @@
package appeng.api.implementations.items;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IGrowableCrystal {
ItemStack triggerGrowth(ItemStack is);
/**
* Gets the crystal growth multiplier based on the material it is submerged in.
*
* @param state The blockstate of the block the crystal is currently in.
* @return The multiplier for the growth tick progress. Zero if the crystal
* cannot grow in the current material.
*/
float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos);
float getMultiplier(Block blk, Material mat);
}
@@ -28,9 +28,4 @@ public enum GridNotification {
* the visible connections for this node have changed, useful for cable.
*/
CONNECTIONS_CHANGED,
/**
* the owner of the grid node has changed, and the node needs to be re-saved
*/
OWNER_CHANGED
}
@@ -87,8 +87,7 @@ public interface IGridBlock {
AEColor getGridColor();
/**
* Called by the {@link IGridNode} to notify its {@link IGridBlock} about
* events.
* Notifies your IGridBlock that changes were made to your connections
*/
void onGridNotification(@Nonnull GridNotification notification);
@@ -27,13 +27,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
/**
* Represents a location in the Minecraft Universe
*/
public class DimensionalCoord extends WorldCoord {
private final IWorld world;
private final World world;
private final DimensionType dimension;
public DimensionalCoord(final DimensionalCoord coordinate) {
@@ -48,13 +49,13 @@ public class DimensionalCoord extends WorldCoord {
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);
this.world = world;
this.dimension = world.func_230315_m_();
}
public DimensionalCoord(final IWorld world, final BlockPos pos) {
public DimensionalCoord(final World world, final BlockPos pos) {
super(pos);
this.world = world;
this.dimension = world.func_230315_m_();
@@ -84,7 +85,7 @@ public class DimensionalCoord extends WorldCoord {
return this.world == world;
}
public IWorld getWorld() {
public World getWorld() {
return this.world;
}
@@ -111,11 +111,6 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
return this.tileEntityFactory.get();
}
@Override
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
super.dropXpOnBlockBreak(worldIn, pos, amount);
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
if (newState.getBlock() == state.getBlock()) {
@@ -39,8 +39,6 @@ import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
@@ -84,12 +82,8 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
private static final IntegerProperty LIGHT_LEVEL = IntegerProperty.create("light_level", 0, 15);
public CableBusBlock() {
super(defaultProps(AEMaterials.GLASS).notSolid().noDrops().variableOpacity()
.setLightLevel(state -> state.get(LIGHT_LEVEL)));
setDefaultState(getDefaultState().with(LIGHT_LEVEL, 0));
super(defaultProps(AEMaterials.GLASS).notSolid().noDrops().variableOpacity());
}
@Override
@@ -132,9 +126,11 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(LIGHT_LEVEL);
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
if (state.getBlock() != this) {
return state.getBlock().getLightValue(state, world, pos);
}
return this.cb(world, pos).getLightValue();
}
@Override
@@ -390,13 +386,4 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, CableBusTileEntity te) {
if (currentState.getBlock() != this) {
return currentState;
}
int lightLevel = te.getCableBus().getLightValue();
return super.updateBlockStateFromTileEntity(currentState, te).with(LIGHT_LEVEL, lightLevel);
}
}
@@ -22,6 +22,7 @@ import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
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));
}
this.renderToolTip(matrixStack, currentToolTip, x, y, this.font);
this.renderToolTip(matrixStack, Lists.transform(currentToolTip, ITextComponent::func_241878_f), x, y,
this.font);
return;
} else if (stack.getCount() > bigNumber) {
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
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;
}
@@ -218,7 +218,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
styledLines.add(lines.get(i).deepCopy().modifyStyle(s -> style));
}
this.renderTooltip(matrices, styledLines, x, y);
this.func_243308_b(matrices, styledLines, x, y);
}
@@ -8,18 +8,19 @@ import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.SlotItemHandler;
/**
* A proxy for a slot that will always return an itemstack with size 1, if there
* is an item in the slot. Used to prevent the default item count from
* rendering.
*/
class Size1Slot extends Slot {
class Size1Slot extends SlotItemHandler {
private final Slot delegate;
private final SlotItemHandler delegate;
public Size1Slot(Slot delegate) {
super(delegate.inventory, delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
public Size1Slot(SlotItemHandler delegate) {
super(delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
this.delegate = delegate;
}
@@ -90,9 +90,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true);
this.searchField.setResponder(str -> this.refreshList());
this.addListener(this.searchField);
this.changeFocus(true);
this.searchField.setFocused2(true);
}
@Override
@@ -133,8 +131,11 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
@Override
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
this.searchField.setText("");
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
this.searchField.setText("");
this.refreshList();
}
return true;
}
@@ -172,7 +173,11 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
if (character == ' ' && this.searchField.getText().isEmpty()) {
return true;
}
return super.charTyped(character, key);
if (this.searchField.charTyped(character, key)) {
this.refreshList();
return true;
}
return false;
}
@Override
@@ -240,7 +245,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
/**
* Rebuilds the list of interfaces.
* <p>
*
* Respects a search term if present (ignores case) and adding only matching
* patterns.
*/
@@ -333,11 +338,12 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
*
* If this cache should be empty, it will populate it with an earlier cache if
* available or at least the cache for the empty string.
*
* @param searchTerm the corresponding search
*
* @return a Set matching a superset of the search term
*/
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
@@ -41,6 +41,11 @@ import appeng.fluids.util.FluidSorters;
import appeng.util.Platform;
import appeng.util.prioritylist.IPartitionList;
/**
* @author BrockWS
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class FluidRepo {
private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
.createList();
+12 -11
View File
@@ -21,22 +21,23 @@ package appeng.client.me;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.fluids.container.slots.IMEFluidSlot;
public class SlotFluidME extends Slot implements IMEFluidSlot {
/**
* @author BrockWS
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
private static final IInventory EMPTY_INVENTORY = new Inventory(0);
private final InternalFluidSlotME slot;
private InternalFluidSlotME slot;
public SlotFluidME(InternalFluidSlotME slot) {
super(EMPTY_INVENTORY, 0, slot.getxPosition(), slot.getyPosition());
super(null, 0, slot.getxPosition(), slot.getyPosition());
this.slot = slot;
}
@@ -49,7 +50,7 @@ public class SlotFluidME extends Slot implements IMEFluidSlot {
}
@Override
public boolean isItemValid(final ItemStack stack) {
public boolean isItemValid(final ItemStack par1ItemStack) {
return false;
}
@@ -68,7 +69,7 @@ public class SlotFluidME extends Slot implements IMEFluidSlot {
}
@Override
public void putStack(final ItemStack stack) {
public void putStack(final ItemStack par1ItemStack) {
}
@@ -84,7 +85,7 @@ public class SlotFluidME extends Slot implements IMEFluidSlot {
}
@Override
public boolean canTakeStack(final PlayerEntity player) {
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
return false;
}
}
+11 -15
View File
@@ -19,27 +19,23 @@
package appeng.client.me;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import appeng.api.storage.data.IAEItemStack;
public class SlotME extends Slot {
public class SlotME extends SlotItemHandler {
private static final IInventory EMPTY_INVENTORY = new Inventory(0);
private final InternalSlotME mySlot;
private final InternalSlotME slot;
public SlotME(final InternalSlotME slot) {
super(EMPTY_INVENTORY, 0, slot.getxPosition(), slot.getyPosition());
this.slot = slot;
public SlotME(final InternalSlotME me) {
super(null, 0, me.getxPosition(), me.getyPosition());
this.mySlot = me;
}
public IAEItemStack getAEStack() {
if (this.slot.hasPower()) {
return this.slot.getAEStack();
if (this.mySlot.hasPower()) {
return this.mySlot.getAEStack();
}
return null;
}
@@ -51,15 +47,15 @@ public class SlotME extends Slot {
@Override
public ItemStack getStack() {
if (this.slot.hasPower()) {
return this.slot.getStack();
if (this.mySlot.hasPower()) {
return this.mySlot.getStack();
}
return ItemStack.EMPTY;
}
@Override
public boolean getHasStack() {
if (this.slot.hasPower()) {
if (this.mySlot.hasPower()) {
return !this.getStack().isEmpty();
}
return false;
@@ -21,6 +21,7 @@ package appeng.client.render.cablebus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -29,11 +30,6 @@ import java.util.Random;
import javax.annotation.Nullable;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.Weigher;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.model.BakedQuad;
@@ -54,10 +50,7 @@ import appeng.api.util.AEColor;
public class CableBusBakedModel implements IBakedModel {
// The number of quads overall that will be cached
private static final int CACHE_QUAD_COUNT = 5000;
private final LoadingCache<CableBusRenderState, List<BakedQuad>> cableModelCache;
private static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
private final CableBuilder cableBuilder;
@@ -73,17 +66,6 @@ public class CableBusBakedModel implements IBakedModel {
this.facadeBuilder = facadeBuilder;
this.partModels = partModels;
this.particleTexture = particleTexture;
this.cableModelCache = CacheBuilder.newBuilder()//
.maximumWeight(CACHE_QUAD_COUNT)//
.weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (key, value) -> value.size())//
.build(new CacheLoader<CableBusRenderState, List<BakedQuad>>() {
@Override
public List<BakedQuad> load(CableBusRenderState renderState) {
final List<BakedQuad> model = new ArrayList<>();
addCableQuads(renderState, model);
return model;
}
});
}
@Override
@@ -110,7 +92,11 @@ public class CableBusBakedModel implements IBakedModel {
if (layer == RenderType.getCutout()) {
// First, handle the cable at the center of the cable bus
final List<BakedQuad> cableModel = cableModelCache.getUnchecked(renderState);
final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k -> {
final List<BakedQuad> model = new ArrayList<>();
this.addCableQuads(renderState, model);
return model;
});
quads.addAll(cableModel);
// Then handle attachments
@@ -355,4 +341,8 @@ public class CableBusBakedModel implements IBakedModel {
return ItemOverrideList.EMPTY;
}
public static void clearCache() {
CABLE_MODEL_CACHE.clear();
}
}
@@ -18,6 +18,7 @@ public class CableBusModelLoader implements IModelLoader<CableBusModel> {
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
CableBusBakedModel.clearCache();
}
@Override
@@ -142,7 +142,7 @@ public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity>
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
@Nonnull IModelData extraData) {
if (side != null) {
side = r.resultingRotate(side); // This fixes the incorrect lightmap position
side = r.rotate(side); // This fixes the incorrect lightmap position
}
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
@@ -133,7 +133,7 @@ public final class ContainerLocator {
public static ContainerLocator forPart(AEBasePart part) {
IPartHost host = part.getHost();
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() {
@@ -42,7 +42,7 @@ import appeng.api.networking.security.IActionHost;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.MEInterfaceUpdatePacket;
import appeng.core.sync.packets.CompressedNBTPacket;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.InventoryAction;
@@ -177,7 +177,7 @@ public final class InterfaceTerminalContainer extends AEBaseContainer {
if (!this.data.isEmpty()) {
try {
NetworkHandler.instance().sendTo(new MEInterfaceUpdatePacket(this.data),
NetworkHandler.instance().sendTo(new CompressedNBTPacket(this.data),
(ServerPlayerEntity) this.getPlayerInv().player);
} catch (final IOException e) {
// :P
@@ -261,19 +261,13 @@ public class PatternTermContainer extends MEMonitorableContainer
return new ItemStack[] { out };
}
} else {
boolean hasValue = false;
final ItemStack[] list = new ItemStack[3];
for (int i = 0; i < this.outputSlots.length; i++) {
final ItemStack out = this.outputSlots[i].getStack();
list[i] = out;
if (!out.isEmpty()) {
hasValue = true;
}
}
if (hasValue) {
return list;
}
return list;
}
return null;
-27
View File
@@ -31,8 +31,6 @@ import java.util.Set;
import java.util.function.DoubleSupplier;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.google.common.base.Strings;
import org.apache.commons.lang3.tuple.Pair;
@@ -395,15 +393,6 @@ public final class AEConfig {
return this.meteoriteDimensionWhitelist;
}
@Nullable
public String getImprovedFluidTag() {
return Strings.emptyToNull(COMMON.improvedFluidTag.get());
}
public float getImprovedFluidMultiplier() {
return COMMON.improvedFluidMultiplier.get().floatValue();
}
// Setters keep visibility as low as possible.
private static class ClientConfig {
@@ -518,11 +507,6 @@ public final class AEConfig {
public final ConfigValue<Integer> condenserMatterBallsPower;
public final ConfigValue<Integer> condenserSingularityPower;
// In-World Purification
// Settings for improved speed depending on fluid the crystal is in
public final ConfigValue<String> improvedFluidTag;
public final ConfigValue<Double> improvedFluidMultiplier;
public final Map<TickRates, ConfigValue<Integer>> tickRateMin = new HashMap<>();
public final Map<TickRates, ConfigValue<Integer>> tickRateMax = new HashMap<>();
@@ -633,17 +617,6 @@ public final class AEConfig {
tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax()));
}
builder.pop();
builder.comment("Settings for in-world purification of crystals.").push("inWorldPurification");
improvedFluidTag = builder.comment(
"A fluid tag that identifies fluids that improve crystal purification speed. Does not affect purification with water/lava.")
.define("improvedFluidTag", "");
improvedFluidMultiplier = builder
.comment("The speed multiplier to use when the crystals are submerged in the improved fluid.")
.defineInRange("improvedFluidMultiplier", 2.0, 1.0, 10.0);
builder.pop();
}
}
+11 -6
View File
@@ -34,13 +34,12 @@ import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.particles.ParticleType;
import net.minecraft.tileentity.TileEntityType;
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.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
@@ -101,6 +100,7 @@ public final class AppEng {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
registration = new Registration();
modEventBus.addListener(this::bootstrap);
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
modEventBus.addGenericListener(Item.class, registration::registerItems);
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
@@ -108,9 +108,6 @@ public final class AppEng {
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
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(this::commonSetup);
@@ -129,7 +126,15 @@ public final class AppEng {
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) {
// This must run here because the config is not available earlier
DeferredWorkQueue.runLater(AppEngBootstrap::enhanceBiomes);
ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(IInitComponent.class)
.forEachRemaining(IInitComponent::initialize);
@@ -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);
}
}
+1 -69
View File
@@ -34,6 +34,7 @@ import net.minecraft.particles.ParticleType;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
@@ -41,7 +42,6 @@ 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;
@@ -213,7 +213,6 @@ import appeng.me.cache.PathGridCache;
import appeng.me.cache.SecurityCache;
import appeng.me.cache.SpatialPylonCache;
import appeng.me.cache.TickManagerCache;
import appeng.mixins.StructureAccessor;
import appeng.parts.automation.PlaneModelLoader;
import appeng.recipes.game.DisassembleRecipe;
import appeng.recipes.game.FacadeRecipe;
@@ -682,73 +681,6 @@ final class Registration {
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)
@@ -115,12 +115,7 @@ public class ApiCrafting implements ICraftingHelper {
// We use the shared itemstack for an identity lookup.
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is);
try {
return new CraftingPatternDetails(ais, world);
} catch (IllegalStateException e) {
AELog.warn("Could not decode an invalid pattern %s: %s", is, e);
return null;
}
return new CraftingPatternDetails(ais, world);
}
private boolean attemptRecovery(EncodedPatternItem patternItem, ItemStack itemStack, World world) {
@@ -20,9 +20,7 @@ package appeng.core.api.definitions;
import static appeng.block.AEBaseBlock.defaultProps;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.SoundType;
@@ -30,7 +28,6 @@ import net.minecraft.block.StairsBlock;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ToolType;
@@ -265,20 +262,18 @@ public final class ApiBlocks implements IBlocks {
this.chiseledQuartzBlock = deco.block("chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES))
.build();
AbstractBlock.IExtendedPositionPredicate<EntityType<?>> neverAllowSpawn = (p1, p2, p3, p4) -> false;
this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS).block("quartz_glass", () -> {
return new QuartzGlassBlock(defaultProps(Material.GLASS).notSolid().setAllowsSpawn(neverAllowSpawn));
}).rendering(new BlockRenderingCustomizer() {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
}
}).build();
this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS)
.block("quartz_glass", () -> new QuartzGlassBlock(defaultProps(Material.GLASS).notSolid()))
.rendering(new BlockRenderingCustomizer() {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
}
}).build();
this.quartzVibrantGlass = deco
.block("quartz_vibrant_glass",
() -> new QuartzLampBlock(defaultProps(Material.GLASS).setLightLevel(b -> 15).notSolid()
.setAllowsSpawn(neverAllowSpawn)))
() -> new QuartzLampBlock(defaultProps(Material.GLASS).setLightLevel(b -> 15).notSolid()))
.addFeatures(AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS)
.rendering(new BlockRenderingCustomizer() {
@Override
@@ -56,7 +56,6 @@ import appeng.hooks.BlockToolDispenseItemBehavior;
import appeng.hooks.MatterCannonDispenseItemBehavior;
import appeng.items.materials.MaterialType;
import appeng.items.misc.CrystalSeedItem;
import appeng.items.misc.CrystalSeedRendering;
import appeng.items.misc.EncodedPatternItem;
import appeng.items.misc.PaintBallItem;
import appeng.items.misc.PaintBallItemRendering;
@@ -300,15 +299,24 @@ public final class ApiItems implements IItems {
this.certusCrystalSeed = registry
.item("certus_crystal_seed",
props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
.bootstrap(item -> new IClientSetupComponent() {
@Override
@OnlyIn(Dist.CLIENT)
public void setup() {
// Expose the growth of the seed to the model system
ItemModelsProperties.func_239418_a_(item, new ResourceLocation("appliedenergistics2:growth"),
(is, w, p) -> CrystalSeedItem.getGrowthTicks(is)
/ (float) CrystalSeedItem.GROWTH_TICKS_REQUIRED);
}
}).features(AEFeature.CRYSTAL_SEEDS).build();
this.fluixCrystalSeed = registry
.item("fluix_crystal_seed",
props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
.features(AEFeature.CRYSTAL_SEEDS).build();
this.netherQuartzSeed = registry
.item("nether_quartz_seed",
props -> new CrystalSeedItem(props, materials.purifiedNetherQuartzCrystal().item()))
.bootstrap(CrystalSeedRendering::new).features(AEFeature.CRYSTAL_SEEDS).build();
.features(AEFeature.CRYSTAL_SEEDS).build();
GrowingCrystalEntity.TYPE = registry
.<GrowingCrystalEntity>entity("growing_crystal", GrowingCrystalEntity::new, EntityClassification.MISC)
@@ -22,12 +22,12 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.features.ILocatable;
import appeng.api.features.ILocatableRegistry;
import appeng.core.AELog;
import appeng.util.Platform;
public final class LocatableRegistry implements ILocatableRegistry {
@@ -35,19 +35,18 @@ public final class LocatableRegistry implements ILocatableRegistry {
public LocatableRegistry() {
this.set = new HashMap<>();
MinecraftForge.EVENT_BUS.addListener(this::updateLocatable);
MinecraftForge.EVENT_BUS.register(this);
}
private void updateLocatable(final LocatableEventAnnounce e) {
@SubscribeEvent
public void updateLocatable(final LocatableEventAnnounce e) {
if (Platform.isClient()) {
return; // IGNORE!
}
if (e.change == LocatableEvent.REGISTER) {
AELog.debug("Registering locatable %s: %s", e.target.getLocatableSerial(), e.target);
this.set.put(e.target.getLocatableSerial(), e.target);
} else if (e.change == LocatableEvent.UNREGISTER) {
AELog.debug("Unregistering locatable %s: %s", e.target.getLocatableSerial(), e.target);
this.set.remove(e.target.getLocatableSerial());
}
}
@@ -51,12 +51,12 @@ public class MovableTileRegistry implements IMovableRegistry {
private final List<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
private final ITag<Block> blockTagWhiteList;
private final ITag<Block> blockTagBlackList;
private final ITag.INamedTag<Block> blockTagWhiteList;
private final ITag.INamedTag<Block> blockTagBlackList;
public MovableTileRegistry() {
this.blockTagWhiteList = BlockTags.getCollection().getOrCreate(TAG_WHITELIST);
this.blockTagBlackList = BlockTags.getCollection().getOrCreate(TAG_BLACKLIST);
this.blockTagWhiteList = BlockTags.makeWrapperTag(TAG_WHITELIST.toString());
this.blockTagBlackList = BlockTags.makeWrapperTag(TAG_BLACKLIST.toString());
}
@Override
@@ -29,6 +29,7 @@ import appeng.core.sync.packets.BlockTransitionEffectPacket;
import appeng.core.sync.packets.ClickPacket;
import appeng.core.sync.packets.CompassRequestPacket;
import appeng.core.sync.packets.CompassResponsePacket;
import appeng.core.sync.packets.CompressedNBTPacket;
import appeng.core.sync.packets.ConfigButtonPacket;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.CraftRequestPacket;
@@ -38,7 +39,6 @@ import appeng.core.sync.packets.ItemTransitionEffectPacket;
import appeng.core.sync.packets.JEIRecipePacket;
import appeng.core.sync.packets.LightningPacket;
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
import appeng.core.sync.packets.MEInterfaceUpdatePacket;
import appeng.core.sync.packets.MEInventoryUpdatePacket;
import appeng.core.sync.packets.MatterCannonPacket;
import appeng.core.sync.packets.MockExplosionPacket;
@@ -101,7 +101,7 @@ public class BasePacketHandler {
PACKET_ASSEMBLER_ANIMATION(AssemblerAnimationPacket.class, AssemblerAnimationPacket::new),
PACKET_ME_INTERFACE_UPDATE(MEInterfaceUpdatePacket.class, MEInterfaceUpdatePacket::new),
PACKET_COMPRESSED_NBT(CompressedNBTPacket.class, CompressedNBTPacket::new),
PACKET_PAINTED_ENTITY(PaintedEntityPacket.class, PaintedEntityPacket::new),
@@ -71,7 +71,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
data.writeInt(this.getPacketID());
data.writeBlockPos(pos);
int blockStateId = GameData.getBlockStateIDMap().get(blockState);
int blockStateId = GameData.getBlockStateIDMap().getId(blockState);
if (blockStateId == -1) {
AELog.warn("Failed to find numeric id for block state %s", blockState);
}
@@ -18,7 +18,13 @@
package appeng.core.sync.packets;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import io.netty.buffer.Unpooled;
@@ -26,6 +32,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -34,24 +41,55 @@ import appeng.client.gui.implementations.InterfaceTerminalScreen;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
public class MEInterfaceUpdatePacket extends BasePacket {
//TODO, this is pointless, NBT is already compressed when written to a PacketBuffer.
public class CompressedNBTPacket extends BasePacket {
// input.
private final CompoundNBT in;
// output...
private final PacketBuffer data;
private final GZIPOutputStream compressFrame;
public MEInterfaceUpdatePacket(final PacketBuffer stream) {
public CompressedNBTPacket(final PacketBuffer stream) {
this.data = null;
this.in = stream.readCompoundTag();
this.compressFrame = null;
try (DataInputStream inStream = new DataInputStream(new GZIPInputStream(new InputStream() {
@Override
public int read() {
if (stream.readableBytes() <= 0) {
return -1;
}
return stream.readByte() & 0xff;
}
}))) {
this.in = CompressedStreamTools.read(inStream);
} catch (IOException e) {
throw new RuntimeException("Failed to decompress packet.", e);
}
}
// api
public MEInterfaceUpdatePacket(final CompoundNBT din) throws IOException {
this.in = null;
public CompressedNBTPacket(final CompoundNBT din) throws IOException {
this.data = new PacketBuffer(Unpooled.buffer(2048));
this.data.writeInt(this.getPacketID());
this.data.writeCompoundTag(din);
this.in = din;
this.compressFrame = new GZIPOutputStream(new OutputStream() {
@Override
public void write(final int value) {
CompressedNBTPacket.this.data.writeByte(value);
}
});
CompressedStreamTools.write(din, new DataOutputStream(this.compressFrame));
this.compressFrame.close();
this.configureWrite(this.data);
}
@@ -19,9 +19,13 @@
package appeng.core.sync.packets;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.BufferOverflowException;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.annotation.Nullable;
@@ -37,6 +41,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkDirection;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.AELog;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.fluids.client.gui.FluidTerminalScreen;
@@ -50,6 +55,8 @@ import appeng.fluids.util.AEFluidStack;
public class MEFluidInventoryUpdatePacket extends BasePacket {
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
private static final int TEMP_BUFFER_SIZE = 1024;
private static final int STREAM_MASK = 0xff;
// input.
@Nullable
@@ -59,18 +66,47 @@ public class MEFluidInventoryUpdatePacket extends BasePacket {
@Nullable
private final PacketBuffer data;
@Nullable
private final GZIPOutputStream compressFrame;
private int writtenBytes = 0;
private boolean empty = true;
public MEFluidInventoryUpdatePacket(final PacketBuffer stream) {
this.data = null;
this.compressFrame = null;
this.list = new LinkedList<>();
this.ref = stream.readByte();
while (stream.readableBytes() > 0) {
this.list.add(AEFluidStack.fromPacket(stream));
try (final GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
@Override
public int read() {
if (stream.readableBytes() <= 0) {
return -1;
}
return stream.readByte() & STREAM_MASK;
}
})) {
final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes()));
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while (gzReader.available() != 0) {
final int bytes = gzReader.read(tmp);
if (bytes > 0) {
uncompressed.writeBytes(tmp, 0, bytes);
}
}
while (uncompressed.readableBytes() > 0) {
this.list.add(AEFluidStack.fromPacket(uncompressed));
}
} catch (IOException e) {
throw new RuntimeException("Failed to decompress packet.", e);
}
this.empty = this.list.isEmpty();
}
@@ -85,6 +121,14 @@ public class MEFluidInventoryUpdatePacket extends BasePacket {
this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
this.data.writeInt(this.getPacketID());
this.data.writeByte(this.ref);
this.compressFrame = new GZIPOutputStream(new OutputStream() {
@Override
public void write(final int value) {
MEFluidInventoryUpdatePacket.this.data.writeByte(value);
}
});
this.list = null;
}
@@ -101,19 +145,28 @@ public class MEFluidInventoryUpdatePacket extends BasePacket {
@Nullable
@Override
public IPacket<?> toPacket(NetworkDirection direction) {
this.configureWrite(this.data);
return super.toPacket(direction);
try {
this.compressFrame.close();
this.configureWrite(this.data);
return super.toPacket(direction);
} catch (final IOException e) {
AELog.debug(e);
}
return null;
}
public void appendFluid(final IAEFluidStack fs) throws IOException, BufferOverflowException {
final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
fs.writeToPacket(tmp);
this.compressFrame.flush();
if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) {
throw new BufferOverflowException();
} else {
this.writtenBytes += tmp.readableBytes();
this.data.writeBytes(tmp.array(), 0, tmp.readableBytes());
this.compressFrame.write(tmp.array(), 0, tmp.readableBytes());
this.empty = false;
}
}
@@ -19,10 +19,12 @@
package appeng.core.sync.packets;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.BufferOverflowException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.annotation.Nullable;
@@ -43,6 +45,7 @@ import appeng.client.gui.implementations.CraftConfirmScreen;
import appeng.client.gui.implementations.CraftingCPUScreen;
import appeng.client.gui.implementations.MEMonitorableScreen;
import appeng.client.gui.implementations.NetworkStatusScreen;
import appeng.core.AELog;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack;
@@ -50,6 +53,8 @@ import appeng.util.item.AEItemStack;
public class MEInventoryUpdatePacket extends BasePacket {
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
private static final int TEMP_BUFFER_SIZE = 1024;
private static final int STREAM_MASK = 0xff;
// input.
@Nullable
@@ -59,18 +64,48 @@ public class MEInventoryUpdatePacket extends BasePacket {
@Nullable
private final PacketBuffer data;
@Nullable
private final GZIPOutputStream compressFrame;
private int writtenBytes = 0;
private boolean empty = true;
public MEInventoryUpdatePacket(final PacketBuffer stream) {
this.data = null;
this.compressFrame = null;
this.list = new ArrayList<>();
this.ref = stream.readByte();
while (stream.readableBytes() > 0) {
this.list.add(AEItemStack.fromPacket(stream));
// int originalBytes = stream.readableBytes();
try (GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
@Override
public int read() {
if (stream.readableBytes() <= 0) {
return -1;
}
return stream.readByte() & STREAM_MASK;
}
})) {
final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes()));
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while (gzReader.available() != 0) {
final int bytes = gzReader.read(tmp);
if (bytes > 0) {
uncompressed.writeBytes(tmp, 0, bytes);
}
}
while (uncompressed.readableBytes() > 0) {
this.list.add(AEItemStack.fromPacket(uncompressed));
}
} catch (IOException e) {
throw new RuntimeException("Failed to decompress packet.", e);
}
this.empty = this.list.isEmpty();
}
@@ -85,6 +120,14 @@ public class MEInventoryUpdatePacket extends BasePacket {
this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
this.data.writeInt(this.getPacketID());
this.data.writeByte(this.ref);
this.compressFrame = new GZIPOutputStream(new OutputStream() {
@Override
public void write(final int value) {
MEInventoryUpdatePacket.this.data.writeByte(value);
}
});
this.list = null;
}
@@ -113,19 +156,28 @@ public class MEInventoryUpdatePacket extends BasePacket {
@Nullable
@Override
public IPacket<?> toPacket(NetworkDirection direction) {
this.configureWrite(this.data);
return super.toPacket(direction);
try {
this.compressFrame.close();
this.configureWrite(this.data);
return super.toPacket(direction);
} catch (final IOException e) {
AELog.debug(e);
}
return null;
}
public void appendItem(final IAEItemStack is) throws IOException, BufferOverflowException {
final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
is.writeToPacket(tmp);
this.compressFrame.flush();
if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) {
throw new BufferOverflowException();
} else {
this.writtenBytes += tmp.readableBytes();
this.data.writeBytes(tmp.array(), 0, tmp.readableBytes());
this.compressFrame.write(tmp.array(), 0, tmp.readableBytes());
this.empty = false;
}
}
@@ -129,7 +129,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
// is a debug tool, we'll not care about being terribly efficient here
ChunkPos.getAllInBox(new ChunkPos(spawned.getPos()), 1).forEach(cp -> {
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;
@@ -20,8 +20,11 @@ package appeng.decorative.solid;
import net.minecraft.block.AbstractGlassBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.util.Direction;
import appeng.helpers.AEMaterials;
public class QuartzGlassBlock extends AbstractGlassBlock {
public QuartzGlassBlock(Properties props) {
@@ -30,7 +33,8 @@ public class QuartzGlassBlock extends AbstractGlassBlock {
@Override
public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
if (adjacentBlockState.getBlock() instanceof QuartzGlassBlock) {
final Material mat = adjacentBlockState.getMaterial();
if (mat == Material.GLASS || mat == AEMaterials.GLASS) {
if (adjacentBlockState.getRenderType() == state.getRenderType()) {
return true;
}
@@ -29,6 +29,7 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import appeng.block.AEBaseBlock;
import appeng.core.worlddata.WorldData;
@@ -42,10 +43,11 @@ public class SkyStoneBlock extends AEBaseBlock {
super(props);
this.type = type;
MinecraftForge.EVENT_BUS.addListener(this::breakFaster);
MinecraftForge.EVENT_BUS.register(this);
}
private void breakFaster(final PlayerEvent.BreakSpeed event) {
@SubscribeEvent
public void breakFaster(final PlayerEvent.BreakSpeed event) {
if (event.getState().getBlock() == this && event.getPlayer() != null) {
final ItemStack is = event.getPlayer().getItemStackFromSlot(EquipmentSlotType.MAINHAND);
int level = -1;
@@ -19,14 +19,13 @@
package appeng.entity;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import appeng.api.features.AEFeature;
@@ -36,27 +35,12 @@ import appeng.client.EffectType;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.items.misc.CrystalSeedItem;
import appeng.util.Platform;
public final class GrowingCrystalEntity extends AEBaseItemEntity {
public static EntityType<GrowingCrystalEntity> TYPE;
// Growth tick progress per tick by number of adjacent accelerators
// Expressed as 1/1000th of a growth tick, applied to progress_1000
// each time this entity ticks.
private static final int[] GROWTH_TICK_PROGRESS = { 1, // no accelerators
40, // 1 accelerator
92, // 2 accelerators
159, // 3 accelerators
247, // 4 accelerators
361, // 5 accelerators
509 // 6 accelerators
};
/**
* The accumulated progress towards a single growth tick of the crystal in
* 1/1000th of a growth tick.
*/
private int progress_1000 = 0;
public GrowingCrystalEntity(EntityType<? extends GrowingCrystalEntity> type, World world) {
@@ -72,140 +56,126 @@ public final class GrowingCrystalEntity extends AEBaseItemEntity {
public void tick() {
super.tick();
final ItemStack is = this.getItem();
final Item gc = is.getItem();
if (!(gc instanceof IGrowableCrystal)) {
return;
}
applyGrowthTick((IGrowableCrystal) gc, is);
}
private void applyGrowthTick(IGrowableCrystal cry, ItemStack is) {
if (!AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) {
return;
}
final int x = MathHelper.floor(this.getPosX());
final int y = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
final int z = MathHelper.floor(this.getPosZ());
final ItemStack is = this.getItem();
final Item gc = is.getItem();
BlockPos pos = new BlockPos(x, y, z);
final BlockState state = this.world.getBlockState(pos);
if (gc instanceof IGrowableCrystal) // if it changes this just stops being an issue...
{
final int j = MathHelper.floor(this.getPosX());
final int i = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
final int k = MathHelper.floor(this.getPosZ());
final float multiplier = cry.getMultiplier(state, world, pos);
final BlockState state = this.world.getBlockState(new BlockPos(j, i, k));
final Material mat = state.getMaterial();
final IGrowableCrystal cry = (IGrowableCrystal) is.getItem();
if (multiplier <= 0) {
// Crystal is in unsuitable material, reset progress and quit
this.progress_1000 = 0;
return;
}
final float multiplier = cry.getMultiplier(state.getBlock(), mat);
final int speed = (int) Math.max(1, this.getSpeed(j, i, k) * multiplier);
final int progressPerTick = (int) Math.max(1, this.getSpeed(pos) * multiplier);
final boolean isClient = Platform.isClient();
if (world.isRemote()) {
// On the client, we reuse the growth-tick-progress
// as a tick-counter for particle effects
int len = getTicksBetweenParticleEffects(progressPerTick);
if (++this.progress_1000 >= len) {
if (mat.isLiquid()) {
if (isClient) {
this.progress_1000++;
} else {
this.progress_1000 += speed;
}
} else {
this.progress_1000 = 0;
AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2,
this.getPosZ(), null);
}
} else {
this.progress_1000 += progressPerTick;
if (this.progress_1000 >= 1000) {
// We need to copy the stack or the change detection will not work and not sync
// this new stack to the client
ItemStack newItem = is.copy();
if (isClient) {
int len = 40;
// If we did not use a while loop here, the fastest growth for a crystal
// would be limited to a minimum of 30 seconds (based on 600 required growth
// ticks).
// Should a crystal decide to use a high multiplier for a certain material,
// it should be possible to go faster.
do {
newItem = cry.triggerGrowth(newItem);
if (speed > 2) {
len = 20;
}
if (speed > 90) {
len = 15;
}
if (speed > 150) {
len = 10;
}
if (speed > 240) {
len = 7;
}
if (speed > 360) {
len = 3;
}
if (speed > 500) {
len = 1;
}
if (this.progress_1000 >= len) {
this.progress_1000 = 0;
AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2,
this.getPosZ(), null);
}
} else {
if (this.progress_1000 > 1000) {
this.progress_1000 -= 1000;
// We assume that if the item changes, the process is complete and we can break
} while (this.progress_1000 >= 1000 && newItem.getItem() == is.getItem());
this.setItem(newItem);
// We need to copy the stack or the change detection will not work and not sync
// this new stack to the client
ItemStack newItem = cry.triggerGrowth(is.copy());
this.setItem(newItem);
}
}
}
}
private static int getTicksBetweenParticleEffects(int progressPerTick) {
if (progressPerTick > 500) {
return 1; // 20 times per second
} else if (progressPerTick > 360) {
return 3;
} else if (progressPerTick > 240) {
return 7;
} else if (progressPerTick > 150) {
return 10;
} else if (progressPerTick > 90) {
return 15;
} else if (progressPerTick > 2) {
return 20;
} else {
return 40; // Every 2 seconds
}
}
private int getSpeed(final int x, final int y, final int z) {
final int per = 80;
final float mul = 0.3f;
/**
* Gets the extra progress per tick in 1/1000th of a growth tick based on the
* surrounding accelerators.
*/
private int getSpeed(BlockPos pos) {
int acceleratorCount = getAcceleratorCount(pos);
int qty = 0;
if (acceleratorCount < 0) {
return GROWTH_TICK_PROGRESS[0];
} else if (acceleratorCount >= GROWTH_TICK_PROGRESS.length) {
return GROWTH_TICK_PROGRESS[GROWTH_TICK_PROGRESS.length - 1];
} else {
return GROWTH_TICK_PROGRESS[acceleratorCount];
}
}
private int getAcceleratorCount(BlockPos pos) {
int count = 0;
BlockPos.Mutable testPos = new BlockPos.Mutable();
for (Direction direction : Direction.values()) {
if (this.isPoweredAccelerator(testPos.func_239622_a_(pos, direction))) {
count++;
}
if (this.isAccelerated(x + 1, y, z)) {
qty += per + qty * mul;
}
return count;
if (this.isAccelerated(x, y + 1, z)) {
qty += per + qty * mul;
}
if (this.isAccelerated(x, y, z + 1)) {
qty += per + qty * mul;
}
if (this.isAccelerated(x - 1, y, z)) {
qty += per + qty * mul;
}
if (this.isAccelerated(x, y - 1, z)) {
qty += per + qty * mul;
}
if (this.isAccelerated(x, y, z - 1)) {
qty += per + qty * mul;
}
return qty;
}
private boolean isPoweredAccelerator(BlockPos pos) {
final TileEntity te = this.world.getTileEntity(pos);
private boolean isAccelerated(final int x, final int y, final int z) {
final TileEntity te = this.world.getTileEntity(new BlockPos(x, y, z));
return te instanceof ICrystalGrowthAccelerator && ((ICrystalGrowthAccelerator) te).isPowered();
}
// Don't let seeds "float" on water surface
@Override
protected void applyFloatMotion() {
ItemStack item = getItem();
// Make ungrown seeds sink, and fully grown seeds bouyant allowing for
// automation based around dropping seeds between 5 CGAs, then catchiung
// them on their way up.
if (item.getItem() instanceof CrystalSeedItem) {
Vector3d v = this.getMotion();
// Apply a much smaller acceleration to make them slowly sink
double yAccel = this.hasNoGravity() ? 0 : -0.002;
// Apply the x/z slow-down, and the y acceleration
this.setMotion(v.x * 0.99, v.y + yAccel, v.z * 0.99);
return;
}
super.applyFloatMotion();
@@ -140,8 +140,8 @@ public final class TinyTNTPrimedEntity extends TNTEntity implements IEntityAddit
return;
}
final Explosion ex = new Explosion(this.world, this, null, null, this.getPosX(), this.getPosY(), this.getPosZ(),
0.2f, false, Explosion.Mode.BREAK);
final Explosion ex = new Explosion(this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f,
false, Mode.BREAK);
final AxisAlignedBB area = new AxisAlignedBB(this.getPosX() - 1.5, this.getPosY() - 1.5f, this.getPosZ() - 1.5,
this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5);
final List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, area);
@@ -37,18 +37,15 @@ public class FacadeContainer implements IFacadeContainer {
private final int facades = 6;
private final CableBusStorage storage;
private final Runnable changeCallback;
public FacadeContainer(final CableBusStorage cbs, Runnable changeCallback) {
public FacadeContainer(final CableBusStorage cbs) {
this.storage = cbs;
this.changeCallback = changeCallback;
}
@Override
public boolean addFacade(final IFacadePart a) {
if (this.getFacade(a.getSide()) == null) {
this.storage.setFacade(a.getSide().ordinal(), a);
this.notifyChange();
return true;
}
return false;
@@ -59,7 +56,6 @@ public class FacadeContainer implements IFacadeContainer {
if (side != null && side != AEPartLocation.INTERNAL) {
if (this.storage.getFacade(side.ordinal()) != null) {
this.storage.setFacade(side.ordinal(), null);
this.notifyChange();
if (host != null) {
host.markForUpdate();
}
@@ -88,7 +84,6 @@ public class FacadeContainer implements IFacadeContainer {
for (int x = 0; x < this.facades; x++) {
this.storage.setFacade(x, newFacades[x]);
}
this.notifyChange();
}
@Override
@@ -180,9 +175,4 @@ public class FacadeContainer implements IFacadeContainer {
}
return true;
}
private void notifyChange() {
this.changeCallback.run();
}
}
@@ -176,7 +176,7 @@ public class FluidTerminalScreen extends AEBaseMEScreen<FluidTerminalContainer>
list.add(new StringTextComponent(formattedAmount));
list.add(new StringTextComponent(modName));
this.renderTooltip(matrixStack, list, mouseX, mouseY);
this.func_243308_b(matrixStack, list, mouseX, mouseY);
return;
}
@@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ITag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
@@ -57,8 +56,8 @@ import appeng.util.Platform;
public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridTickable {
public static final ResourceLocation TAG_BLACKLIST = new ResourceLocation(AppEng.MOD_ID,
"blacklisted/fluid_annihilation_plane");
public static final ITag.INamedTag<Fluid> TAG_BLACKLIST = FluidTags
.makeWrapperTag(AppEng.makeId("blacklisted/fluid_annihilation_plane").toString());
private static final PlaneModels MODELS = new PlaneModels("part/fluid_annihilation_plane",
"part/fluid_annihilation_plane_on");
@@ -214,8 +213,7 @@ public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridT
}
private boolean isFluidBlacklisted(Fluid fluid) {
ITag<Fluid> tag = FluidTags.getCollection().getOrCreate(TAG_BLACKLIST);
return fluid.isIn(tag);
return TAG_BLACKLIST.contains(fluid);
}
}
@@ -96,15 +96,16 @@ public class FluidImportBusPart extends SharedFluidBusPart {
}
final TileEntity te = this.getConnectedTE();
LazyOptional<IFluidHandler> fhOpt = LazyOptional.empty();
if (te != null) {
LazyOptional<IFluidHandler> fhOpt = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
this.getSide().getFacing().getOpposite());
if (fhOpt.isPresent()) {
try {
final IFluidHandler fh = fhOpt.orElseThrow(() -> new IllegalStateException());
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory(this.getChannel());
te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite());
}
if (fhOpt.isPresent()) {
try {
final IFluidHandler fh = fhOpt.orElse(null);
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory(this.getChannel());
if (fh != null) {
final FluidStack fluidStack = fh.drain(this.calculateAmountToSend(), FluidAction.SIMULATE);
if (this.filterEnabled() && !this.isInFilter(fluidStack)) {
@@ -127,11 +128,12 @@ public class FluidImportBusPart extends SharedFluidBusPart {
}
return TickRateModulation.IDLE;
} catch (GridAccessException e) {
// skip
}
} catch (GridAccessException e) {
e.printStackTrace();
}
}
return TickRateModulation.SLEEP;
}
@@ -24,19 +24,15 @@ import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.block.BlockState;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -45,7 +41,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.implementations.items.IGrowableCrystal;
import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
import appeng.entity.GrowingCrystalEntity;
import appeng.items.AEBaseItem;
@@ -99,24 +94,8 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal {
}
@Override
public float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos) {
// Check for the improved fluid tag and return the improved multiplier
String improvedFluidTagName = AEConfig.instance().getImprovedFluidTag();
if (improvedFluidTagName != null) {
ITag<Fluid> tag = FluidTags.getCollection().get(new ResourceLocation(improvedFluidTagName));
if (tag != null && state.getFluidState().isTagged(tag)) {
return AEConfig.instance().getImprovedFluidMultiplier();
}
}
// Check for the normal supported fluid
if (world != null && world.func_234923_W_() == World.field_234919_h_) {
// In the nether, use Lava as the "normal" fluid
return state.getFluidState().isTagged(FluidTags.LAVA) ? 1 : 0;
} else {
return state.getFluidState().isTagged(FluidTags.WATER) ? 1 : 0;
}
public float getMultiplier(final Block blk, final Material mat) {
return 0.5f;
}
@Override
@@ -1,29 +0,0 @@
package appeng.items.misc;
import net.minecraft.item.Item;
import net.minecraft.item.ItemModelsProperties;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.components.IClientSetupComponent;
/**
* Exposes a predicate "growth", which is used in the item model to
* differentiate the growth stages.
*/
public class CrystalSeedRendering implements IClientSetupComponent {
private final Item item;
public CrystalSeedRendering(Item item) {
this.item = item;
}
@Override
@OnlyIn(Dist.CLIENT)
public void setup() {
// Expose the growth of the seed to the model system
ItemModelsProperties.func_239418_a_(item, new ResourceLocation("appliedenergistics2:growth"),
(is, w, p) -> CrystalSeedItem.getGrowthTicks(is) / (float) CrystalSeedItem.GROWTH_TICKS_REQUIRED);
}
}
@@ -307,27 +307,14 @@ public class EncodedPatternItem extends AEBaseItem {
final ListNBT tagIn = new ListNBT();
final ListNBT tagOut = new ListNBT();
boolean hasInput = false;
for (final ItemStack i : in) {
tagIn.add(createItemTag(i));
if (!i.isEmpty()) {
hasInput = true;
}
}
Preconditions.checkArgument(hasInput, "cannot encode a pattern that has no inputs.");
boolean hasNonEmptyOutput = false;
for (final ItemStack i : out) {
tagOut.add(createItemTag(i));
if (!i.isEmpty()) {
hasNonEmptyOutput = true;
}
}
// Patterns without any outputs are corrupt! Never encode such a pattern.
Preconditions.checkArgument(hasNonEmptyOutput, "cannot encode a pattern that has no output.");
encodedValue.put(EncodedPatternItem.NBT_INGREDIENTS, tagIn);
encodedValue.put(EncodedPatternItem.NBT_PRODUCTS, tagOut);
return encodedValue;
@@ -58,7 +58,8 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
/**
* 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";
@@ -105,8 +106,7 @@ public class FacadeItem extends AEBaseItem implements IFacadeItem, IAlphaPassIte
BlockState blockState = block.getDefaultState();
final boolean areTileEntitiesEnabled = AEConfig.instance().isFeatureEnabled(AEFeature.TILE_ENTITY_FACADES);
ITag<Block> whitelistTag = BlockTags.getCollection().getOrCreate(TAG_WHITELISTED);
final boolean isWhiteListed = block.isIn(whitelistTag);
final boolean isWhiteListed = BLOCK_WHITELIST.contains(block);
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
final BlockState defaultState = block.getDefaultState();
@@ -324,21 +324,21 @@ public class ColorApplicatorItem extends AEBasePoweredItem
return w.setBlockState(pos, newState);
}
if (blk instanceof CableBusBlock && p != null) {
return ((CableBusBlock) blk).recolorBlock(w, pos, side, newColor.dye, p);
}
TileEntity be = w.getTileEntity(pos);
if (be instanceof IColorableTile) {
IColorableTile ct = (IColorableTile) be;
AEColor c = ct.getColor();
if (c != newColor) {
ct.recolourBlock(side, newColor, p);
ct.recolourBlock(side, newColor, null);
return true;
}
return false;
}
if (blk instanceof CableBusBlock && p != null) {
return ((CableBusBlock) blk).recolorBlock(w, pos, side, newColor.dye, p);
}
return false;
}
+1
View File
@@ -176,6 +176,7 @@ public class Grid implements IGrid {
}
gridNode.getGridProxy().gridChanged();
// postEventTo( gridNode, networkChanged );
}
@Override
+1 -2
View File
@@ -327,9 +327,8 @@ public class GridNode implements IGridNode, IPathItem {
@Override
public void setPlayerID(final int playerID) {
if (playerID >= 0 && this.playerID != playerID) {
if (playerID >= 0) {
this.playerID = playerID;
gridProxy.onGridNotification(GridNotification.OWNER_CHANGED);
}
}
+1 -1
View File
@@ -502,7 +502,7 @@ public class EnergyGridCache implements IEnergyGrid {
private void removeRequester(IAEPowerStorage requester) {
Preconditions.checkState(!ongoingInjectOperation,
"Cannot modify energy requesters while energy is being injected.");
this.requesters.remove(requester);
this.requesters.add(requester);
}
private void addProvider(IAEPowerStorage provider) {
+2 -14
View File
@@ -81,16 +81,8 @@ public class SecurityCache implements ISecurityGrid {
private void updateSecurityKey() {
final long lastCode = this.securityKey;
/**
* Placing a security station will propagate the security station's owner to all
* connected grid nodes to prevent the network from not reforming due to
* different owners later.
*/
int newOwner = -1;
if (this.securityProvider.size() == 1) {
ISecurityProvider securityProvider = this.securityProvider.get(0);
this.securityKey = securityProvider.getSecurityKey();
newOwner = securityProvider.getOwner();
this.securityKey = this.securityProvider.get(0).getSecurityKey();
} else {
this.securityKey = -1;
}
@@ -98,11 +90,7 @@ public class SecurityCache implements ISecurityGrid {
if (lastCode != this.securityKey) {
this.getGrid().postEvent(new MENetworkSecurityChange());
for (final IGridNode n : this.getGrid().getNodes()) {
GridNode gridNode = (GridNode) n;
gridNode.setLastSecurityKey(this.securityKey);
if (gridNode.getPlayerID() != newOwner) {
gridNode.setPlayerID(newOwner);
}
((GridNode) n).setLastSecurityKey(this.securityKey);
}
}
}
@@ -22,6 +22,7 @@ import java.util.Iterator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
@@ -158,16 +159,12 @@ public class QuantumCluster implements ILocatable, IAECluster {
if (qc != null) {
final World theWorld = qc.center.getWorld();
if (!qc.isDestroyed) {
// In future versions, we might actually want to delay the entire registration
// until the center
// tile begins ticking normally.
if (theWorld.isBlockLoaded(qc.center.getPos())) {
ChunkPos cPos = new ChunkPos(qc.center.getPos());
if (theWorld.getChunkProvider().isChunkLoaded(cPos)) {
final World cur = theWorld.getServer().getWorld(theWorld.func_234923_W_());
final TileEntity te = theWorld.getTileEntity(qc.center.getPos());
return te != qc.center || theWorld != cur;
} else {
AELog.warn("Found a registered QNB with serial %s whose chunk seems to be unloaded: %s", qe, qc);
}
}
}
@@ -278,17 +275,4 @@ public class QuantumCluster implements ILocatable, IAECluster {
private void setRing(final QuantumBridgeTileEntity[] ring) {
this.Ring = ring;
}
@Override
public String toString() {
if (center == null) {
return "QuantumCluster{no-center}";
}
World world = center.getWorld();
BlockPos pos = center.getPos();
return "QuantumCluster{" + world + "," + pos + "}";
}
}
@@ -167,6 +167,7 @@ public class AENetworkProxy implements IGridBlock {
* short cut!
*
* @return grid of node
*
* @throws GridAccessException of node or grid is null
*/
public IGrid getGrid() throws GridAccessException {
@@ -279,11 +280,6 @@ public class AENetworkProxy implements IGridBlock {
@Override
public void onGridNotification(final GridNotification notification) {
if (notification == GridNotification.OWNER_CHANGED) {
gp.saveChanges();
return;
}
if (this.gp instanceof CablePart) {
((CablePart) this.gp).markForUpdate();
}
@@ -28,7 +28,4 @@ public interface IGridProxyable extends IGridHost {
DimensionalCoord getLocation();
void gridChanged();
void saveChanges();
}
@@ -1,15 +0,0 @@
package appeng.mixins;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.server.ChunkManager;
@Mixin(ChunkManager.class)
public interface ThreadedAnvilChunkStorageAccessor {
@Accessor("field_219266_t")
IChunkStatusListener getWorldGenerationProgressListener();
}
@@ -0,0 +1,19 @@
package appeng.mixins.feature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Features;
import net.minecraft.world.gen.feature.IFeatureConfig;
@Mixin(Features.class)
public interface ConfiguredFeaturesAccessor {
@Invoker("func_243968_a")
static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String id,
ConfiguredFeature<FC, ?> configuredFeature) {
throw new AssertionError();
}
}
@@ -0,0 +1,27 @@
package appeng.mixins.spatial;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.biome.BiomeRegistry;
import appeng.spatial.SpatialStorageBiome;
import appeng.spatial.SpatialStorageDimensionIds;
/**
* This only needs to be here because the server-side will create a dynamic
* registry manager long before our mod is initialized.
*/
@Mixin(BiomeRegistry.class)
public class BiomesMixin {
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void registerBiomes(CallbackInfo ci) {
WorldGenRegistries.func_243664_a(WorldGenRegistries.field_243657_i,
SpatialStorageDimensionIds.BIOME_KEY.func_240901_a_(), SpatialStorageBiome.INSTANCE);
}
}
@@ -35,4 +35,4 @@ public class DimensionOptionMixin {
return dimensions;
}
}
}
@@ -2,15 +2,25 @@ package appeng.mixins.spatial;
import java.util.OptionalLong;
import com.mojang.serialization.Lifecycle;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.server.IDynamicRegistries;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.DynamicRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.world.Dimension;
import net.minecraft.world.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.DimensionSettings;
import appeng.spatial.SpatialStorageChunkGenerator;
import appeng.spatial.SpatialStorageDimensionIds;
/**
@@ -21,12 +31,37 @@ import appeng.spatial.SpatialStorageDimensionIds;
@Mixin(value = DimensionType.class)
public class DimensionTypeMixin {
@Inject(method = "func_236027_a_", at = @At("TAIL"))
private static void addRegistryDefaults(IDynamicRegistries.Impl registryTracker, CallbackInfoReturnable<?> cir) {
@Invoker("<init>")
static DimensionType create(OptionalLong fixedTime, boolean hasSkylight, boolean hasCeiling, boolean ultrawarm,
boolean natural, double coordinateScale, boolean piglinSafe, boolean bedWorks, boolean respawnAnchorWorks,
boolean hasRaids, int logicalHeight, ResourceLocation infiniburn, ResourceLocation skyProperties,
float ambientLight) {
throw new AssertionError();
}
registryTracker.func_239774_a_(SpatialStorageDimensionIds.DIMENSION_TYPE_ID,
new DimensionType(OptionalLong.of(12000), false, false, false, false, false, false, true, false, false,
256, BlockTags.INFINIBURN_OVERWORLD.getName(), 1.0f));
@Inject(method = "func_236027_a_", at = @At("TAIL"))
private static void addRegistryDefaults(DynamicRegistries.Impl registryTracker, CallbackInfoReturnable<?> cir) {
DimensionType dimensionType = create(OptionalLong.of(12000), false, false, false, false, 1.0, false, false,
false, false, 256, BlockTags.INFINIBURN_OVERWORLD.getName(),
SpatialStorageDimensionIds.SKY_PROPERTIES_ID, 1.0f);
Registry.register(registryTracker.func_230520_a_(),
SpatialStorageDimensionIds.DIMENSION_TYPE_ID.func_240901_a_(), dimensionType);
}
/**
* Insert our custom dimension into the initial registry. <em>This is what will
* ultimately lead to the creation of a new World.</em>
*/
@Inject(method = "func_242718_a", at = @At("RETURN"))
private static void buildDimensionRegistry(Registry<DimensionType> dimensionTypes, Registry<Biome> biomes,
Registry<DimensionSettings> dimensionSettings, long seed,
CallbackInfoReturnable<SimpleRegistry<Dimension>> cir) {
SimpleRegistry<Dimension> simpleregistry = cir.getReturnValue();
simpleregistry.register(SpatialStorageDimensionIds.DIMENSION_ID, new Dimension(() -> {
return dimensionTypes.func_243576_d(SpatialStorageDimensionIds.DIMENSION_TYPE_ID);
}, new SpatialStorageChunkGenerator(biomes)), Lifecycle.stable());
}
@@ -0,0 +1,33 @@
package appeng.mixins.spatial;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.PortalInfo;
import net.minecraft.entity.Entity;
import net.minecraft.world.server.ServerWorld;
import appeng.spatial.SpatialStorageDimensionIds;
import appeng.spatial.SpatialStorageHelper;
/**
* This mixin sets the teleport destination, because otherwise Vanilla will not
* move the player.
*/
@Mixin(Entity.class)
public class EntityMixin {
@Inject(method = "func_241829_a", at = @At("HEAD"), cancellable = true, allow = 1)
public void getTeleportTarget(ServerWorld destination, CallbackInfoReturnable<PortalInfo> cri) {
// Check if a destination has been set for the entity currently being teleported
if (destination.func_234923_W_() == SpatialStorageDimensionIds.WORLD_ID) {
PortalInfo target = SpatialStorageHelper.getInstance().getTeleportTarget();
if (target != null) {
cri.setReturnValue(target);
}
}
}
}
@@ -1,15 +1,15 @@
package appeng.mixins.spatial;
import java.util.Optional;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.world.DimensionRenderInfo;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.DimensionType;
import net.minecraft.util.ResourceLocation;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import appeng.spatial.SpatialStorageDimensionIds;
import appeng.spatial.SpatialStorageSkyProperties;
@@ -17,12 +17,12 @@ import appeng.spatial.SpatialStorageSkyProperties;
@Mixin(DimensionRenderInfo.class)
public class SkyPropertiesMixin {
@Inject(method = "func_239215_a_", at = @At("HEAD"), cancellable = true)
private static void byDimensionType(Optional<RegistryKey<DimensionType>> optional,
CallbackInfoReturnable<DimensionRenderInfo> ci) {
if (optional.orElse(null) == SpatialStorageDimensionIds.DIMENSION_TYPE_ID) {
ci.setReturnValue(SpatialStorageSkyProperties.INSTANCE);
}
@Shadow
private static Object2ObjectMap<ResourceLocation, DimensionRenderInfo> field_239208_a_/* BY_IDENTIFIER */;
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void init(CallbackInfo ci) {
field_239208_a_.put(SpatialStorageDimensionIds.SKY_PROPERTIES_ID, SpatialStorageSkyProperties.INSTANCE);
}
}
@@ -23,7 +23,7 @@ public class SkyRenderMixin {
@SuppressWarnings("ConstantConditions")
@Inject(method = "renderSky(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V", at = @At("HEAD"), cancellable = true)
public void renderSky(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
if (mc.world.func_234922_V_() == SpatialStorageDimensionIds.DIMENSION_TYPE_ID) {
if (mc.world.func_234923_W_() == SpatialStorageDimensionIds.WORLD_ID) {
SpatialSkyRender.getInstance().render(matrices);
ci.cancel();
}
@@ -0,0 +1,26 @@
package appeng.mixins.structure;
import java.util.List;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.structure.Structure;
/**
* Allows access to the copy of _all_ structures that is maintained within each
* instance of {@link Biome}, in order to add our new structure to it. Note that
* this does not mean the structure will start _generating_ in this biome, it
* will only continue to generate if an adjacent biome has started the structure
* and it extends into this one.
*/
@Mixin(Biome.class)
public interface BiomeAccessor {
@Accessor
Map<Integer, List<Structure<?>>> getField_242421_g();
}
@@ -0,0 +1,20 @@
package appeng.mixins.structure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.feature.structure.StructureFeatures;
@Mixin(StructureFeatures.class)
public interface ConfiguredStructureFeaturesAccessor {
@Invoker("func_244162_a")
static <FC extends IFeatureConfig, F extends Structure<FC>> StructureFeature<FC, F> register(String id,
StructureFeature<FC, F> configuredStructureFeature) {
throw new AssertionError();
}
}
@@ -1,4 +1,4 @@
package appeng.mixins;
package appeng.mixins.structure;
import com.google.common.collect.ImmutableMap;
@@ -0,0 +1,31 @@
package appeng.mixins.structure;
import java.util.List;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.BiomeGenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.StructureFeature;
/**
* Allows the settings in a Biome's generation settings to be modified.
*/
@Mixin(BiomeGenerationSettings.class)
public interface GenerationSettingsAccessor {
@Accessor("field_242484_f")
List<List<Supplier<ConfiguredFeature<?, ?>>>> getFeatures();
@Accessor("field_242484_f")
void setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
@Accessor("field_242485_g")
List<Supplier<StructureFeature<?, ?>>> getStructureFeatures();
@Accessor("field_242485_g")
void setStructureFeatures(List<Supplier<StructureFeature<?, ?>>> structureFeatures);
}
@@ -1,4 +1,4 @@
package appeng.mixins;
package appeng.mixins.structure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@@ -7,10 +7,10 @@ import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.structure.Structure;
@Mixin(Structure.class)
public interface StructureAccessor {
public interface StructureFeatureAccessor {
@Invoker("func_236394_a_")
static <F extends Structure<?>> F register(String id, F feature, GenerationStage.Decoration defaultStage) {
static <F extends Structure<?>> F register(String id, F structureFeature, GenerationStage.Decoration step) {
throw new AssertionError();
}
@@ -41,6 +41,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
@@ -81,6 +82,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
private final EnumSet<LayerFlags> myLayerFlags = EnumSet.noneOf(LayerFlags.class);
private YesNo hasRedstone = YesNo.UNDECIDED;
private IPartHost tcb;
// TODO 1.10.2-R - does somebody seriously want to make parts TESR??? Hope not.
private boolean requiresDynamicRender = false;
private boolean inWorld = false;
// Cached collision shape for living entities
@@ -123,7 +125,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
@Override
public IFacadeContainer getFacadeContainer() {
return new FacadeContainer(this, this::invalidateShapes);
return new FacadeContainer(this);
}
@Override
@@ -1094,7 +1096,11 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
}
}
return VoxelShapeCache.get(boxes);
VoxelShape shape = VoxelShapes.empty();
for (final AxisAlignedBB bx : boxes) {
shape = VoxelShapes.or(shape, VoxelShapes.create(bx));
}
return shape;
}
private void invalidateShapes() {
@@ -1,81 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts;
import java.util.List;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
/**
* While creation of a {@link VoxelShape} with
* {@link VoxelShapes#create(AxisAlignedBB)} is fast enough, combining voxel
* shapes with {@link VoxelShapes#or(VoxelShape, VoxelShape)} or any other
* combination method, as well as {@link VoxelShape#simplify()} are <b>extremely
* slow</b>. For example: Creating a VoxelShape for a list of 5 bounding boxes
* 10,000 times takes about 1.7 seconds.
*
* <p>
* To reduce the impact of this on cables, we introduce a global voxel shape
* cache so that cables can share their combined voxel shapes better.
*/
final class VoxelShapeCache {
// Why using a List here should not make much of a difference vs. using a Set:
// The part's bounding box depends on the side it is attached to, and the sides
// are iterated over in a fixed order, meaning the order of bounding boxes
// should
// be the same for a same set of parts.
private static final LoadingCache<List<AxisAlignedBB>, VoxelShape> CACHE = CacheBuilder.newBuilder()//
.maximumSize(10000L)//
.build(new CacheLoader<List<AxisAlignedBB>, VoxelShape>() {
@Override
public VoxelShape load(List<AxisAlignedBB> key) {
return create(key);
}
});
private VoxelShapeCache() {
}
public static VoxelShape get(List<AxisAlignedBB> boxes) {
return CACHE.getUnchecked(boxes);
}
private static VoxelShape create(List<AxisAlignedBB> boxes) {
if (boxes.isEmpty()) {
return VoxelShapes.empty();
}
int i = 0;
VoxelShape shape = VoxelShapes.create(boxes.get(i));
for (; i < boxes.size(); i++) {
AxisAlignedBB box = boxes.get(i);
shape = VoxelShapes.combine(shape, VoxelShapes.create(box), IBooleanFunction.OR);
}
return shape.simplify();
}
}
@@ -34,6 +34,7 @@ import net.minecraft.item.Items;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
@@ -82,6 +83,10 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
public static final ResourceLocation TAG_BLACKLIST = new ResourceLocation(AppEng.MOD_ID,
"blacklisted/annihilation_plane");
private static final ITag.INamedTag<Block> BLOCK_BLACKLIST = BlockTags.makeWrapperTag(TAG_BLACKLIST.toString());
private static final ITag.INamedTag<Item> ITEM_BLACKLIST = ItemTags.makeWrapperTag(TAG_BLACKLIST.toString());
private static final PlaneModels MODELS = new PlaneModels("part/annihilation_plane", "part/annihilation_plane_on");
@PartModels
@@ -527,13 +532,11 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
}
public static boolean isBlockBlacklisted(Block b) {
ITag<Block> tag = BlockTags.getCollection().getOrCreate(TAG_BLACKLIST);
return b.isIn(tag);
return BLOCK_BLACKLIST.contains(b);
}
public static boolean isItemBlacklisted(Item i) {
ITag<Item> tag = ItemTags.getCollection().getOrCreate(TAG_BLACKLIST);
return i.isIn(tag);
return ITEM_BLACKLIST.contains(i);
}
}
@@ -379,12 +379,12 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
@Override
public BlockPos getPos() {
return this.rayTraceResult.getPos();
return this.func_242401_i().getPos();
}
@Override
public boolean canPlace() {
return this.world.getBlockState(this.rayTraceResult.getPos()).isReplaceable(this);
return getWorld().getBlockState(this.getPos()).isReplaceable(this);
}
@Override
@@ -110,7 +110,7 @@ public class SpatialStorageCommand implements ISubCommand {
}
}
throw new CommandException(ITextComponent.func_241827_a_("Couldn't find a plot for the current position."));
throw new CommandException(ITextComponent.func_244388_a("Couldn't find a plot for the current position."));
}
@@ -120,8 +120,7 @@ public class SpatialStorageCommand implements ISubCommand {
private void teleportBack(CommandSource source, SpatialStoragePlot plot) {
TransitionInfo lastTransition = plot.getLastTransition();
if (lastTransition == null) {
throw new CommandException(
ITextComponent.func_241827_a_("This plot doesn't have a last known transition."));
throw new CommandException(ITextComponent.func_244388_a("This plot doesn't have a last known transition."));
}
String command = getTeleportCommand(lastTransition.getWorldId(), lastTransition.getMin().add(0, 1, 0));
@@ -212,7 +211,7 @@ public class SpatialStorageCommand implements ISubCommand {
if (!(cell.getItem() instanceof SpatialStorageCellItem)) {
throw new CommandException(
ITextComponent.func_241827_a_("Storage cell items don't implement the storage cell interface!"));
ITextComponent.func_244388_a("Storage cell items don't implement the storage cell interface!"));
}
SpatialStorageCellItem spatialCellItem = (SpatialStorageCellItem) cell.getItem();
@@ -321,7 +320,7 @@ public class SpatialStorageCommand implements ISubCommand {
}
}
throw new CommandException(ITextComponent.func_241827_a_("Couldn't find a plot for the current position."));
throw new CommandException(ITextComponent.func_244388_a("Couldn't find a plot for the current position."));
}
}
@@ -172,8 +172,9 @@ public class TestMeteoritesCommand implements ISubCommand {
msg.append(getClickablePosition(world, settings, pos)).append(restOfLine);
// Add a tooltip
String biomeId = world.func_242406_i(pos).map(bk -> bk.func_240901_a_().toString()).orElse("unknown");
ITextComponent tooltip = new StringTextComponent(settings.toString() + "\nBiome: ").deepCopy()
.append(world.getBiome(pos).getDisplayName());
.appendString(biomeId);
msg.modifyStyle(style -> style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
sender.sendFeedback(msg, true);
@@ -31,8 +31,7 @@ import net.minecraft.block.Block;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.IServerWorld;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.event.world.WorldEvent;
@@ -92,18 +91,14 @@ public final class CompassService {
}
}
public void tryUpdateArea(final IWorld w, ChunkPos chunkPos) {
public void tryUpdateArea(final IServerWorld w, ChunkPos chunkPos) {
// If this seems weird: during worldgen, WorldAccess is a specific region, but
// getWorld is
// still the server world. We do need to use the world access to get the chunk
// in question
// though, since during worldgen, it's not comitted to the actual world yet.
World world = w.getWorld();
if (!(world instanceof ServerWorld)) {
return;
}
IChunk chunk = w.getChunk(chunkPos.x, chunkPos.z);
updateArea((ServerWorld) world, chunk);
updateArea(w.getWorld(), chunk);
}
public void updateArea(final ServerWorld w, IChunk chunk) {
@@ -323,7 +323,7 @@ public class CachedPlane {
WorldData.instance().compassData().service().updateArea(this.getWorld(), c);
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits, false);
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits);
world.getChunkProvider().chunkManager.getTrackingPlayers(c.getPos(), false)
.forEach(spe -> spe.connection.sendPacket(cdp));
}
@@ -20,33 +20,25 @@ package appeng.spatial;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeAmbience;
import net.minecraft.world.biome.BiomeGenerationSettings;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* The single biome used within the spatial storage world.
*/
public class SpatialStorageBiome extends Biome {
public class SpatialStorageBiome {
public static final SpatialStorageBiome INSTANCE = new SpatialStorageBiome();
public SpatialStorageBiome() {
super(new Biome.Builder()
.surfaceBuilder(
new ConfiguredSurfaceBuilder<>(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG))
.precipitation(RainType.NONE).category(Category.NONE).depth(0).scale(1)
// Copied from the vanilla void biome
.temperature(0.5F).downfall(0.5F).func_235097_a_(new BiomeAmbience.Builder().setWaterColor(4159204)
.setWaterFogColor(329011).setFogColor(0).build())
.parent(null));
}
@Override
@OnlyIn(Dist.CLIENT)
public int getSkyColor() {
return 0x111111;
}
public static final Biome INSTANCE = new Biome.Builder()
.func_242457_a(new BiomeGenerationSettings.Builder().func_242517_a(
new ConfiguredSurfaceBuilder<>(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG))
.func_242508_a())
.precipitation(Biome.RainType.NONE).category(Biome.Category.NONE).depth(0).scale(1)
// Copied from the vanilla void biome
.temperature(0.5F).downfall(0.5F)
.func_235097_a_(new BiomeAmbience.Builder().setWaterColor(4159204).setWaterFogColor(329011).setFogColor(0)
.func_242539_d(0x111111).build())
.func_242458_a(new MobSpawnInfo.Builder().func_242572_a(0).func_242577_b()).func_242455_a();
}
@@ -23,15 +23,16 @@ import java.util.Collections;
import java.util.Optional;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryLookupCodec;
import net.minecraft.world.Blockreader;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeManager;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.biome.provider.SingleBiomeProvider;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.ChunkGenerator;
@@ -48,18 +49,28 @@ import appeng.core.Api;
*/
public class SpatialStorageChunkGenerator extends ChunkGenerator {
/**
* This codec is necessary to restore the actual instance of the Biome we use,
* since it is sources from the dynamic registries and <em>must be the same
* object as in the registry!</em>.
* <p>
* If it was not the same object, then the Object->ID lookup would fail since it
* uses an identity hashmap internally.
*/
public static final Codec<SpatialStorageChunkGenerator> CODEC = RegistryLookupCodec
.func_244331_a(Registry.BIOME_KEY)
.xmap(SpatialStorageChunkGenerator::new, SpatialStorageChunkGenerator::getBiomeRegistry).stable().codec();
private final Registry<Biome> biomeRegistry;
private final Blockreader columnSample;
public static final SpatialStorageChunkGenerator INSTANCE = new SpatialStorageChunkGenerator();
public static final Codec<SpatialStorageChunkGenerator> CODEC = RecordCodecBuilder
.create((instance) -> instance.stable(INSTANCE));
private final BlockState defaultBlockState;
private SpatialStorageChunkGenerator() {
super(createBiomeProvider(), createSettings());
public SpatialStorageChunkGenerator(Registry<Biome> biomeRegistry) {
super(createBiomeSource(biomeRegistry), createSettings());
this.defaultBlockState = Api.instance().definitions().blocks().matrixFrame().block().getDefaultState();
this.biomeRegistry = biomeRegistry;
// Vertical sample is mostly used for Feature generation, for those purposes
// we're all filled with matrix blocks
@@ -73,8 +84,13 @@ public class SpatialStorageChunkGenerator extends ChunkGenerator {
return CODEC;
}
private static BiomeProvider createBiomeProvider() {
return new SingleBiomeProvider(SpatialStorageBiome.INSTANCE);
private static SingleBiomeProvider createBiomeSource(Registry<Biome> biomeRegistry) {
return new SingleBiomeProvider(
biomeRegistry.func_243576_d/* getOrThrow */(SpatialStorageDimensionIds.BIOME_KEY));
}
public Registry<Biome> getBiomeRegistry() {
return biomeRegistry;
}
private static DimensionStructuresSettings createSettings() {
@@ -6,6 +6,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.Dimension;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import appeng.core.AppEng;
import appeng.mixins.spatial.DimensionTypeMixin;
@@ -33,13 +34,13 @@ public final class SpatialStorageDimensionIds {
* ID of the {@link net.minecraft.world.biome.Biome} used for the spatial
* storage world.
*/
public static final ResourceLocation BIOME_ID = AppEng.makeId("spatial_storage");
public static final RegistryKey<Biome> BIOME_KEY = RegistryKey.func_240903_a_(Registry.BIOME_KEY,
AppEng.makeId("spatial_storage"));
/**
* ID of the {@link Dimension} used for the spatial storage dimension.
* <p>
* This is defined in
* <code>data/minecraft/dimension/appliedenergistics2/spatial_storage.json</code>
* This is defined in {@link appeng.mixins.spatial.DimensionTypeMixin}.
*/
public static final RegistryKey<Dimension> DIMENSION_ID = RegistryKey.func_240903_a_(Registry.DIMENSION_KEY,
AppEng.makeId("spatial_storage"));
@@ -51,6 +52,12 @@ public final class SpatialStorageDimensionIds {
public static final RegistryKey<World> WORLD_ID = RegistryKey.func_240903_a_(Registry.WORLD_KEY,
AppEng.makeId("spatial_storage"));
/**
* ID of the {@link net.minecraft.client.world.DimensionRenderInfo} used for the
* spatial storage world.
*/
public static ResourceLocation SKY_PROPERTIES_ID = AppEng.makeId("spatial_storage");
private SpatialStorageDimensionIds() {
}
@@ -25,11 +25,13 @@ import java.util.function.Function;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PortalInfo;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.server.ServerWorld;
@@ -50,6 +52,16 @@ public class SpatialStorageHelper {
return instance;
}
private final ThreadLocal<PortalInfo> teleportTarget = new ThreadLocal<>();
/**
* If an entity is currently being teleported, this will return the target
* within the target dimension.
*/
public PortalInfo getTeleportTarget() {
return teleportTarget.get();
}
/**
* Mostly from dimensional doors.. which mostly got it form X-Comp.
*
@@ -97,12 +109,25 @@ public class SpatialStorageHelper {
newWorld.getChunkProvider().getChunk(MathHelper.floor(link.x) >> 4, MathHelper.floor(link.z) >> 4,
ChunkStatus.FULL, true);
if (entity instanceof ServerPlayerEntity
&& link.dim.func_234922_V_() == SpatialStorageDimensionIds.DIMENSION_TYPE_ID) {
if (entity instanceof ServerPlayerEntity && link.dim.func_234923_W_() == SpatialStorageDimensionIds.WORLD_ID) {
AppEng.instance().getAdvancementTriggers().getSpatialExplorer().trigger((ServerPlayerEntity) entity);
}
entity.changeDimension(link.dim, new METeleporter(link));
// Store in a threadlocal so that EntityMixin can return it for the Vanilla
// logic to use
teleportTarget.set(new PortalInfo(new Vector3d(link.x, link.y, link.z), Vector3d.ZERO, entity.rotationYaw,
entity.rotationPitch));
try {
entity = entity.changeDimension(link.dim, new ITeleporter() {
@Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw,
Function<Boolean, Entity> repositionEntity) {
return repositionEntity.apply(false);
}
});
} finally {
teleportTarget.remove();
}
if (!passengersOnOtherSide.isEmpty()) {
for (Entity passanger : passengersOnOtherSide) {
@@ -238,22 +263,4 @@ public class SpatialStorageHelper {
}
}
private static class METeleporter implements ITeleporter {
private final TelDestination destination;
METeleporter(final TelDestination d) {
this.destination = d;
}
@Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw,
Function<Boolean, Entity> repositionEntity) {
Entity newEntity = repositionEntity.apply(false);
newEntity.rotationYaw = yaw;
newEntity.setPositionAndUpdate(this.destination.x, this.destination.y, this.destination.z);
newEntity.setMotion(0, 0, 0);
return newEntity;
}
}
}
@@ -39,13 +39,10 @@ import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.items.IItemHandler;
@@ -256,11 +253,9 @@ public class AEBaseTileEntity extends TileEntity implements IOrientable, ICommon
if (this.renderFragment > 0) {
this.renderFragment |= 1;
} else {
// Clearing the cached model-data is always harmless regardless of status
this.requestModelDataUpdate();
// TODO: Optimize Network Load
if (this.world != null && !this.isRemoved() && !notLoaded()) {
if (this.world != null) {
this.requestModelDataUpdate();
boolean alreadyUpdated = false;
// Let the block update it's own state with our internal state changes
@@ -309,7 +304,6 @@ public class AEBaseTileEntity extends TileEntity implements IOrientable, ICommon
this.up = inUp;
this.markForUpdate();
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
this.saveChanges();
}
public void onPlacement(BlockItemUseContext context) {
@@ -373,6 +367,7 @@ public class AEBaseTileEntity extends TileEntity implements IOrientable, ICommon
* null means nothing to store...
*
* @param from source of settings
*
* @return compound of source
*/
public CompoundNBT downloadSettings(final SettingsFrom from) {
@@ -461,15 +456,4 @@ public class AEBaseTileEntity extends TileEntity implements IOrientable, ICommon
return new AEModelData(up, forward);
}
/**
* AE Tile Entities will generally confine themselves to rendering within the
* bounding block. Forge however would retrieve the collision box here, which is
* very expensive.
*/
@OnlyIn(Dist.CLIENT)
@Override
public AxisAlignedBB getRenderBoundingBox() {
return new AxisAlignedBB(pos, pos.add(1, 1, 1));
}
}
@@ -80,10 +80,6 @@ public abstract class AENetworkInvTileEntity extends AEBaseInvTileEntity impleme
@Override
public void remove() {
super.remove();
// if the cached block state is not current, the following method may call
// markForUpdate
// and cause the block state to be changed back to non-air
updateContainingBlockInfo();
this.getProxy().remove();
}
@@ -125,7 +125,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
buffer.writeBoolean(this.isCraftable());
buffer.writeVarLong(this.getStackSize());
buffer.writeVarLong(this.getCountRequestable());
buffer.writeItemStack(getDefinition(), false);
buffer.writeItemStack(getDefinition());
}
@Override
@@ -29,7 +29,6 @@ import net.minecraft.nbt.CompoundNBT;
import appeng.api.config.FuzzyMode;
final class AESharedItemStack implements Comparable<AESharedItemStack> {
private final ItemStack itemStack;
private final int itemId;
private final int itemDamage;
@@ -98,8 +97,7 @@ final class AESharedItemStack implements Comparable<AESharedItemStack> {
return damageValue;
}
return System.identityHashCode(this.getDefinition().getTag())
- System.identityHashCode(b.getDefinition().getTag());
return 0;
}
private int makeHashCode() {
@@ -185,5 +183,4 @@ final class AESharedItemStack implements Comparable<AESharedItemStack> {
}
}
}
@@ -0,0 +1,66 @@
package appeng.worldgen;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import com.google.common.collect.Lists;
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.StructureFeature;
import net.minecraft.world.gen.feature.structure.Structure;
import appeng.mixins.structure.BiomeAccessor;
import appeng.mixins.structure.GenerationSettingsAccessor;
public final class BiomeModifier {
private final BiomeAccessor biomeAccessor;
private final GenerationSettingsAccessor generationSettingsAccessor;
@SuppressWarnings("ConstantConditions")
public BiomeModifier(Biome biome) {
this.biomeAccessor = (BiomeAccessor) (Object) biome;
this.generationSettingsAccessor = (GenerationSettingsAccessor) biome.func_242440_e();
}
public void addFeature(GenerationStage.Decoration step, ConfiguredFeature<?, ?> feature) {
int stepIndex = step.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> featuresByStep = new ArrayList<>(
generationSettingsAccessor.getFeatures());
while (featuresByStep.size() <= stepIndex) {
featuresByStep.add(Lists.newArrayList());
}
List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(featuresByStep.get(stepIndex));
features.add(() -> feature);
featuresByStep.set(stepIndex, features);
generationSettingsAccessor.setFeatures(featuresByStep);
}
public void addStructureFeature(StructureFeature<?, ?> structure) {
List<Supplier<StructureFeature<?, ?>>> features = new ArrayList<>(
generationSettingsAccessor.getStructureFeatures());
features.add(() -> structure);
generationSettingsAccessor.setStructureFeatures(features);
// Add it to the structures that will generate pieces within this biome,
// this is only half-correct since a structure can start in an adjacent biome
// and extend into biomes that would usually not start the structure
Map<Integer, List<Structure<?>>> structuresByStage = biomeAccessor.getField_242421_g();
int step = structure.field_236268_b_.func_236396_f_().ordinal();
if (!structuresByStage.containsKey(step)) {
structuresByStage.put(step, new ArrayList<>());
}
structuresByStage.get(step).add(structure.field_236268_b_);
}
}
@@ -15,7 +15,7 @@ public class ChargedQuartzOreConfig implements IFeatureConfig {
public static final Codec<ChargedQuartzOreConfig> CODEC = RecordCodecBuilder.create((instance) -> instance
.group(BlockState.BLOCKSTATE_CODEC.fieldOf("target").forGetter((config) -> config.target),
BlockState.BLOCKSTATE_CODEC.fieldOf("state").forGetter((config) -> config.state),
Codec.FLOAT.fieldOf("chance").withDefault(0f).forGetter((config) -> config.chance))
Codec.FLOAT.fieldOf("chance").orElse(0f).forGetter((config) -> config.chance))
.apply(instance, ChargedQuartzOreConfig::new));
public final BlockState target;
@@ -11,7 +11,6 @@ import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.structure.StructureManager;
/**
* Extends {@link net.minecraft.world.gen.feature.OreFeature} by also allowing
@@ -27,8 +26,8 @@ public class ChargedQuartzOreFeature extends Feature<ChargedQuartzOreConfig> {
}
@Override
public boolean func_230362_a_(ISeedReader worldIn, StructureManager structureAccessor, ChunkGenerator generator,
Random rand, BlockPos pos, ChargedQuartzOreConfig config) {
public boolean func_241855_a(ISeedReader worldIn, ChunkGenerator generator, Random rand, BlockPos pos,
ChargedQuartzOreConfig config) {
ChunkPos chunkPos = new ChunkPos(pos);
BlockPos.Mutable bpos = new BlockPos.Mutable();
@@ -9,6 +9,7 @@ import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.structure.Structure;
import appeng.core.AppEng;
@@ -19,6 +20,9 @@ public class MeteoriteStructure extends Structure<NoFeatureConfig> {
public static final Structure<NoFeatureConfig> INSTANCE = new MeteoriteStructure(NoFeatureConfig.field_236558_a_);
public static final StructureFeature<NoFeatureConfig, ? extends Structure<NoFeatureConfig>> CONFIGURED_INSTANCE = INSTANCE
.func_236391_a_(NoFeatureConfig.field_236559_b_);
public MeteoriteStructure(Codec<NoFeatureConfig> configCodec) {
super(configCodec);
}
@@ -36,7 +36,7 @@ import appeng.worldgen.meteorite.fallout.FalloutMode;
public class MeteoriteStructurePiece extends StructurePiece {
public static final IStructurePieceType TYPE = IStructurePieceType.register(MeteoriteStructurePiece::new,
"AE2MTRT");
"ae2mtrt");
public static void register() {
// THIS MUST BE CALLED otherwise the static initializer above will not run,
@@ -12,9 +12,9 @@ import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.registry.DynamicRegistries;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.biome.Biome.TempCategory;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.Heightmap.Type;
@@ -27,17 +27,18 @@ import appeng.worldgen.meteorite.fallout.FalloutMode;
public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
private final ITag<Block> sandTag = BlockTags.getCollection().getOrCreate(new ResourceLocation("minecraft:sand"));
private final ITag<Block> sandTag = BlockTags.getCollection().func_241834_b(new ResourceLocation("minecraft:sand"));
private final ITag<Block> terracottaTag = BlockTags.getCollection()
.getOrCreate(new ResourceLocation("forge:terracotta"));
.func_241834_b(new ResourceLocation("forge:terracotta"));
public MeteoriteStructureStart(Structure<NoFeatureConfig> p_i225815_1_, int p_i225815_2_, int p_i225815_3_,
MutableBoundingBox p_i225815_4_, int p_i225815_5_, long p_i225815_6_) {
super(p_i225815_1_, p_i225815_2_, p_i225815_3_, p_i225815_4_, p_i225815_5_, p_i225815_6_);
}
public void func_230364_a_(ChunkGenerator generator, TemplateManager templateManagerIn, int chunkX, int chunkZ,
Biome biome, NoFeatureConfig config) {
@Override
public void func_230364_a_(DynamicRegistries dynamicRegistryManager, ChunkGenerator generator,
TemplateManager templateManager, int chunkX, int chunkZ, Biome biome, NoFeatureConfig config) {
final int centerX = chunkX * 16 + this.rand.nextInt(16);
final int centerZ = chunkZ * 16 + this.rand.nextInt(16);
final float meteoriteRadius = (this.rand.nextFloat() * 6.0f) + 2;
@@ -75,7 +76,7 @@ public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
boolean craterLake = this.locateWaterAroundTheCrater(generator, actualPos, meteoriteRadius);
CraterType craterType = this.determineCraterType(spawnBiome);
boolean pureCrater = this.rand.nextFloat() > .9f;
FalloutMode fallout = getFalloutFromBaseBlock(spawnBiome.getSurfaceBuilderConfig().getTop());
FalloutMode fallout = getFalloutFromBaseBlock(spawnBiome.func_242440_e().func_242502_e().getTop());
components.add(
new MeteoriteStructurePiece(actualPos, meteoriteRadius, craterType, fallout, pureCrater, craterLake));
@@ -118,7 +119,9 @@ public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
}
private CraterType determineCraterType(Biome biome) {
final TempCategory temp = biome.getTempCategory();
// The temperature thresholds below are taken from older Vanilla code
// (temperature categories)
final float temp = biome.func_242445_k();
final Category category = biome.getCategory();
// No craters in oceans
@@ -135,7 +138,7 @@ public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
}
// Warm biomes, higher chance for lava
if (temp == TempCategory.WARM) {
if (temp >= 1) {
// 50% chance to actually spawn as lava
final boolean lava = rand.nextFloat() > .5f;
@@ -158,7 +161,7 @@ public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
}
// Temperate biomes. Water or maybe lava
if (temp == TempCategory.MEDIUM) {
if (temp < 1 && temp >= 0.2) {
// 75% chance to actually spawn with a crater lake
final boolean lake = rand.nextFloat() > .25f;
// 20% to spawn with lava
@@ -184,7 +187,7 @@ public class MeteoriteStructureStart extends StructureStart<NoFeatureConfig> {
}
// Cold biomes, Snow or Ice, maybe water and very rarely lava.
if (temp == TempCategory.COLD) {
if (temp < 0.2) {
// 75% chance to actually spawn with a crater lake
final boolean lake = rand.nextFloat() > .25f;
// 5% to spawn with lava
@@ -36,7 +36,7 @@ public class FalloutCopy extends Fallout {
public FalloutCopy(final IWorld w, BlockPos pos, final MeteoriteBlockPutter putter, final BlockState skyStone) {
super(putter, skyStone);
this.putter = putter;
this.block = w.getBiome(pos).getSurfaceBuilderConfig().getTop();
this.block = w.getBiome(pos).func_242440_e().func_242502_e().getTop();
}
@Override
+3 -2
View File
@@ -6,6 +6,7 @@ displayURL="https://github.com/AppliedEnergistics/Applied-Energistics-2"
logoFile="logo.png"
#credits="Thanks for this example mod goes to Java"
authors="TeamAppliedEnergistics"
license="See GitHub repository for details"
[[mods]]
modId="appliedenergistics2"
@@ -16,13 +17,13 @@ description="A Mod about Matter, Energy and using them to conquer the world.."
[[dependencies.appliedenergistics2]]
modId="forge"
mandatory=true
versionRange="[32.0.108,33.0.0)"
versionRange="[33.0.5,34.0.0)"
ordering="NONE"
side="BOTH"
[[dependencies.appliedenergistics2]]
modId="minecraft"
mandatory=true
versionRange="[1.16.1]"
versionRange="[1.16.2]"
ordering="NONE"
side="BOTH"
@@ -7,9 +7,14 @@
"mixins": [
"spatial.DimensionTypeMixin",
"spatial.DimensionOptionMixin",
"ThreadedAnvilChunkStorageAccessor",
"DimensionStructuresSettingsMixin",
"StructureAccessor"
"spatial.EntityMixin",
"spatial.BiomesMixin",
"structure.DimensionStructuresSettingsMixin",
"structure.ConfiguredStructureFeaturesAccessor",
"structure.StructureFeatureAccessor",
"structure.GenerationSettingsAccessor",
"structure.BiomeAccessor",
"feature.ConfiguredFeaturesAccessor"
],
"client": [
"spatial.SkyRenderMixin",
@@ -1 +1,3 @@
{}
{
"parent": "appliedenergistics2:block/cable_bus"
}
@@ -1,8 +1,7 @@
{
"display": {
"icon": {
"item": "appliedenergistics2:facade",
"nbt": "{item:\"minecraft:stone\"}"
"item": "appliedenergistics2:facade"
},
"title": {
"translate": "achievement.ae2.Facade"
@@ -1,6 +0,0 @@
{
"type": "appliedenergistics2:spatial_storage",
"generator": {
"type": "appliedenergistics2:spatial_storage"
}
}

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