Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1713f1682 | |||
| f455fd1994 | |||
| 1657c88681 | |||
| fd67e0e5c6 | |||
| 87c2c94bd4 | |||
| d591a1492c | |||
| d1ba26311b | |||
| 8733c2c11f | |||
| 4230fc7325 | |||
| 484af8baf3 | |||
| 9456f639d4 | |||
| fe753c540b | |||
| 2fabab3a6a | |||
| 6f39bd8fe8 | |||
| c7d3877129 |
+5
-4
@@ -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.93
|
||||
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
|
||||
|
||||
#########################################################
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
package appeng.api.config;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represent the security systems basic permissions, these are not for
|
||||
* anti-griefing, they are part of the mod as a gameplay feature.
|
||||
@@ -58,7 +60,7 @@ public enum SecurityPermissions {
|
||||
*/
|
||||
SECURITY;
|
||||
|
||||
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase();
|
||||
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase(Locale.ROOT);
|
||||
|
||||
public String getTranslatedName() {
|
||||
return this.translationKey + ".name";
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.implementations;
|
||||
|
||||
/**
|
||||
* Defines the result of performing a transition from the world into a storage
|
||||
* cell, if its possible, and what the energy usage is.
|
||||
*/
|
||||
public class TransitionResult {
|
||||
public final boolean success;
|
||||
public final double energyUsage;
|
||||
|
||||
public TransitionResult(final boolean success, final double power) {
|
||||
this.success = success;
|
||||
this.energyUsage = power;
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,8 @@ package appeng.api.implementations.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.util.WorldCoord;
|
||||
|
||||
/**
|
||||
@@ -52,13 +49,13 @@ public interface ISpatialStorageCell {
|
||||
int getMaxStoredDim(ItemStack is);
|
||||
|
||||
/**
|
||||
* get the currently stored Dimension id.
|
||||
* get the currently stored spatial storage plot id.
|
||||
*
|
||||
* @param is spatial storage cell
|
||||
*
|
||||
* @return dimension id or -1
|
||||
* @return plot id or -1
|
||||
*/
|
||||
RegistryKey<World> getStoredDimension(ItemStack is);
|
||||
int getAllocatedPlotId(ItemStack is);
|
||||
|
||||
/**
|
||||
* Perform a spatial swap with the contents of the cell, and the world.
|
||||
@@ -69,7 +66,7 @@ public interface ISpatialStorageCell {
|
||||
* @param max max coord
|
||||
* @param playerId owner of current grid or -1
|
||||
*
|
||||
* @return result of transition
|
||||
* @return success of transition
|
||||
*/
|
||||
TransitionResult doSpatialTransition(ItemStack is, ServerWorld w, WorldCoord min, WorldCoord max, int playerId);
|
||||
boolean doSpatialTransition(ItemStack is, ServerWorld w, WorldCoord min, WorldCoord max, int playerId);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public interface ISpatialDimension {
|
||||
ServerWorld getWorld(RegistryKey<World> cellDim);
|
||||
|
||||
@Nullable
|
||||
RegistryKey<World> createNewCellDimension(BlockPos capacity);
|
||||
|
||||
void deleteCellDimension(RegistryKey<World> cellDim);
|
||||
|
||||
boolean isCellDimension(RegistryKey<World> cellDim);
|
||||
|
||||
BlockPos getCellDimensionOrigin(RegistryKey<World> cellDim);
|
||||
|
||||
BlockPos getCellDimensionSize(RegistryKey<World> cellDim);
|
||||
|
||||
/**
|
||||
* Adds a user-facing tooltip that describes this dimension so that a player can
|
||||
* keep storage cells apart.
|
||||
*/
|
||||
void addCellDimensionTooltip(RegistryKey<World> cellDim, List<ITextComponent> lines);
|
||||
|
||||
}
|
||||
@@ -27,13 +27,14 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,8 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.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()) {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -51,7 +53,7 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return this.name().toLowerCase();
|
||||
return this.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,10 @@ import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.dispenser.IDispenseItemBehavior;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlockItemChargeable;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.core.AEItemGroup;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
package appeng.client;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public enum ActionKey {
|
||||
@@ -13,7 +15,7 @@ public enum ActionKey {
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
return "key." + this.name().toLowerCase() + ".desc";
|
||||
return "key." + this.name().toLowerCase(Locale.ROOT) + ".desc";
|
||||
}
|
||||
|
||||
public int getDefaultKey() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
@@ -24,7 +26,7 @@ import appeng.core.AEConfig;
|
||||
public class NumberEntryWidget implements ITickingWidget {
|
||||
|
||||
private static final ITextComponent PLUS = new StringTextComponent("+");
|
||||
private static final ITextComponent MINUS = new StringTextComponent("+");
|
||||
private static final ITextComponent MINUS = new StringTextComponent("-");
|
||||
|
||||
private final AEBaseScreen<?> parent;
|
||||
|
||||
@@ -33,14 +35,7 @@ public class NumberEntryWidget implements ITickingWidget {
|
||||
|
||||
private final NumberBox level;
|
||||
private final NumberEntryType type;
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
private List<Button> buttons;
|
||||
|
||||
public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, NumberEntryType type,
|
||||
LongConsumer changeListener) {
|
||||
@@ -63,14 +58,7 @@ public class NumberEntryWidget implements ITickingWidget {
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.level.setEnabled(active);
|
||||
this.plus1.active = active;
|
||||
this.plus10.active = active;
|
||||
this.plus100.active = active;
|
||||
this.plus1000.active = active;
|
||||
this.minus1.active = active;
|
||||
this.minus10.active = active;
|
||||
this.minus100.active = active;
|
||||
this.minus1000.active = active;
|
||||
this.buttons.forEach(b -> b.active = active);
|
||||
}
|
||||
|
||||
public void setTextFieldBounds(int x, int y, int width) {
|
||||
@@ -93,18 +81,23 @@ public class NumberEntryWidget implements ITickingWidget {
|
||||
int left = parent.getGuiLeft() + x;
|
||||
int top = parent.getGuiTop() + y;
|
||||
|
||||
addButton.accept(this.plus1 = new Button(left, top, 22, 20, PLUS /* + a */, btn -> addQty(a)));
|
||||
addButton.accept(this.plus10 = new Button(left + 28, top, 28, 20, PLUS /* + b */, btn -> addQty(b)));
|
||||
addButton.accept(this.plus100 = new Button(left + 62, top, 32, 20, PLUS /* + c */, btn -> addQty(c)));
|
||||
addButton.accept(this.plus1000 = new Button(left + 100, top, 38, 20, PLUS/* + d */, btn -> addQty(d)));
|
||||
List<Button> buttons = new ArrayList<>(8);
|
||||
|
||||
buttons.add(new Button(left, top, 22, 20, makeLabel(PLUS, a), btn -> addQty(a)));
|
||||
buttons.add(new Button(left + 28, top, 28, 20, makeLabel(PLUS, b), btn -> addQty(b)));
|
||||
buttons.add(new Button(left + 62, top, 32, 20, makeLabel(PLUS, c), btn -> addQty(c)));
|
||||
buttons.add(new Button(left + 100, top, 38, 20, makeLabel(PLUS, d), btn -> addQty(d)));
|
||||
|
||||
// Placing this here will give a sensible tab order
|
||||
addChildren.accept(this.level);
|
||||
|
||||
addButton.accept(this.minus1 = new Button(left, top + 42, 22, 20, MINUS /* + a */, btn -> addQty(-a)));
|
||||
addButton.accept(this.minus10 = new Button(left + 28, top + 42, 28, 20, MINUS /* + b */, btn -> addQty(-b)));
|
||||
addButton.accept(this.minus100 = new Button(left + 62, top + 42, 32, 20, MINUS /* + c */, btn -> addQty(-c)));
|
||||
addButton.accept(this.minus1000 = new Button(left + 100, top + 42, 38, 20, MINUS /* + d */, btn -> addQty(-d)));
|
||||
buttons.add(new Button(left, top + 42, 22, 20, makeLabel(MINUS, a), btn -> addQty(-a)));
|
||||
buttons.add(new Button(left + 28, top + 42, 28, 20, makeLabel(MINUS, b), btn -> addQty(-b)));
|
||||
buttons.add(new Button(left + 62, top + 42, 32, 20, makeLabel(MINUS, c), btn -> addQty(-c)));
|
||||
buttons.add(new Button(left + 100, top + 42, 38, 20, makeLabel(MINUS, d), btn -> addQty(-d)));
|
||||
|
||||
this.buttons = buttons;
|
||||
this.buttons.forEach(addButton);
|
||||
}
|
||||
|
||||
private void addQty(final long i) {
|
||||
@@ -134,4 +127,8 @@ public class NumberEntryWidget implements ITickingWidget {
|
||||
this.level.tick();
|
||||
}
|
||||
|
||||
private ITextComponent makeLabel(ITextComponent prefix, int amount) {
|
||||
return prefix.copyRaw().appendString(String.valueOf(amount));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -111,6 +113,6 @@ public enum FacingToRotation implements IStringSerializable {
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
@@ -100,7 +101,7 @@ class CableBuilder {
|
||||
}
|
||||
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, textureFolder + color.name().toLowerCase()));
|
||||
new ResourceLocation(AppEng.MOD_ID, textureFolder + color.name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -74,7 +75,7 @@ public enum CableCoreType {
|
||||
|
||||
public RenderMaterial getTexture(AEColor color) {
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase()));
|
||||
new ResourceLocation(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.render.crafting;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -48,7 +50,7 @@ public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
|
||||
if (typeEl != null) {
|
||||
String typeName = deserializationContext.deserialize(typeEl, String.class);
|
||||
if (typeName != null) {
|
||||
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase());
|
||||
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
if (unitType == null) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class EnergyParticleData implements IParticleData {
|
||||
reader.expect(' ');
|
||||
boolean forItem = reader.readBoolean();
|
||||
reader.expect(' ');
|
||||
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase());
|
||||
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase(Locale.ROOT));
|
||||
return new EnergyParticleData(forItem, direction);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,8 @@ public class EnergyParticleData implements IParticleData {
|
||||
|
||||
@Override
|
||||
public String getParameters() {
|
||||
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false", direction.name().toLowerCase());
|
||||
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false",
|
||||
direction.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
@@ -193,7 +191,7 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
||||
vec.setX(vec.getX() + 0.5f);
|
||||
vec.setY(vec.getY() + 0.5f);
|
||||
vec.setZ(vec.getZ() + 0.5f);
|
||||
return new float[] { vec.getX(), vec.getY(), vec.getZ() };
|
||||
return new float[] { snap(vec.getX()), snap(vec.getY()), snap(vec.getZ()) };
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
||||
vecc.setX(vecc.getX() - 0.5f);
|
||||
@@ -203,13 +201,32 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
||||
vecc.setX(vecc.getX() + 0.5f);
|
||||
vecc.setY(vecc.getY() + 0.5f);
|
||||
vecc.setZ(vecc.getZ() + 0.5f);
|
||||
return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), vecc.getW() };
|
||||
return new float[] { snap(vecc.getX()), snap(vecc.getY()), snap(vecc.getZ()), snap(vecc.getW()) };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the same value used by Vanilla's AO lighter.
|
||||
*/
|
||||
private static final float EPS = 0.0001f;
|
||||
|
||||
/**
|
||||
* This tries to snap the coordinate to the edges of the block frame, because
|
||||
* Vanilla uses direct equals comparisons to 0 and 1 for checking if a face
|
||||
* extends fully towards the edge. This is used primarily for AO calculations.
|
||||
*/
|
||||
private static float snap(float x) {
|
||||
if (Math.abs(x) <= EPS) {
|
||||
return 0f;
|
||||
} else if (Math.abs(x - 1) <= EPS) {
|
||||
return 1f;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private float[] transformNormal(float[] fs) {
|
||||
if (this.face == null) {
|
||||
switch (fs.length) {
|
||||
@@ -220,7 +237,7 @@ public class AutoRotatingBakedModel extends DelegateBakedModel {
|
||||
case 4:
|
||||
Vector4f vec4 = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
|
||||
vec4.transform(this.f2r.getMat());
|
||||
return new float[] { vec4.getX(), vec4.getY(), vec4.getZ(), 0 };
|
||||
return new float[] { snap(vec4.getX()), snap(vec4.getY()), snap(vec4.getZ()), 0 };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BlockFaceUV;
|
||||
import net.minecraft.client.renderer.model.BlockModel;
|
||||
import net.minecraft.client.renderer.model.BlockPart;
|
||||
import net.minecraft.client.renderer.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.RenderMaterial;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraftforge.client.model.IModelBuilder;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
|
||||
public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapper> {
|
||||
|
||||
public static final UVLModelLoader INSTANCE = new UVLModelLoader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UVLModelWrapper read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
modelContents.remove("loader");
|
||||
BlockModel blockModel = UVLSERIALIZER.fromJson(modelContents, BlockModel.class);
|
||||
return new UVLModelWrapper(blockModel);
|
||||
}
|
||||
|
||||
final Gson UVLSERIALIZER = (new GsonBuilder())
|
||||
.registerTypeAdapter(BlockModel.class, new ModelLoaderRegistry.ExpandedBlockModelDeserializer())
|
||||
.registerTypeAdapter(BlockPart.class, new BlockPart.Deserializer())
|
||||
.registerTypeAdapter(BlockPartFace.class, new BlockPartFaceOverrideSerializer())
|
||||
.registerTypeAdapter(BlockFaceUV.class, new BlockFaceUV.Deserializer())
|
||||
.registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer())
|
||||
.registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer())
|
||||
.registerTypeAdapter(ItemOverride.class, new ItemOverride.Deserializer())
|
||||
.registerTypeAdapter(TransformationMatrix.class, new TransformationHelper.Deserializer()).create();
|
||||
|
||||
private static class BlockPartFaceOverrideSerializer extends BlockPartFace.Deserializer {
|
||||
@Override
|
||||
public BlockPartFace deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_,
|
||||
JsonDeserializationContext p_deserialize_3_) throws JsonParseException {
|
||||
BlockPartFace blockFace = super.deserialize(p_deserialize_1_, p_deserialize_2_, p_deserialize_3_);
|
||||
Pair<Float, Float> uvl = this.parseUVL(p_deserialize_1_.getAsJsonObject());
|
||||
if (uvl != null) {
|
||||
return new BlockPartFaceWithUVL(blockFace.cullFace, blockFace.tintIndex, blockFace.texture,
|
||||
blockFace.blockFaceUV, uvl.getLeft(), uvl.getRight());
|
||||
}
|
||||
return blockFace;
|
||||
}
|
||||
|
||||
protected Pair<Float, Float> parseUVL(JsonObject object) {
|
||||
if (!object.has("uvlightmap")) {
|
||||
return null;
|
||||
}
|
||||
object = object.get("uvlightmap").getAsJsonObject();
|
||||
return new ImmutablePair<>(JSONUtils.getFloat(object, "sky", 0), JSONUtils.getFloat(object, "block", 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static class BlockPartFaceWithUVL extends BlockPartFace {
|
||||
|
||||
private final float sky;
|
||||
private final float block;
|
||||
|
||||
public BlockPartFaceWithUVL(@Nullable Direction cullFaceIn, int tintIndexIn, String textureIn,
|
||||
BlockFaceUV blockFaceUVIn, float sky, float block) {
|
||||
super(cullFaceIn, tintIndexIn, textureIn, blockFaceUVIn);
|
||||
this.sky = sky;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public float getSky() {
|
||||
return sky;
|
||||
}
|
||||
|
||||
public float getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UVLModelWrapper implements IModelGeometry<UVLModelWrapper> {
|
||||
private final BlockModel parent;
|
||||
|
||||
public UVLModelWrapper(BlockModel parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
|
||||
|
||||
IModelBuilder<?> builder = IModelBuilder.of(owner, overrides, particle);
|
||||
for (BlockPart blockpart : parent.getElements()) {
|
||||
for (Direction direction : blockpart.mapFaces.keySet()) {
|
||||
BlockPartFace blockpartface = blockpart.mapFaces.get(direction);
|
||||
TextureAtlasSprite textureatlassprite1 = spriteGetter
|
||||
.apply(owner.resolveTexture(blockpartface.texture));
|
||||
BakedQuad quad = BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction,
|
||||
modelTransform, modelLocation);
|
||||
|
||||
if (blockpartface instanceof BlockPartFaceWithUVL) {
|
||||
BlockPartFaceWithUVL uvlFace = (BlockPartFaceWithUVL) blockpartface;
|
||||
quad = applyPreBakedLighting(quad, textureatlassprite1, uvlFace.sky, uvlFace.block);
|
||||
}
|
||||
|
||||
if (blockpartface.cullFace == null) {
|
||||
builder.addGeneralQuad(quad);
|
||||
} else {
|
||||
builder.addFaceQuad(modelTransform.getRotation().rotateTransform(blockpartface.cullFace), quad);
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private BakedQuad applyPreBakedLighting(BakedQuad quad, TextureAtlasSprite sprite, float sky, float block) {
|
||||
// FIXME: just piping through the quads and manipulating uv index 2 directly
|
||||
// seems way easier than this
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder(sprite);
|
||||
VertexLighterFlat trans = new VertexLighterFlat(Minecraft.getInstance().getBlockColors()) {
|
||||
|
||||
@Override
|
||||
protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z) {
|
||||
lightmap[0] = block;
|
||||
lightmap[1] = sky;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadTint(int tint) {
|
||||
// Tint requires a block state which we don't have at this point
|
||||
}
|
||||
};
|
||||
MatrixStack identity = new MatrixStack();
|
||||
trans.setTransform(identity.getLast());
|
||||
trans.setParent(builder);
|
||||
quad.pipe(trans);
|
||||
builder.setQuadTint(quad.getTintIndex());
|
||||
builder.setQuadOrientation(quad.getFace());
|
||||
builder.setApplyDiffuseLighting(false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner,
|
||||
Function<ResourceLocation, IUnbakedModel> modelGetter,
|
||||
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
|
||||
return parent.getTextures(modelGetter, missingTextureErrors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package appeng.client.render.spatial;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
@@ -59,7 +60,7 @@ public class SpatialPylonModel implements BasicUnbakedModel<SpatialPylonModel> {
|
||||
|
||||
private static RenderMaterial getTexturePath(SpatialPylonTextureType type) {
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase()));
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -35,15 +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.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
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;
|
||||
@@ -56,29 +52,10 @@ import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.FacadeItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||
import appeng.client.render.model.BiometricCardModel;
|
||||
import appeng.client.render.model.ColorApplicatorModel;
|
||||
import appeng.client.render.model.DriveModel;
|
||||
import appeng.client.render.model.GlassModel;
|
||||
import appeng.client.render.model.MemoryCardModel;
|
||||
import appeng.client.render.model.SkyCompassModel;
|
||||
import appeng.client.render.model.UVLModelLoader;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
@@ -90,7 +67,6 @@ import appeng.entity.TinyTNTPrimedRenderer;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.parts.automation.PlaneModelLoader;
|
||||
import appeng.server.ServerHelper;
|
||||
|
||||
@Mod(AppEng.MOD_ID)
|
||||
@@ -124,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);
|
||||
@@ -131,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);
|
||||
@@ -152,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);
|
||||
@@ -181,39 +163,6 @@ public final class AppEng {
|
||||
RenderingRegistry.registerEntityRenderingHandler(ChargedQuartzEntity.TYPE,
|
||||
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
|
||||
// TODO: Do not use the internal API
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
||||
.forEachRemaining(IClientSetupComponent::setup);
|
||||
|
||||
addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
addBuiltInModel("facade", FacadeItemModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
||||
EncodedPatternModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
||||
PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"),
|
||||
CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"),
|
||||
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id),
|
||||
new SimpleModelLoader<>(modelFactory));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -32,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;
|
||||
@@ -39,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;
|
||||
@@ -50,7 +52,8 @@ import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -79,7 +82,10 @@ import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||
import appeng.bootstrap.components.IItemColorRegistrationComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
@@ -118,6 +124,13 @@ import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.implementations.VibrationChamberScreen;
|
||||
import appeng.client.gui.implementations.WirelessScreen;
|
||||
import appeng.client.gui.implementations.WirelessTermScreen;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.FacadeItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
import appeng.client.render.effects.CraftingFx;
|
||||
import appeng.client.render.effects.EnergyFx;
|
||||
@@ -126,6 +139,13 @@ import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.effects.MatterCannonFX;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.client.render.effects.VibrantFX;
|
||||
import appeng.client.render.model.BiometricCardModel;
|
||||
import appeng.client.render.model.ColorApplicatorModel;
|
||||
import appeng.client.render.model.DriveModel;
|
||||
import appeng.client.render.model.GlassModel;
|
||||
import appeng.client.render.model.MemoryCardModel;
|
||||
import appeng.client.render.model.SkyCompassModel;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.client.render.tesr.InscriberTESR;
|
||||
import appeng.client.render.tesr.SkyChestTESR;
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -193,21 +213,21 @@ 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;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import appeng.recipes.handlers.GrinderRecipeSerializer;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import appeng.recipes.handlers.InscriberRecipeSerializer;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.spatial.StorageCellBiome;
|
||||
import appeng.spatial.StorageChunkGenerator;
|
||||
import appeng.spatial.SpatialStorageBiome;
|
||||
import appeng.spatial.SpatialStorageChunkGenerator;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.crafting.MolecularAssemblerRenderer;
|
||||
import appeng.worldgen.ChargedQuartzOreConfig;
|
||||
import appeng.worldgen.ChargedQuartzOreFeature;
|
||||
import appeng.worldgen.meteorite.MeteoriteStructure;
|
||||
import appeng.worldgen.meteorite.MeteoriteStructurePiece;
|
||||
|
||||
final class Registration {
|
||||
|
||||
@@ -239,6 +259,39 @@ final class Registration {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void modelRegistryEvent(ModelRegistryEvent event) {
|
||||
registerSpecialModels();
|
||||
|
||||
// TODO: Do not use the internal API
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
||||
.forEachRemaining(IClientSetupComponent::setup);
|
||||
|
||||
addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
addBuiltInModel("facade", FacadeItemModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
||||
EncodedPatternModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
||||
PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"),
|
||||
CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"),
|
||||
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id),
|
||||
new SimpleModelLoader<>(modelFactory));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -628,70 +681,6 @@ final class Registration {
|
||||
new ResourceLocation(dimension));
|
||||
}
|
||||
|
||||
ForgeRegistries.BIOMES.forEach(b -> {
|
||||
addMeteoriteWorldGen(b);
|
||||
addQuartzWorldGen(b);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void addMeteoriteWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
||||
return;
|
||||
}
|
||||
|
||||
b.func_235063_a_(MeteoriteStructure.INSTANCE.func_236391_a_(IFeatureConfig.NO_FEATURE_CONFIG));
|
||||
}
|
||||
|
||||
private static void addQuartzWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockState quartzOre = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
|
||||
Feature.ORE
|
||||
.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
|
||||
quartzOre, AEConfig.instance().getQuartzOresPerCluster()))
|
||||
.withPlacement(Placement.COUNT_RANGE.configure(
|
||||
new CountRangeConfig(AEConfig.instance().getQuartzOresClusterAmount(), 12, 12, 72))));
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
|
||||
BlockState chargedQuartzOre = Api.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
b.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION,
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
.withConfiguration(new ChargedQuartzOreConfig(quartzOre, chargedQuartzOre,
|
||||
AEConfig.instance().getSpawnChargedChance()))
|
||||
.withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void registerFeatures(RegistryEvent.Register<Feature<?>> evt) {
|
||||
IForgeRegistry<Feature<?>> r = evt.getRegistry();
|
||||
|
||||
r.register(ChargedQuartzOreFeature.INSTANCE.setRegistryName(AppEng.makeId("charged_quartz_ore")));
|
||||
}
|
||||
|
||||
public void registerStructures(RegistryEvent.Register<Structure<?>> evt) {
|
||||
// Registering into the Forge registry is INSUFFICIENT!
|
||||
// There's a bidirectional map in the Structure class itself primarily for the
|
||||
// purposes of NBT serialization
|
||||
StructureAccessor.register(MeteoriteStructure.ID.toString(),
|
||||
MeteoriteStructure.INSTANCE.setRegistryName(MeteoriteStructure.ID),
|
||||
GenerationStage.Decoration.TOP_LAYER_MODIFICATION);
|
||||
|
||||
Registry.register(Registry.CHUNK_GENERATOR_CODEC, AppEng.makeId("storage"), StorageChunkGenerator.CODEC);
|
||||
}
|
||||
|
||||
public void registerBiomes(RegistryEvent.Register<Biome> evt) {
|
||||
evt.getRegistry().register(StorageCellBiome.INSTANCE.setRegistryName(AppEng.makeId("storage")));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -726,7 +715,7 @@ final class Registration {
|
||||
|
||||
modEventBus.addListener(this::registerParticleFactories);
|
||||
modEventBus.addListener(this::registerTextures);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::modelRegistryEvent);
|
||||
modEventBus.addListener(this::modelRegistryEvent);
|
||||
modEventBus.addListener(this::registerItemColors);
|
||||
modEventBus.addListener(this::handleModelBake);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -42,6 +43,8 @@ import appeng.util.Platform;
|
||||
|
||||
public final class ChargedQuartzEntity extends AEBaseItemEntity {
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
public static EntityType<ChargedQuartzEntity> TYPE;
|
||||
|
||||
private int delay = 0;
|
||||
@@ -135,9 +138,15 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
|
||||
}
|
||||
|
||||
materials.fluixCrystal().maybeStack(2).ifPresent(is -> {
|
||||
final ItemEntity entity = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(),
|
||||
is);
|
||||
final double x = Math.floor(this.getPosX()) + .25d + RANDOM.nextDouble() * .5;
|
||||
final double y = Math.floor(this.getPosY()) + .25d + RANDOM.nextDouble() * .5;
|
||||
final double z = Math.floor(this.getPosZ()) + .25d + RANDOM.nextDouble() * .5;
|
||||
final double xSpeed = RANDOM.nextDouble() * .25 - 0.125;
|
||||
final double ySpeed = RANDOM.nextDouble() * .25 - 0.125;
|
||||
final double zSpeed = RANDOM.nextDouble() * .25 - 0.125;
|
||||
|
||||
final ItemEntity entity = new ItemEntity(this.world, x, y, z, is);
|
||||
entity.setMotion(xSpeed, ySpeed, zSpeed);
|
||||
this.world.addEntity(entity);
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package appeng.hooks;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public interface DynamicDimensions {
|
||||
|
||||
ServerWorld addWorld(RegistryKey<World> worldId, RegistryKey<DimensionType> dimensionTypeId,
|
||||
ChunkGenerator chunkGenerator);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package appeng.hooks;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BlockFaceUV;
|
||||
import net.minecraft.client.renderer.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.mixins.unlitquad.BakedQuadAccessor;
|
||||
|
||||
/**
|
||||
* Implementation details of allowing quads to be defined as "unlit" in JSON
|
||||
* models by specifying an "unlit" boolean property on the face.
|
||||
*/
|
||||
public class UnlitQuadHooks {
|
||||
|
||||
/**
|
||||
* Offset into the vertex data (which is represented as integers).
|
||||
*/
|
||||
private static final int LIGHT_OFFSET = getLightOffset();
|
||||
|
||||
// Lightmap texture coordinate with full intensity light leading to no drop in
|
||||
// brightness
|
||||
private static final int UNLIT_LIGHT_UV = LightTexture.packLight(15, 15);
|
||||
|
||||
/**
|
||||
* Thread-Local flag to indicate that an enhanced Applied Energistics model is
|
||||
* currently being deserialized.
|
||||
*/
|
||||
private static final ThreadLocal<Boolean> ENABLE_UNLIT_EXTENSIONS = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Notify the unlit model system that a specific model is about to be
|
||||
* deserialized by {@link net.minecraft.client.renderer.model.ModelBakery}.
|
||||
*/
|
||||
public static void beginDeserializingModel(ResourceLocation location) {
|
||||
String namespace = location.getNamespace();
|
||||
if (namespace.equals(AppEng.MOD_ID)) {
|
||||
ENABLE_UNLIT_EXTENSIONS.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the unlit model system that deserialization of a model has ended.
|
||||
*/
|
||||
public static void endDeserializingModel() {
|
||||
ENABLE_UNLIT_EXTENSIONS.set(false);
|
||||
}
|
||||
|
||||
public static boolean isUnlitExtensionEnabled() {
|
||||
Boolean b = ENABLE_UNLIT_EXTENSIONS.get();
|
||||
return b != null && b;
|
||||
}
|
||||
|
||||
public static BlockPartFace enhanceModelElementFace(BlockPartFace modelElement, JsonElement jsonElement) {
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
if (JSONUtils.getBoolean(jsonObject, "unlit", false)) {
|
||||
return new UnlitBlockPartFace(modelElement.cullFace, modelElement.tintIndex, modelElement.texture,
|
||||
modelElement.blockFaceUV);
|
||||
}
|
||||
return modelElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new quad from the given quad and pre-bakes it to not be affected by
|
||||
* lighting (neither diffuse lighting nor the prebaked lightmap). This works on
|
||||
* the assumption that Vanilla will not modify a quad's lightmap data if it's
|
||||
* not zero.
|
||||
*/
|
||||
public static BakedQuad makeUnlit(BakedQuad quad) {
|
||||
int[] vertexData = quad.getVertexData().clone();
|
||||
int stride = DefaultVertexFormats.BLOCK.getIntegerSize();
|
||||
// Set the pre-baked texture coords for the lightmap.
|
||||
// Vanilla will not overwrite them if they are non-zero
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vertexData[stride * i + LIGHT_OFFSET] = UNLIT_LIGHT_UV;
|
||||
}
|
||||
TextureAtlasSprite sprite = ((BakedQuadAccessor) quad).getSprite();
|
||||
// Copy the quad to disable diffuse lighting
|
||||
return new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), sprite, false /* diffuse lighting */);
|
||||
}
|
||||
|
||||
/**
|
||||
* This subclass is used as a marker to indicate this face deserialized from
|
||||
* JSON is supposed to be unlit, which translates to processing by
|
||||
* {@link #makeUnlit(BakedQuad)}.
|
||||
*/
|
||||
public static class UnlitBlockPartFace extends BlockPartFace {
|
||||
public UnlitBlockPartFace(Direction cullFaceIn, int tintIndexIn, String textureIn, BlockFaceUV blockFaceUVIn) {
|
||||
super(cullFaceIn, tintIndexIn, textureIn, blockFaceUVIn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the index in the BakedQuad vertex data (for vertex 0) where the lightmap
|
||||
* coordinates are. Assumes the BLOCK vertex format.
|
||||
*/
|
||||
private static int getLightOffset() {
|
||||
VertexFormat format = DefaultVertexFormats.BLOCK;
|
||||
int offset = 0;
|
||||
for (VertexFormatElement element : format.getElements()) {
|
||||
// TEX_2SB is the lightmap vertex element
|
||||
if (element == DefaultVertexFormats.TEX_2SB) {
|
||||
if (element.getType() != VertexFormatElement.Type.SHORT) {
|
||||
throw new UnsupportedOperationException("Expected light map format to be of type SHORT");
|
||||
}
|
||||
if (offset % 4 != 0) {
|
||||
throw new UnsupportedOperationException("Expected light map offset to be 4-byte aligned");
|
||||
}
|
||||
return offset / 4;
|
||||
}
|
||||
offset += element.getSize();
|
||||
}
|
||||
throw new UnsupportedOperationException("Failed to find the lightmap index in the block vertex format");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public enum TheOneProbeText {
|
||||
}
|
||||
|
||||
public String getUnlocalized() {
|
||||
return this.root + '.' + this.name().toLowerCase(Locale.ENGLISH);
|
||||
return this.root + '.' + this.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,12 +29,10 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -18,35 +18,40 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.spatial.StorageHelper;
|
||||
import appeng.spatial.SpatialStorageHelper;
|
||||
import appeng.spatial.SpatialStoragePlot;
|
||||
import appeng.spatial.SpatialStoragePlotManager;
|
||||
import appeng.spatial.TransitionInfo;
|
||||
|
||||
public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorageCell {
|
||||
private static final String TAG_DIMENSION_ID = "dimension_id";
|
||||
private static final String TAG_PLOT_ID = "plot_id";
|
||||
|
||||
/**
|
||||
* This is only stored in the itemstack to display in the tooltip on the
|
||||
* client-side.
|
||||
*/
|
||||
private static final String TAG_PLOT_SIZE = "plot_size";
|
||||
|
||||
private final int maxRegion;
|
||||
|
||||
@@ -59,18 +64,22 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final RegistryKey<World> worldId = this.getStoredDimension(stack);
|
||||
if (worldId == null) {
|
||||
int plotId = this.getAllocatedPlotId(stack);
|
||||
if (plotId == -1) {
|
||||
lines.add(GuiText.Unformatted.text().deepCopy().mergeStyle(TextFormatting.ITALIC));
|
||||
lines.add(GuiText.SpatialCapacity.text(maxRegion, maxRegion, maxRegion));
|
||||
} else {
|
||||
SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(worldId, lines);
|
||||
return;
|
||||
}
|
||||
|
||||
if (advancedTooltips.isAdvanced()) {
|
||||
if (worldId != null && worldId.func_240901_a_() != null) {
|
||||
lines.add(new StringTextComponent("Dimension: " + worldId.func_240901_a_()));
|
||||
}
|
||||
// Add a serial number to allows players to keep different cells apart
|
||||
// Try to make this a little more flavorful.
|
||||
String serialNumber = String.format(Locale.ROOT, "SP-%04d", plotId);
|
||||
lines.add(GuiText.SerialNumber.text(serialNumber));
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
if (tag != null && tag.contains(TAG_PLOT_SIZE, Constants.NBT.TAG_LONG)) {
|
||||
BlockPos size = BlockPos.fromLong(tag.getLong(TAG_PLOT_SIZE));
|
||||
lines.add(GuiText.StoredSize.text(size.getX(), size.getY(), size.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,70 +94,80 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryKey<World> getStoredDimension(final ItemStack is) {
|
||||
public int getAllocatedPlotId(final ItemStack is) {
|
||||
final CompoundNBT c = is.getTag();
|
||||
if (c != null && c.contains(TAG_DIMENSION_ID)) {
|
||||
if (c != null && c.contains(TAG_PLOT_ID)) {
|
||||
try {
|
||||
ResourceLocation worldId = new ResourceLocation(c.getString(TAG_DIMENSION_ID));
|
||||
return RegistryKey.func_240903_a_(Registry.WORLD_KEY, worldId);
|
||||
int plotId = c.getInt(TAG_PLOT_ID);
|
||||
if (SpatialStoragePlotManager.INSTANCE.getPlot(plotId) == null) {
|
||||
return -1;
|
||||
}
|
||||
return plotId;
|
||||
} catch (Exception e) {
|
||||
AELog.warn("Failed to retrieve storage cell dimension.", e);
|
||||
AELog.warn("Failed to retrieve spatial storage dimension: %s", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionResult doSpatialTransition(final ItemStack is, final ServerWorld w, final WorldCoord min,
|
||||
public boolean doSpatialTransition(final ItemStack is, final ServerWorld w, final WorldCoord min,
|
||||
final WorldCoord max, int playerId) {
|
||||
final int targetX = max.x - min.x - 1;
|
||||
final int targetY = max.y - min.y - 1;
|
||||
final int targetZ = max.z - min.z - 1;
|
||||
final int maxSize = this.getMaxStoredDim(is);
|
||||
if (targetX > maxSize && targetY > maxSize && targetZ > maxSize) {
|
||||
AELog.info(
|
||||
"Failing spatial transition because the transfer area (%dx%dx%d) exceeds the cell capacity (%s).",
|
||||
targetX, targetY, targetZ, maxSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
final BlockPos targetSize = new BlockPos(targetX, targetY, targetZ);
|
||||
|
||||
ISpatialDimension manager = SpatialDimensionManager.INSTANCE;
|
||||
SpatialStoragePlotManager manager = SpatialStoragePlotManager.INSTANCE;
|
||||
|
||||
RegistryKey<World> worldId = this.getStoredDimension(is);
|
||||
if (worldId == null || manager.getWorld(worldId) == null) {
|
||||
worldId = manager.createNewCellDimension(targetSize);
|
||||
SpatialStoragePlot plot = SpatialStoragePlotManager.INSTANCE.getPlot(this.getAllocatedPlotId(is));
|
||||
if (plot != null) {
|
||||
// Check that the existing plot has the right size
|
||||
if (!plot.getSize().equals(targetSize)) {
|
||||
AELog.info(
|
||||
"Failing spatial transition because the transfer area (%dx%dx%d) does not match the spatial storage plot's size (%s).",
|
||||
targetX, targetY, targetZ, plot.getSize());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Otherwise allocate a new one
|
||||
plot = manager.allocatePlot(targetSize, playerId);
|
||||
}
|
||||
|
||||
if (worldId == null) {
|
||||
// Failed to create the dimension
|
||||
return new TransitionResult(false, 0);
|
||||
}
|
||||
// Store some information about this transition in the plot
|
||||
TransitionInfo info = new TransitionInfo(w.func_234923_W_().func_240901_a_(), min.getBlockPos(),
|
||||
max.getBlockPos(), Instant.now());
|
||||
manager.setLastTransition(plot.getId(), info);
|
||||
|
||||
try {
|
||||
if (manager.isCellDimension(worldId)) {
|
||||
ServerWorld cellWorld = manager.getWorld(worldId);
|
||||
ServerWorld cellWorld = manager.getWorld();
|
||||
|
||||
BlockPos scale = manager.getCellDimensionSize(worldId);
|
||||
BlockPos offset = plot.getOrigin();
|
||||
|
||||
if (scale.equals(targetSize)) {
|
||||
if (targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize) {
|
||||
BlockPos offset = manager.getCellDimensionOrigin(worldId);
|
||||
this.setStoredDimension(is, plot.getId(), plot.getSize());
|
||||
SpatialStorageHelper.getInstance().swapRegions(w, min.x + 1, min.y + 1, min.z + 1, cellWorld, offset.getX(),
|
||||
offset.getY(), offset.getZ(), targetX - 1, targetY - 1, targetZ - 1);
|
||||
|
||||
this.setStoredDimension(is, worldId);
|
||||
StorageHelper.getInstance().swapRegions(w, min.x + 1, min.y + 1, min.z + 1, cellWorld,
|
||||
offset.getX(), offset.getY(), offset.getZ(), targetX - 1, targetY - 1, targetZ - 1);
|
||||
|
||||
return new TransitionResult(true, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TransitionResult(false, 0);
|
||||
return true;
|
||||
} finally {
|
||||
// clean up newly created dimensions that failed transfer
|
||||
if (manager.isCellDimension(worldId) && this.getStoredDimension(is) == null) {
|
||||
manager.deleteCellDimension(worldId);
|
||||
if (this.getAllocatedPlotId(is) == -1) {
|
||||
manager.freePlot(plot.getId(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStoredDimension(final ItemStack is, RegistryKey<World> worldId) {
|
||||
public void setStoredDimension(final ItemStack is, int plotId, BlockPos size) {
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
c.putString(TAG_DIMENSION_ID, worldId.func_240901_a_().toString());
|
||||
c.putInt(TAG_PLOT_ID, plotId);
|
||||
c.putLong(TAG_PLOT_SIZE, size.toLong());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
@@ -69,7 +68,6 @@ import appeng.block.networking.CableBusBlock;
|
||||
import appeng.block.paint.PaintSplotchesBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.IBlockTool;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
|
||||
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.server.IDynamicRegistries;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
|
||||
@Mixin(value = DimensionType.class)
|
||||
public class DimensionTypeMixin {
|
||||
|
||||
@Inject(method = "func_236027_a_", at = @At("TAIL"))
|
||||
private static void addRegistryDefaults(IDynamicRegistries.Impl registryTracker, CallbackInfoReturnable<?> cir) {
|
||||
|
||||
registryTracker.func_239774_a_(SpatialDimensionManager.STORAGE_DIMENSION_TYPE,
|
||||
new DimensionType(OptionalLong.of(12000), false, false, false, false, false, false, true, false, false,
|
||||
256, BlockTags.INFINIBURN_OVERWORLD.getName(), 1.0f));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.server.IDynamicRegistries;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
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.border.IBorderListener;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
import net.minecraft.world.chunk.listener.IChunkStatusListener;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.DerivedWorldInfo;
|
||||
import net.minecraft.world.storage.IServerConfiguration;
|
||||
import net.minecraft.world.storage.IServerWorldInfo;
|
||||
import net.minecraft.world.storage.SaveFormat;
|
||||
|
||||
import appeng.hooks.DynamicDimensions;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin implements DynamicDimensions {
|
||||
|
||||
@Shadow()
|
||||
private IDynamicRegistries.Impl field_240767_f_;
|
||||
|
||||
@Shadow
|
||||
private Map<RegistryKey<World>, ServerWorld> worlds;
|
||||
|
||||
@Shadow
|
||||
private IServerConfiguration field_240768_i_;
|
||||
|
||||
@Shadow
|
||||
private Executor backgroundExecutor;
|
||||
|
||||
@Shadow
|
||||
private SaveFormat.LevelSave anvilConverterForAnvilFile;
|
||||
|
||||
public ServerWorld addWorld(RegistryKey<World> worldId, RegistryKey<DimensionType> dimensionTypeId,
|
||||
ChunkGenerator chunkGenerator) {
|
||||
Preconditions.checkArgument(!worlds.containsKey(worldId), "World with id %s already exists.",
|
||||
worldId.func_240901_a_());
|
||||
|
||||
// Each worlds must have a corresponding dimension options, otherwise they will
|
||||
// not be re-created on load
|
||||
DimensionGeneratorSettings generatorOptions = this.field_240768_i_.getDimensionGeneratorSettings();
|
||||
Preconditions.checkArgument(!generatorOptions.func_236224_e_().containsKey(worldId.func_240901_a_()),
|
||||
"Dimension config with id %s already exists.", worldId.func_240901_a_());
|
||||
|
||||
DimensionType dimensionType = field_240767_f_.func_230520_a_().getValueForKey(dimensionTypeId);
|
||||
Preconditions.checkArgument(dimensionType != null, "dimensionTypeId %s is not registered", dimensionTypeId);
|
||||
|
||||
// Create dimension options with the given world-id and chunk generator
|
||||
Dimension dimensionOptions = new Dimension(
|
||||
() -> field_240767_f_.func_230520_a_().getValueForKey(dimensionTypeId), chunkGenerator);
|
||||
|
||||
IServerWorldInfo serverWorldProperties = this.field_240768_i_.func_230407_G_();
|
||||
|
||||
// This sucks a little, but during startup, the server will use the same
|
||||
// listener for every world,
|
||||
// but it is ultimately only stored in the chunk storage. So we retrieve it from
|
||||
// the overworld to
|
||||
// mirror the original code as much as possible
|
||||
ServerWorld overworld = worlds.get(ServerWorld.field_234918_g_);
|
||||
Preconditions.checkState(overworld != null, "Overworld does not exist!");
|
||||
IChunkStatusListener worldGenerationProgressListener = ((ThreadedAnvilChunkStorageAccessor) overworld
|
||||
.getChunkProvider().chunkManager).getWorldGenerationProgressListener();
|
||||
|
||||
// Inherit seed + WorldBorder from overworld
|
||||
long seed = overworld.getSeed();
|
||||
WorldBorder worldBorder = overworld.getWorldBorder();
|
||||
|
||||
MinecraftServer self = (MinecraftServer) (Object) this;
|
||||
DerivedWorldInfo unmodifiableLevelProperties = new DerivedWorldInfo(this.field_240768_i_,
|
||||
serverWorldProperties);
|
||||
ServerWorld world = new ServerWorld(self, this.backgroundExecutor, this.anvilConverterForAnvilFile,
|
||||
unmodifiableLevelProperties, worldId, dimensionTypeId, dimensionType, worldGenerationProgressListener,
|
||||
chunkGenerator, false, seed, ImmutableList.of(), false);
|
||||
worldBorder.addListener(new IBorderListener.Impl(world.getWorldBorder()));
|
||||
this.worlds.put(worldId, world);
|
||||
|
||||
// Adding it here will cause the world to be re-created on server restart
|
||||
RegistryKey<Dimension> dimOptKey = RegistryKey.func_240903_a_(Registry.DIMENSION_KEY, worldId.func_240901_a_());
|
||||
generatorOptions.func_236224_e_().register(dimOptKey, dimensionOptions);
|
||||
generatorOptions.func_236224_e_().func_239662_d_(dimOptKey); // Otherwise it wont be saved
|
||||
// Ensure the save properties are saved, or the world will potentially be lost
|
||||
// on restart
|
||||
this.anvilConverterForAnvilFile.func_237288_a_(this.field_240767_f_, this.field_240768_i_,
|
||||
self.getPlayerList().getHostPlayerData());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
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.client.world.DimensionRenderInfo;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.spatial.StorageSkyProperties;
|
||||
|
||||
@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) == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
|
||||
ci.setReturnValue(StorageSkyProperties.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.mixins.spatial;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.Dimension;
|
||||
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
|
||||
/**
|
||||
* This Mixin tries to hide the screen that warns users about experimental
|
||||
* features being used, but only if AE2's dimension is the only added dimension.
|
||||
*/
|
||||
@Mixin(Dimension.class)
|
||||
public class DimensionOptionMixin {
|
||||
|
||||
/**
|
||||
* This injects right after the method makes a local copy of all present
|
||||
* dimensions, and modifies the list by removing our mod-provided dimension from
|
||||
* it.
|
||||
* <p>
|
||||
* This means Vanilla will perform it's check whether it should display an
|
||||
* experimental warning without considering our dimension.
|
||||
*/
|
||||
@ModifyVariable(method = "func_236060_a_", at = @At(value = "INVOKE_ASSIGN", ordinal = 0, target = "Lcom/google/common/collect/Lists;newArrayList(Ljava/lang/Iterable;)Ljava/util/ArrayList;", remap = false), allow = 1)
|
||||
private static List<Map.Entry<RegistryKey<Dimension>, Dimension>> overrideExperimentalCheck(
|
||||
List<Map.Entry<RegistryKey<Dimension>, Dimension>> dimensions) {
|
||||
// this only removes our dimension from the check
|
||||
dimensions.removeIf(e -> e.getKey() == SpatialStorageDimensionIds.DIMENSION_ID);
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Adds the storage cell world dimension type as a built-in dimension type. This
|
||||
* can be registered as a JSON file as well, but doing so will trigger an
|
||||
* experimental feature warning when the world is being loaded.
|
||||
*/
|
||||
@Mixin(value = DimensionType.class)
|
||||
public class DimensionTypeMixin {
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.mixins.spatial;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.world.DimensionRenderInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
import appeng.spatial.SpatialStorageSkyProperties;
|
||||
|
||||
@Mixin(DimensionRenderInfo.class)
|
||||
public class SkyPropertiesMixin {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package appeng.mixins;
|
||||
package appeng.mixins.spatial;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
|
||||
import appeng.client.render.SpatialSkyRender;
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
|
||||
@Mixin(value = WorldRenderer.class)
|
||||
public class SkyRenderMixin {
|
||||
@@ -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_() == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
|
||||
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
-1
@@ -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);
|
||||
|
||||
}
|
||||
+3
-3
@@ -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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package appeng.mixins.unlitquad;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
@Mixin(BakedQuad.class)
|
||||
public interface BakedQuadAccessor {
|
||||
|
||||
@Accessor
|
||||
TextureAtlasSprite getSprite();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.mixins.unlitquad;
|
||||
|
||||
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.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.BlockModel;
|
||||
import net.minecraft.client.renderer.model.BlockPart;
|
||||
import net.minecraft.client.renderer.model.BlockPartFace;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.hooks.UnlitQuadHooks;
|
||||
|
||||
/**
|
||||
* This mixin hooks into conversion from {@link BlockPartFace} to
|
||||
* {@link BakedQuad} to apply our unlit extensions if the block part face is an
|
||||
* instance of our marker class
|
||||
* {@link appeng.hooks.UnlitQuadHooks.UnlitBlockPartFace}.
|
||||
*/
|
||||
@Mixin(BlockModel.class)
|
||||
public class BlockModelMixin {
|
||||
|
||||
@Inject(method = "bakeFace", at = @At("RETURN"), cancellable = true, require = 1, allow = 1)
|
||||
private static void onBakeFace(BlockPart partIn, BlockPartFace partFaceIn, TextureAtlasSprite spriteIn,
|
||||
Direction directionIn, IModelTransform transformIn, ResourceLocation locationIn,
|
||||
CallbackInfoReturnable<BakedQuad> cri) {
|
||||
if (partFaceIn instanceof UnlitQuadHooks.UnlitBlockPartFace) {
|
||||
cri.setReturnValue(UnlitQuadHooks.makeUnlit(cri.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package appeng.mixins.unlitquad;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
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.client.renderer.model.BlockPartFace;
|
||||
|
||||
import appeng.hooks.UnlitQuadHooks;
|
||||
|
||||
/**
|
||||
* This mixin will call the hook to deserialize the unlit property, but only if
|
||||
* we are currently deserializing an AE2 model.
|
||||
*/
|
||||
@Mixin(BlockPartFace.Deserializer.class)
|
||||
public class BlockPartFaceDeserializerMixin {
|
||||
|
||||
@Inject(method = "deserialize", at = @At("RETURN"), cancellable = true, allow = 1, remap = false)
|
||||
public void onDeserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext,
|
||||
CallbackInfoReturnable<BlockPartFace> cri) {
|
||||
if (!UnlitQuadHooks.isUnlitExtensionEnabled()) {
|
||||
return; // Not in a model that activated the deserializer
|
||||
}
|
||||
|
||||
BlockPartFace modelElement = cri.getReturnValue();
|
||||
cri.setReturnValue(UnlitQuadHooks.enhanceModelElementFace(modelElement, jsonElement));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.mixins.unlitquad;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
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.client.renderer.model.BlockModel;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.hooks.UnlitQuadHooks;
|
||||
|
||||
/**
|
||||
* The only job of this mixin is to only enable the unlit extensions if the
|
||||
* model is whitelisted for it, which is decided in {@link UnlitQuadHooks}.
|
||||
*/
|
||||
@Mixin(ModelBakery.class)
|
||||
public class ModelBakeryMixin {
|
||||
|
||||
@Inject(method = "loadModel", at = @At("HEAD"), allow = 1)
|
||||
protected void onBeginLoadModel(ResourceLocation location, CallbackInfoReturnable<BlockModel> cri)
|
||||
throws IOException {
|
||||
UnlitQuadHooks.beginDeserializingModel(location);
|
||||
}
|
||||
|
||||
@Inject(method = "loadModel", at = @At("RETURN"))
|
||||
protected void onEndLoadModel(ResourceLocation location, CallbackInfoReturnable<BlockModel> cri) {
|
||||
UnlitQuadHooks.endDeserializingModel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -28,15 +28,11 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.items.parts.PartModels;
|
||||
|
||||
public class IdentityAnnihilationPlanePart extends AnnihilationPlanePart {
|
||||
|
||||
@@ -45,6 +45,11 @@ public class FEP2PTunnelPart extends P2PTunnelPart<FEP2PTunnelPart> {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels() {
|
||||
return MODELS.getModels();
|
||||
|
||||
@@ -54,7 +54,8 @@ public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> {
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick() {
|
||||
@Override
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,11 @@ public class ItemP2PTunnelPart extends P2PTunnelPart<ItemP2PTunnelPart> implemen
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPowerDrainPerTick() {
|
||||
return POWER_DRAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) {
|
||||
this.cachedInv = null;
|
||||
@@ -235,10 +240,6 @@ public class ItemP2PTunnelPart extends P2PTunnelPart<ItemP2PTunnelPart> implemen
|
||||
return this.getDestination().getSlotLimit(slot);
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick() {
|
||||
return POWER_DRAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return MODELS.getModel(this.isPowered(), this.isActive());
|
||||
|
||||
@@ -56,6 +56,10 @@ public class LightP2PTunnelPart extends P2PTunnelPart<LightP2PTunnelPart> implem
|
||||
super(is);
|
||||
}
|
||||
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chanRender(final MENetworkChannelsChanged c) {
|
||||
this.onTunnelNetworkChange();
|
||||
@@ -186,10 +190,6 @@ public class LightP2PTunnelPart extends P2PTunnelPart<LightP2PTunnelPart> implem
|
||||
return this.doWork() ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return MODELS.getModel(this.isPowered(), this.isActive());
|
||||
|
||||
@@ -67,6 +67,11 @@ public class MEP2PTunnelPart extends P2PTunnelPart<MEP2PTunnelPart> implements I
|
||||
this.outerProxy.setFlags(GridFlags.DENSE_CAPACITY, GridFlags.CANNOT_CARRY_COMPRESSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final CompoundNBT extra) {
|
||||
super.readFromNBT(extra);
|
||||
|
||||
@@ -61,6 +61,11 @@ public abstract class P2PTunnelPart<T extends P2PTunnelPart> extends BasicStateP
|
||||
|
||||
public P2PTunnelPart(final ItemStack is) {
|
||||
super(is);
|
||||
this.getProxy().setIdlePowerUsage(this.getPowerDrainPerTick());
|
||||
}
|
||||
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public TunnelCollection<T> getCollection(final Collection<P2PTunnelPart> collection,
|
||||
|
||||
@@ -55,6 +55,11 @@ public class RedstoneP2PTunnelPart extends P2PTunnelPart<RedstoneP2PTunnelPart>
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPowerDrainPerTick() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateA(final MENetworkBootingStatusChange bs) {
|
||||
this.setNetworkReady();
|
||||
@@ -123,10 +128,6 @@ public class RedstoneP2PTunnelPart extends P2PTunnelPart<RedstoneP2PTunnelPart>
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) {
|
||||
if (!this.isOutput()) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.BasePacket;
|
||||
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.BasePacket;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
|
||||
@@ -20,6 +20,8 @@ package appeng.server;
|
||||
|
||||
import static net.minecraft.command.Commands.literal;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
||||
@@ -46,7 +48,7 @@ public final class AECommand {
|
||||
|
||||
private void add(LiteralArgumentBuilder<net.minecraft.command.CommandSource> builder, Commands subCommand) {
|
||||
|
||||
LiteralArgumentBuilder<CommandSource> subCommandBuilder = literal(subCommand.name().toLowerCase())
|
||||
LiteralArgumentBuilder<CommandSource> subCommandBuilder = literal(subCommand.name().toLowerCase(Locale.ROOT))
|
||||
.requires(src -> src.hasPermissionLevel(subCommand.level));
|
||||
subCommand.command.addArguments(subCommandBuilder);
|
||||
subCommandBuilder.executes(ctx -> {
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
package appeng.server;
|
||||
|
||||
import appeng.server.subcommands.ChunkLogger;
|
||||
import appeng.server.subcommands.SpatialStorageCommand;
|
||||
import appeng.server.subcommands.Supporters;
|
||||
import appeng.server.subcommands.TestMeteoritesCommand;
|
||||
import appeng.server.subcommands.TestOreGenCommand;
|
||||
|
||||
public enum Commands {
|
||||
Chunklogger(4, new ChunkLogger(), false), Supporters(0, new Supporters(), false),
|
||||
TestOreGen(4, new TestOreGenCommand(), true), TestMeteorites(4, new TestMeteoritesCommand(), true);
|
||||
TestOreGen(4, new TestOreGenCommand(), true), TestMeteorites(4, new TestMeteoritesCommand(), true),
|
||||
Spatial(4, new SpatialStorageCommand(), false);
|
||||
|
||||
public final int level;
|
||||
public final ISubCommand command;
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
package appeng.server.subcommands;
|
||||
|
||||
import static net.minecraft.command.Commands.literal;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.items.storage.SpatialStorageCellItem;
|
||||
import appeng.server.ISubCommand;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
import appeng.spatial.SpatialStoragePlot;
|
||||
import appeng.spatial.SpatialStoragePlotManager;
|
||||
import appeng.spatial.TransitionInfo;
|
||||
|
||||
/**
|
||||
* This admin command allows management of spatial storage plots.
|
||||
*/
|
||||
public class SpatialStorageCommand implements ISubCommand {
|
||||
|
||||
@Override
|
||||
public void addArguments(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
// Shows info about a given plot or about the plot the player is currently in
|
||||
builder.then(literal("info").executes(ctx -> {
|
||||
showPlotInfo(ctx.getSource(), getCurrentPlot(ctx.getSource()));
|
||||
return 1;
|
||||
}).then(Commands.argument("plotId", IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
int plotId = IntegerArgumentType.getInteger(ctx, "plotId");
|
||||
showPlotInfo(ctx.getSource(), getPlot(plotId));
|
||||
return 1;
|
||||
})));
|
||||
|
||||
// Teleport into the plot
|
||||
builder.then(literal("tp").then(Commands.argument("plotId", IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
int plotId = IntegerArgumentType.getInteger(ctx, "plotId");
|
||||
teleportToPlot(ctx.getSource(), plotId);
|
||||
return 1;
|
||||
})));
|
||||
|
||||
// Teleport from the current plot back to the source of its content, or do the
|
||||
// same for a given plot id
|
||||
builder.then(literal("tpback").executes(ctx -> {
|
||||
teleportBack(ctx.getSource());
|
||||
return 1;
|
||||
}).then(Commands.argument("plotId", IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
int plotId = IntegerArgumentType.getInteger(ctx, "plotId");
|
||||
teleportBack(ctx.getSource(), getPlot(plotId));
|
||||
return 1;
|
||||
})));
|
||||
|
||||
// Creates a storage cell for the given plot id and gives it to the player
|
||||
builder.then(
|
||||
literal("givecell").then(Commands.argument("plotId", IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
int plotId = IntegerArgumentType.getInteger(ctx, "plotId");
|
||||
giveCell(ctx.getSource(), plotId);
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the player is currently within a spatial storage plot, teleports them back
|
||||
* to the last source of transition.
|
||||
*/
|
||||
private void teleportBack(CommandSource source) {
|
||||
|
||||
if (source.getWorld().func_234923_W_() != SpatialStorageDimensionIds.WORLD_ID) {
|
||||
throw new CommandException(new StringTextComponent("Must be within the spatial storage world."));
|
||||
}
|
||||
|
||||
BlockPos playerPos = new BlockPos(source.getPos());
|
||||
int x = playerPos.getX();
|
||||
int z = playerPos.getZ();
|
||||
|
||||
// This is slow, but for an admin-command it's acceptable
|
||||
|
||||
for (SpatialStoragePlot plot : SpatialStoragePlotManager.INSTANCE.getPlots()) {
|
||||
BlockPos origin = plot.getOrigin();
|
||||
BlockPos size = plot.getSize();
|
||||
if (x >= origin.getX() && x <= origin.getX() + size.getX() && z >= origin.getZ()
|
||||
&& z <= origin.getZ() + size.getZ()) {
|
||||
teleportBack(source, plot);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CommandException(ITextComponent.func_244388_a("Couldn't find a plot for the current position."));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports back from the given plot.
|
||||
*/
|
||||
private void teleportBack(CommandSource source, SpatialStoragePlot plot) {
|
||||
TransitionInfo lastTransition = plot.getLastTransition();
|
||||
if (lastTransition == null) {
|
||||
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));
|
||||
runCommandFor(source, command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows detailed information about a spatial storage plot.
|
||||
*/
|
||||
private static void showPlotInfo(CommandSource source, SpatialStoragePlot plot) {
|
||||
|
||||
sendKeyValuePair(source, "Plot ID", String.valueOf(plot.getId()));
|
||||
// Show the owner of the spatial storage plot
|
||||
int playerId = plot.getOwner();
|
||||
if (playerId != -1) {
|
||||
UUID profileId = WorldData.instance().playerData().getProfileId(playerId);
|
||||
|
||||
if (profileId == null) {
|
||||
sendKeyValuePair(source, "Owner", "Unknown AE2 player (" + playerId + ")");
|
||||
} else {
|
||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||
ServerPlayerEntity player = server.getPlayerList().getPlayerByUUID(profileId);
|
||||
if (player == null) {
|
||||
sendKeyValuePair(source, "Owner", "Unknown Minecraft profile (" + profileId + ")");
|
||||
} else {
|
||||
sendKeyValuePair(source, "Owner", player.getDisplayName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendKeyValuePair(source, "Owner", "Unknown");
|
||||
}
|
||||
|
||||
sendKeyValuePair(source, "Size", formatBlockPos(plot.getSize(), "x"));
|
||||
|
||||
// Show the plot's origin and make it clickable to teleport directly to it
|
||||
String teleportToPlotCommand = getTeleportCommand(SpatialStorageDimensionIds.WORLD_ID.func_240901_a_(),
|
||||
plot.getOrigin());
|
||||
sendKeyValuePair(source, "Origin", new StringTextComponent(formatBlockPos(plot.getOrigin(), ","))
|
||||
.modifyStyle(makeCommandLink(teleportToPlotCommand, "Teleport into plot")));
|
||||
|
||||
sendKeyValuePair(source, "Region file:", plot.getRegionFilename());
|
||||
|
||||
// Show information about what was last transfered into the plot (with a
|
||||
// clickable link to the source)
|
||||
TransitionInfo lastTransition = plot.getLastTransition();
|
||||
if (lastTransition != null) {
|
||||
source.sendFeedback(new StringTextComponent("Last Transition:").mergeStyle(TextFormatting.UNDERLINE,
|
||||
TextFormatting.BOLD), true);
|
||||
|
||||
String sourceWorldId = lastTransition.getWorldId().toString();
|
||||
IFormattableTextComponent sourceLink = new StringTextComponent(
|
||||
sourceWorldId + " - " + formatBlockPos(lastTransition.getMin(), ",") + " to "
|
||||
+ formatBlockPos(lastTransition.getMax(), ","));
|
||||
String tpCommand = getTeleportCommand(lastTransition.getWorldId(), lastTransition.getMin().add(0, 1, 0));
|
||||
sourceLink.modifyStyle(makeCommandLink(tpCommand, "Click to teleport"));
|
||||
|
||||
sendKeyValuePair(source, "Source", sourceLink);
|
||||
sendKeyValuePair(source, "When", lastTransition.getTimestamp().toString());
|
||||
} else {
|
||||
source.sendFeedback(new StringTextComponent("Last Transition unknown"), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void teleportToPlot(CommandSource source, int plotId) {
|
||||
SpatialStoragePlot plot = getPlot(plotId);
|
||||
|
||||
String teleportCommand = getTeleportCommand(SpatialStorageDimensionIds.WORLD_ID.func_240901_a_(),
|
||||
plot.getOrigin());
|
||||
|
||||
runCommandFor(source, teleportCommand);
|
||||
}
|
||||
|
||||
private void giveCell(CommandSource source, int plotId) throws CommandSyntaxException {
|
||||
ServerPlayerEntity player = source.asPlayer();
|
||||
|
||||
SpatialStoragePlot plot = getPlot(plotId);
|
||||
|
||||
ItemStack cell;
|
||||
int longestSide = getLongestSide(plot.getSize());
|
||||
if (longestSide <= 2) {
|
||||
cell = Api.instance().definitions().items().spatialCell2().stack(1);
|
||||
} else if (longestSide <= 16) {
|
||||
cell = Api.instance().definitions().items().spatialCell16().stack(1);
|
||||
} else {
|
||||
cell = Api.instance().definitions().items().spatialCell128().stack(1);
|
||||
}
|
||||
|
||||
if (!(cell.getItem() instanceof SpatialStorageCellItem)) {
|
||||
throw new CommandException(
|
||||
ITextComponent.func_244388_a("Storage cell items don't implement the storage cell interface!"));
|
||||
}
|
||||
|
||||
SpatialStorageCellItem spatialCellItem = (SpatialStorageCellItem) cell.getItem();
|
||||
spatialCellItem.setStoredDimension(cell, plotId, plot.getSize());
|
||||
|
||||
player.addItemStackToInventory(cell);
|
||||
}
|
||||
|
||||
private static int getLongestSide(BlockPos size) {
|
||||
return Math.max(size.getX(), Math.max(size.getY(), size.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, CommandContext<CommandSource> ctx, CommandSource sender) {
|
||||
|
||||
List<SpatialStoragePlot> plots = new ArrayList<>(SpatialStoragePlotManager.INSTANCE.getPlots());
|
||||
|
||||
// Prints the least recently used plots
|
||||
plots.sort(Comparator.comparing((SpatialStoragePlot plot) -> {
|
||||
TransitionInfo lastTransition = plot.getLastTransition();
|
||||
if (lastTransition != null) {
|
||||
return lastTransition.getTimestamp();
|
||||
} else {
|
||||
return Instant.MIN;
|
||||
}
|
||||
}).reversed());
|
||||
|
||||
for (int i = 0; i < Math.min(5, plots.size()); i++) {
|
||||
SpatialStoragePlot plot = plots.get(i);
|
||||
String size = formatBlockPos(plot.getSize(), "x");
|
||||
BlockPos originPos = plot.getOrigin();
|
||||
String origin = formatBlockPos(originPos, ",");
|
||||
|
||||
ITextComponent infoLink = new StringTextComponent("Plot #" + plot.getId())
|
||||
.modifyStyle(makeCommandLink("/ae2 spatial info " + plot.getId(), "Click to show details"));
|
||||
ITextComponent tpLink = new StringTextComponent("Origin: " + origin)
|
||||
.modifyStyle(makeCommandLink("/ae2 spatial tp " + plot.getId(), "Click to teleport into plot"));
|
||||
|
||||
IFormattableTextComponent message = new StringTextComponent("").append(infoLink)
|
||||
.appendString(" Size: " + size + " ").append(tpLink);
|
||||
|
||||
sender.sendFeedback(message, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String formatBlockPos(BlockPos size, String separator) {
|
||||
return size.getX() + separator + size.getY() + separator + size.getZ();
|
||||
}
|
||||
|
||||
private static UnaryOperator<Style> makeCommandLink(String command, String tooltip) {
|
||||
|
||||
return style -> style.applyFormatting(TextFormatting.UNDERLINE)
|
||||
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new StringTextComponent(tooltip)));
|
||||
|
||||
}
|
||||
|
||||
private static void runCommandFor(CommandSource source, String command) {
|
||||
Commands commandManager = ServerLifecycleHooks.getCurrentServer().getCommandManager();
|
||||
commandManager.handleCommand(source, command);
|
||||
}
|
||||
|
||||
private static String getTeleportCommand(ResourceLocation worldId, BlockPos pos) {
|
||||
return "/execute in " + worldId + " run tp @s " + pos.getX() + " " + (pos.getY() + 1) + " " + pos.getZ();
|
||||
}
|
||||
|
||||
private static SpatialStoragePlot getPlot(int plotId) {
|
||||
SpatialStoragePlot plot = SpatialStoragePlotManager.INSTANCE.getPlot(plotId);
|
||||
if (plot == null) {
|
||||
throw new CommandException(new StringTextComponent("Plot not found: " + plotId));
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
private static void sendKeyValuePair(CommandSource source, String label, ITextComponent value) {
|
||||
source.sendFeedback(
|
||||
new StringTextComponent("")
|
||||
.append(new StringTextComponent(label + ": ").mergeStyle(TextFormatting.BOLD)).append(value),
|
||||
true);
|
||||
}
|
||||
|
||||
private static void sendKeyValuePair(CommandSource source, String label, String value) {
|
||||
sendKeyValuePair(source, label, new StringTextComponent(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spatial storage plot that the command source is currently in.
|
||||
*/
|
||||
private static SpatialStoragePlot getCurrentPlot(CommandSource source) {
|
||||
if (source.getWorld().func_234923_W_() != SpatialStorageDimensionIds.WORLD_ID) {
|
||||
throw new CommandException(new StringTextComponent("Must be within the spatial storage world."));
|
||||
}
|
||||
|
||||
BlockPos playerPos = new BlockPos(source.getPos());
|
||||
int x = playerPos.getX();
|
||||
int z = playerPos.getZ();
|
||||
|
||||
// This is slow, but for an admin-command it's acceptable
|
||||
for (SpatialStoragePlot plot : SpatialStoragePlotManager.INSTANCE.getPlots()) {
|
||||
BlockPos origin = plot.getOrigin();
|
||||
BlockPos size = plot.getSize();
|
||||
if (x >= origin.getX() && x <= origin.getX() + size.getX() && z >= origin.getZ()
|
||||
&& z <= origin.getZ() + size.getZ()) {
|
||||
return plot;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -34,9 +34,10 @@ import net.minecraft.world.ITickList;
|
||||
import net.minecraft.world.NextTickListEntry;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.lighting.WorldLightManager;
|
||||
import net.minecraft.world.server.ServerTickList;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.server.ServerWorldLightManager;
|
||||
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
@@ -300,12 +301,17 @@ public class CachedPlane {
|
||||
|
||||
private void updateChunks() {
|
||||
|
||||
WorldLightManager lightManager = world.getLightManager();
|
||||
|
||||
// update shit..
|
||||
for (int x = 0; x < this.cx_size; x++) {
|
||||
for (int z = 0; z < this.cz_size; z++) {
|
||||
final Chunk c = this.myChunks[x][z];
|
||||
// FIXME: Light shit
|
||||
c.markDirty();
|
||||
if (lightManager instanceof ServerWorldLightManager) {
|
||||
ServerWorldLightManager serverLightManager = (ServerWorldLightManager) lightManager;
|
||||
for (int x = 0; x < this.cx_size; x++) {
|
||||
for (int z = 0; z < this.cz_size; z++) {
|
||||
final Chunk c = this.myChunks[x][z];
|
||||
serverLightManager.lightChunk(c, false);
|
||||
c.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,17 +323,14 @@ public class CachedPlane {
|
||||
|
||||
WorldData.instance().compassData().service().updateArea(this.getWorld(), c);
|
||||
|
||||
// FIXME this was sending chunks to players...
|
||||
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits, false);
|
||||
((ServerChunkProvider) world.getChunkProvider()).chunkManager.getTrackingPlayers(c.getPos(), false)
|
||||
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits);
|
||||
world.getChunkProvider().chunkManager.getTrackingPlayers(c.getPos(), false)
|
||||
.forEach(spe -> spe.connection.sendPacket(cdp));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME check if this makes any sense at all to send changes to players asap
|
||||
ServerChunkProvider serverChunkProvider = (ServerChunkProvider) world.getChunkProvider();
|
||||
serverChunkProvider.tick(() -> false);
|
||||
world.getChunkProvider().tick(() -> false);
|
||||
}
|
||||
|
||||
List<WorldCoord> getUpdates() {
|
||||
@@ -340,7 +343,6 @@ public class CachedPlane {
|
||||
|
||||
private static class BlockStorageData {
|
||||
public BlockState state;
|
||||
public int light;
|
||||
}
|
||||
|
||||
private class Column {
|
||||
@@ -373,8 +375,6 @@ public class CachedPlane {
|
||||
final ChunkSection[] storage = this.c.getSections();
|
||||
final ChunkSection extendedBlockStorage = storage[y >> 4];
|
||||
extendedBlockStorage.setBlockState(this.x, y & 15, this.z, data.state);
|
||||
// FIXME extendedBlockStorage.setBlockLight( this.x, y & 15, this.z, data.light
|
||||
// );
|
||||
}
|
||||
|
||||
private void fillData(final int y, BlockStorageData data) {
|
||||
@@ -382,8 +382,6 @@ public class CachedPlane {
|
||||
final ChunkSection extendedblockstorage = storage[y >> 4];
|
||||
|
||||
data.state = extendedblockstorage.getBlockState(this.x, y & 15, this.z);
|
||||
// FIXME data.light = extendedblockstorage.getBlockLight( this.x, y & 15, this.z
|
||||
// );
|
||||
}
|
||||
|
||||
private boolean doNotSkip(final int y) {
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
/**
|
||||
* Helps with encoding and decoding the extra data we attach to each created
|
||||
* storage dimension world as persistent state.
|
||||
*/
|
||||
public final class SpatialDimensionExtraData extends WorldSavedData {
|
||||
|
||||
/**
|
||||
* ID of this data when it is attached to a world.
|
||||
*/
|
||||
public static final String ID = "ae2_spatial_info";
|
||||
|
||||
// Used to allow forward compatibility
|
||||
private static final int CURRENT_FORMAT = 1;
|
||||
|
||||
private static final String TAG_FORMAT = "format";
|
||||
|
||||
private static final String TAG_SIZE = "size";
|
||||
|
||||
/**
|
||||
* The storage size of this dimension. This is dicateted by the pylon structure
|
||||
* size used to perform the first transfer into this dimension. Once it's set,
|
||||
* it cannot be changed anymore.
|
||||
*/
|
||||
private BlockPos size = BlockPos.ZERO;
|
||||
|
||||
public SpatialDimensionExtraData() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
public SpatialDimensionExtraData(BlockPos size) {
|
||||
super(ID);
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public BlockPos getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(BlockPos size) {
|
||||
this.size = size;
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
int version = tag.getInt(TAG_FORMAT);
|
||||
if (version != CURRENT_FORMAT) {
|
||||
// Currently no new format has been defined, as such anything but the current
|
||||
// version is invalid
|
||||
throw new IllegalStateException("Invalid AE2 spatial info version: " + version);
|
||||
}
|
||||
|
||||
size = NBTUtil.readBlockPos(tag.getCompound(TAG_SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
tag.putInt(TAG_FORMAT, CURRENT_FORMAT);
|
||||
tag.put(TAG_SIZE, NBTUtil.writeBlockPos(size));
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.hooks.DynamicDimensions;
|
||||
|
||||
public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
|
||||
// A region file is 512x512 blocks (32x32 chunks),
|
||||
// to avoid creating the 4 regions around 0,0,0,
|
||||
// we move the origin to the middle of region 0,0
|
||||
public static final BlockPos REGION_CENTER = new BlockPos(512 / 2, 64, 512 / 2);
|
||||
|
||||
public static final RegistryKey<DimensionType> STORAGE_DIMENSION_TYPE = RegistryKey
|
||||
.func_240903_a_(Registry.DIMENSION_TYPE_KEY, AppEng.makeId("storage_cell"));
|
||||
|
||||
public static final ISpatialDimension INSTANCE = new SpatialDimensionManager();
|
||||
|
||||
private static final String DIM_ID_PREFIX = "spatial_";
|
||||
|
||||
private SpatialDimensionManager() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerWorld getWorld(RegistryKey<World> cellDim) {
|
||||
MinecraftServer server = getServer();
|
||||
return server.getWorld(cellDim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryKey<World> createNewCellDimension(BlockPos size) {
|
||||
ResourceLocation dimKey = findFreeDimensionId();
|
||||
AELog.info("Allocating storage cell dimension '%s'", dimKey);
|
||||
|
||||
DynamicDimensions dynamicDimensions = (DynamicDimensions) getServer();
|
||||
|
||||
RegistryKey<World> worldId = RegistryKey.func_240903_a_(Registry.WORLD_KEY, dimKey);
|
||||
|
||||
ServerWorld world = dynamicDimensions.addWorld(worldId, STORAGE_DIMENSION_TYPE, StorageChunkGenerator.INSTANCE);
|
||||
|
||||
SpatialDimensionExtraData spatialExtraData = world.getSavedData().getOrCreate(SpatialDimensionExtraData::new,
|
||||
SpatialDimensionExtraData.ID);
|
||||
spatialExtraData.setSize(size);
|
||||
|
||||
return worldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries finding the next free storage cell dimension ID based on the currently
|
||||
* registered storage cell dimensions.
|
||||
*/
|
||||
private ResourceLocation findFreeDimensionId() {
|
||||
int maxId = 0;
|
||||
for (RegistryKey<World> worldId : getServer().func_240770_D_()) {
|
||||
ResourceLocation regName = worldId.func_240901_a_();
|
||||
if (regName == null || !AppEng.MOD_ID.equals(regName.getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = regName.getPath();
|
||||
if (!path.startsWith(DIM_ID_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
String numericIdPart = path.substring(DIM_ID_PREFIX.length());
|
||||
maxId = Math.max(Integer.parseUnsignedInt(numericIdPart), maxId);
|
||||
} catch (NumberFormatException e) {
|
||||
AELog.warn("Unparsable storage cell dimension id '%s'", path, e);
|
||||
}
|
||||
}
|
||||
|
||||
++maxId;
|
||||
|
||||
return AppEng.makeId(DIM_ID_PREFIX + maxId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension(RegistryKey<World> worldId) {
|
||||
AELog.info("Unregistering storage cell dimension %s", worldId.func_240901_a_());
|
||||
MinecraftServer server = getServer();
|
||||
// FIXME FABRIC ServerWorld world = DimensionManager.getWorld(server, worldId, false, false);
|
||||
// FIXME FABRIC if (world != null) {
|
||||
// FIXME FABRIC DimensionManager.unloadWorld(world);
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC DimensionManager.unloadWorlds(server, true);
|
||||
// FIXME FABRIC DimensionManager.unregisterDimension(worldId.getId());
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension(RegistryKey<World> worldId) {
|
||||
ResourceLocation id = worldId.func_240901_a_();
|
||||
if (!id.getNamespace().equals(AppEng.MOD_ID)) {
|
||||
return false; // World belongs to a different mod
|
||||
}
|
||||
if (!id.getPath().startsWith(DIM_ID_PREFIX)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the world has the right dimension type
|
||||
ServerWorld world = getServer().getWorld(worldId);
|
||||
if (world == null) {
|
||||
return false; // Non-existent world
|
||||
}
|
||||
|
||||
return world.func_234922_V_().equals(STORAGE_DIMENSION_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin(RegistryKey<World> worldId) {
|
||||
return REGION_CENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionSize(RegistryKey<World> worldId) {
|
||||
SpatialDimensionExtraData extraData = getExtraData(worldId);
|
||||
return extraData != null ? extraData.getSize() : BlockPos.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellDimensionTooltip(RegistryKey<World> worldId, List<ITextComponent> lines) {
|
||||
// Check if the cell dimension type is even registered
|
||||
ResourceLocation registryName = worldId.func_240901_a_();
|
||||
if (registryName == null || !AppEng.MOD_ID.equals(registryName.getNamespace())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!registryName.getPath().startsWith(DIM_ID_PREFIX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the actual stored size
|
||||
BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(worldId);
|
||||
lines.add(GuiText.StoredSize.text(size.getX(), size.getY(), size.getZ()));
|
||||
|
||||
// Add a serial number to allows players to keep different cells apart
|
||||
int dimId;
|
||||
try {
|
||||
String numericIdPart = registryName.getPath().substring(DIM_ID_PREFIX.length());
|
||||
dimId = Integer.parseUnsignedInt(numericIdPart);
|
||||
} catch (NumberFormatException ignored) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to make this a little more flavorful.
|
||||
String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId);
|
||||
lines.add(GuiText.SerialNumber.text(serialNumber));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SpatialDimensionExtraData getExtraData(RegistryKey<World> worldId) {
|
||||
ServerWorld world = getWorld(worldId);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return world.getSavedData().get(SpatialDimensionExtraData::new, SpatialDimensionExtraData.ID);
|
||||
}
|
||||
|
||||
private static MinecraftServer getServer() {
|
||||
return ServerLifecycleHooks.getCurrentServer();
|
||||
}
|
||||
|
||||
}
|
||||
+16
-21
@@ -20,30 +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;
|
||||
|
||||
public class StorageCellBiome extends Biome {
|
||||
/**
|
||||
* The single biome used within the spatial storage world.
|
||||
*/
|
||||
public class SpatialStorageBiome {
|
||||
|
||||
public static final StorageCellBiome INSTANCE = new StorageCellBiome();
|
||||
|
||||
public StorageCellBiome() {
|
||||
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();
|
||||
|
||||
}
|
||||
+31
-12
@@ -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;
|
||||
@@ -43,20 +44,33 @@ import net.minecraft.world.gen.settings.DimensionStructuresSettings;
|
||||
|
||||
import appeng.core.Api;
|
||||
|
||||
public class StorageChunkGenerator extends ChunkGenerator {
|
||||
/**
|
||||
* Chunk generator the spatial storage world.
|
||||
*/
|
||||
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 StorageChunkGenerator INSTANCE = new StorageChunkGenerator();
|
||||
|
||||
public static final Codec<StorageChunkGenerator> CODEC = RecordCodecBuilder
|
||||
.create((instance) -> instance.stable(INSTANCE));
|
||||
|
||||
private final BlockState defaultBlockState;
|
||||
|
||||
private StorageChunkGenerator() {
|
||||
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
|
||||
@@ -70,8 +84,13 @@ public class StorageChunkGenerator extends ChunkGenerator {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
private static BiomeProvider createBiomeProvider() {
|
||||
return new SingleBiomeProvider(StorageCellBiome.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() {
|
||||
@@ -0,0 +1,64 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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;
|
||||
|
||||
/**
|
||||
* IDs for the spatial storage world related dimension objects.
|
||||
*/
|
||||
public final class SpatialStorageDimensionIds {
|
||||
|
||||
/**
|
||||
* ID of the {@link DimensionType} used for the spatial storage world.
|
||||
* <p>
|
||||
* This is defined in {@link DimensionTypeMixin}.
|
||||
*/
|
||||
public static final RegistryKey<DimensionType> DIMENSION_TYPE_ID = RegistryKey
|
||||
.func_240903_a_(Registry.DIMENSION_TYPE_KEY, AppEng.makeId("spatial_storage"));
|
||||
|
||||
/**
|
||||
* ID of the {@link net.minecraft.world.gen.ChunkGenerator} used for the spatial
|
||||
* storage world.
|
||||
*/
|
||||
public static final ResourceLocation CHUNK_GENERATOR_ID = AppEng.makeId("spatial_storage");
|
||||
|
||||
/**
|
||||
* ID of the {@link net.minecraft.world.biome.Biome} used for the spatial
|
||||
* storage world.
|
||||
*/
|
||||
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 {@link appeng.mixins.spatial.DimensionTypeMixin}.
|
||||
*/
|
||||
public static final RegistryKey<Dimension> DIMENSION_ID = RegistryKey.func_240903_a_(Registry.DIMENSION_KEY,
|
||||
AppEng.makeId("spatial_storage"));
|
||||
|
||||
/**
|
||||
* ID of the {@link World} that is instantiated from the dimension/dimension
|
||||
* type.
|
||||
*/
|
||||
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() {
|
||||
}
|
||||
|
||||
}
|
||||
+33
-26
@@ -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;
|
||||
@@ -39,17 +41,27 @@ import appeng.api.util.WorldCoord;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class StorageHelper {
|
||||
public class SpatialStorageHelper {
|
||||
|
||||
private static StorageHelper instance;
|
||||
private static SpatialStorageHelper instance;
|
||||
|
||||
public static StorageHelper getInstance() {
|
||||
public static SpatialStorageHelper getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new StorageHelper();
|
||||
instance = new 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.
|
||||
*
|
||||
@@ -64,7 +76,7 @@ public class StorageHelper {
|
||||
|
||||
try {
|
||||
oldWorld = (ServerWorld) entity.world;
|
||||
newWorld = (ServerWorld) link.dim;
|
||||
newWorld = link.dim;
|
||||
} catch (final Throwable e) {
|
||||
return entity;
|
||||
}
|
||||
@@ -97,12 +109,25 @@ public class StorageHelper {
|
||||
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_() == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
|
||||
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 StorageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
/**
|
||||
* A plot inside the storage cell world that is assigned to a specific storage
|
||||
* cell.
|
||||
*/
|
||||
public class SpatialStoragePlot {
|
||||
|
||||
private static final String TAG_ID = "id";
|
||||
|
||||
private static final String TAG_SIZE = "size";
|
||||
|
||||
private static final String TAG_OWNER = "owner";
|
||||
|
||||
private static final String TAG_LAST_TRANSITION = "last_transition";
|
||||
|
||||
private static final int REGION_SIZE = 512;
|
||||
|
||||
public static final int MAX_SIZE = 128;
|
||||
|
||||
/**
|
||||
* Id of the plot.
|
||||
*/
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* The storage size of this dimension. This is dictated by the pylon structure
|
||||
* size used to perform the first transfer into this dimension. Once it's set,
|
||||
* it cannot be changed anymore.
|
||||
*/
|
||||
private final BlockPos size;
|
||||
|
||||
/**
|
||||
* AE2 player id of who primarily owned the network when the storage plot was
|
||||
* allocated.
|
||||
*/
|
||||
private final int owner;
|
||||
|
||||
/**
|
||||
* Information about the last transition into this plot.
|
||||
*/
|
||||
@Nullable
|
||||
private TransitionInfo lastTransition;
|
||||
|
||||
public SpatialStoragePlot(int id, BlockPos size, int owner) {
|
||||
this.id = id;
|
||||
this.size = size;
|
||||
this.owner = owner;
|
||||
if (size.getX() < 1 || size.getY() < 1 || size.getZ() < 1) {
|
||||
throw new IllegalArgumentException("Plot size " + size + " is smaller than minimum size.");
|
||||
}
|
||||
if (size.getX() > MAX_SIZE || size.getY() > MAX_SIZE || size.getZ() > MAX_SIZE) {
|
||||
throw new IllegalArgumentException("Plot size " + size + " exceeds maximum size of " + MAX_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The size in blocks of the plot in the storage dimension.
|
||||
*
|
||||
* @see #getOrigin()
|
||||
*/
|
||||
public BlockPos getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the AE player id of the owner of this plot, or -1 if unknown.
|
||||
*
|
||||
* @see appeng.core.worlddata.IWorldPlayerData
|
||||
*/
|
||||
public int getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the last transition into this plot (if any).
|
||||
*/
|
||||
@Nullable
|
||||
public TransitionInfo getLastTransition() {
|
||||
return lastTransition;
|
||||
}
|
||||
|
||||
void setLastTransition(TransitionInfo info) {
|
||||
this.lastTransition = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* The origin of this plot within the spatial storage dimension.
|
||||
* <p>
|
||||
* To map an integer to a specific position, it uses the following algorithm.
|
||||
*
|
||||
* The 2 least significant bits determine the sign for the x and z axis. Every
|
||||
* other pack of 2 bits locate the plot within a quadrant of a increasing area
|
||||
* by the bit position.
|
||||
*
|
||||
* The first 2 bits after the sign address a quadrant within 1024x1024 blocks
|
||||
* (or 4 region files)
|
||||
*
|
||||
* Every further will continue to double both x and z values. E.g. 2048x2048 for
|
||||
* the 3rd pack and 4096x4096 for the 4th.
|
||||
*
|
||||
* @see #getSize()
|
||||
*/
|
||||
public BlockPos getOrigin() {
|
||||
int signBits = id & 0b11;
|
||||
int offsetBits = id >> 2;
|
||||
int offsetScale = 1;
|
||||
int posx = REGION_SIZE / 2;
|
||||
int posz = REGION_SIZE / 2;
|
||||
|
||||
// find quadrant
|
||||
while (offsetBits != 0) {
|
||||
posx += REGION_SIZE * offsetScale * (offsetBits & 0b01);
|
||||
posz += REGION_SIZE * offsetScale * (offsetBits >> 1 & 0b01);
|
||||
|
||||
offsetBits >>= 2;
|
||||
offsetScale <<= 1;
|
||||
}
|
||||
|
||||
// mirror in one of 4 directions
|
||||
// First flip the z axis on every increment and then every two the x axis
|
||||
if ((signBits & 0b01) != 0) {
|
||||
posz *= -1;
|
||||
}
|
||||
if ((signBits & 0b10) != 0) {
|
||||
posx *= -1;
|
||||
}
|
||||
|
||||
// offset from cell center
|
||||
//
|
||||
// This is to ensure a 128x128x128 block plot (or 8x8 chunks) is centered within
|
||||
// the region.
|
||||
// This provides 12 chunks around it, so the default chunk loading radius on
|
||||
// servers of 10 will prevent adjacent regions to be generated. As well as a 24
|
||||
// chunks to the next plot.
|
||||
posx -= 64;
|
||||
posz -= 64;
|
||||
|
||||
return new BlockPos(posx, 64, posz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the filename of the region in the world save containing this plot.
|
||||
*/
|
||||
public String getRegionFilename() {
|
||||
BlockPos origin = this.getOrigin();
|
||||
ChunkPos originChunk = new ChunkPos(origin);
|
||||
|
||||
return String.format(Locale.ROOT, "r.%d.%d.mca", originChunk.getRegionCoordX(), originChunk.getRegionCoordZ());
|
||||
}
|
||||
|
||||
public CompoundNBT toTag() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putInt(TAG_ID, id);
|
||||
tag.put(TAG_SIZE, NBTUtil.writeBlockPos(size));
|
||||
tag.putInt(TAG_OWNER, owner);
|
||||
if (lastTransition != null) {
|
||||
tag.put(TAG_LAST_TRANSITION, lastTransition.toTag());
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static SpatialStoragePlot fromTag(CompoundNBT tag) {
|
||||
int id = tag.getInt(TAG_ID);
|
||||
BlockPos size = NBTUtil.readBlockPos(tag.getCompound(TAG_SIZE));
|
||||
int ownerId = tag.getInt(TAG_OWNER);
|
||||
SpatialStoragePlot plot = new SpatialStoragePlot(id, size, ownerId);
|
||||
|
||||
if (tag.contains(TAG_LAST_TRANSITION, Constants.NBT.TAG_COMPOUND)) {
|
||||
plot.lastTransition = TransitionInfo.fromTag(tag.getCompound(TAG_LAST_TRANSITION));
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
|
||||
/**
|
||||
* Allocates and manages plots for spatial storage in the spatial storage world.
|
||||
*/
|
||||
public final class SpatialStoragePlotManager {
|
||||
|
||||
public static final SpatialStoragePlotManager INSTANCE = new SpatialStoragePlotManager();
|
||||
|
||||
private SpatialStoragePlotManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the world used to store spatial storage cell's content.
|
||||
*/
|
||||
public ServerWorld getWorld() {
|
||||
MinecraftServer server = getServer();
|
||||
ServerWorld world = server.getWorld(SpatialStorageDimensionIds.WORLD_ID);
|
||||
if (world == null) {
|
||||
throw new IllegalStateException("The storage cell world is missing.");
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
private SpatialStorageWorldData getWorldData() {
|
||||
return getWorld().getChunkProvider().getSavedData().getOrCreate(SpatialStorageWorldData::new,
|
||||
SpatialStorageWorldData.ID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SpatialStoragePlot getPlot(int plotId) {
|
||||
if (plotId == -1) {
|
||||
return null;
|
||||
}
|
||||
return getWorldData().getPlotById(plotId);
|
||||
}
|
||||
|
||||
public SpatialStoragePlot allocatePlot(BlockPos size, int ownerId) {
|
||||
SpatialStoragePlot plot = getWorldData().allocatePlot(size, ownerId);
|
||||
AELog.info("Allocating storage cell plot %d with size %s for %d", plot.getId(), size, ownerId);
|
||||
return plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last source for a spatial storage transition into the given plot.
|
||||
* This is used to allow the server-admin commands to know where the content of
|
||||
* a given plot came from.
|
||||
*/
|
||||
public void setLastTransition(int plotId, TransitionInfo info) {
|
||||
getWorldData().setLastTransition(plotId, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an immutable list of all plots.
|
||||
*/
|
||||
public List<SpatialStoragePlot> getPlots() {
|
||||
return getWorldData().getPlots();
|
||||
}
|
||||
|
||||
public void freePlot(int plotId, boolean resetBlocks) {
|
||||
SpatialStoragePlot plot = getPlot(plotId);
|
||||
if (plot == null) {
|
||||
return; // Already removed apparently
|
||||
}
|
||||
|
||||
if (resetBlocks) {
|
||||
BlockPos from = plot.getOrigin();
|
||||
BlockPos to = from.add(plot.getSize()).add(-1, -1, -1);
|
||||
|
||||
AELog.info("Clearing spatial storage plot %s (%s -> %s)", plotId, from, to);
|
||||
|
||||
// This is slow, but it should usually be just an admin-command
|
||||
ServerWorld world = getWorld();
|
||||
BlockState matrixFrame = Api.instance().definitions().blocks().matrixFrame().block().getDefaultState();
|
||||
for (BlockPos blockPos : BlockPos.getAllInBoxMutable(from, to)) {
|
||||
world.setBlockState(blockPos, matrixFrame);
|
||||
}
|
||||
}
|
||||
|
||||
getWorldData().removePlot(plotId);
|
||||
}
|
||||
|
||||
private static MinecraftServer getServer() {
|
||||
return ServerLifecycleHooks.getCurrentServer();
|
||||
}
|
||||
|
||||
}
|
||||
+4
-1
@@ -7,8 +7,11 @@ import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* Defines properties for how the sky in the spatial storage world is rendered.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class StorageSkyProperties {
|
||||
public class SpatialStorageSkyProperties {
|
||||
|
||||
// See the fabric version of this to get any idea what its doing
|
||||
public static final DimensionRenderInfo INSTANCE = new DimensionRenderInfo(Float.NaN /* disables clouds */, false,
|
||||
@@ -0,0 +1,110 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import appeng.core.AELog;
|
||||
|
||||
/**
|
||||
* Extra data attached to the spatial storage world.
|
||||
*/
|
||||
public class SpatialStorageWorldData extends WorldSavedData {
|
||||
|
||||
/**
|
||||
* ID of this data when it is attached to a world.
|
||||
*/
|
||||
public static final String ID = "ae2_spatial_storage";
|
||||
|
||||
// Used to allow forward compatibility
|
||||
private static final int CURRENT_FORMAT = 2;
|
||||
|
||||
private static final String TAG_FORMAT = "format";
|
||||
|
||||
private static final String TAG_PLOTS = "plots";
|
||||
|
||||
private final Int2ObjectOpenHashMap<SpatialStoragePlot> plots = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public SpatialStorageWorldData() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
public SpatialStoragePlot getPlotById(int id) {
|
||||
return plots.get(id);
|
||||
}
|
||||
|
||||
public List<SpatialStoragePlot> getPlots() {
|
||||
return ImmutableList.copyOf(plots.values());
|
||||
}
|
||||
|
||||
public SpatialStoragePlot allocatePlot(BlockPos size, int owner) {
|
||||
|
||||
int nextId = 1;
|
||||
for (int id : plots.keySet()) {
|
||||
if (id >= nextId) {
|
||||
nextId = id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
SpatialStoragePlot plot = new SpatialStoragePlot(nextId, size, owner);
|
||||
plots.put(nextId, plot);
|
||||
markDirty();
|
||||
return plot;
|
||||
}
|
||||
|
||||
public void removePlot(int plotId) {
|
||||
plots.remove(plotId);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setLastTransition(int plotId, TransitionInfo info) {
|
||||
SpatialStoragePlot plot = plots.get(plotId);
|
||||
if (plot != null) {
|
||||
plot.setLastTransition(info);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
int version = tag.getInt(TAG_FORMAT);
|
||||
if (version != CURRENT_FORMAT) {
|
||||
// Currently no new format has been defined, as such anything but the current
|
||||
// version is invalid
|
||||
throw new IllegalStateException("Invalid AE2 spatial info version: " + version);
|
||||
}
|
||||
|
||||
ListNBT plotsTag = tag.getList(TAG_PLOTS, Constants.NBT.TAG_COMPOUND);
|
||||
for (INBT plotTag : plotsTag) {
|
||||
SpatialStoragePlot plot = SpatialStoragePlot.fromTag((CompoundNBT) plotTag);
|
||||
|
||||
if (plots.containsKey(plot.getId())) {
|
||||
AELog.warn("Overwriting duplicate plot id %s", plot.getId());
|
||||
}
|
||||
plots.put(plot.getId(), plot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
tag.putInt(TAG_FORMAT, CURRENT_FORMAT);
|
||||
|
||||
ListNBT plotTags = new ListNBT();
|
||||
for (SpatialStoragePlot plot : plots.values()) {
|
||||
plotTags.add(plot.toTag());
|
||||
}
|
||||
tag.put(TAG_PLOTS, plotTags);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Defines the source world and area of a transition into the spatial storage
|
||||
* plot.
|
||||
*/
|
||||
public final class TransitionInfo {
|
||||
|
||||
public static final String TAG_WORLD_ID = "world_id";
|
||||
public static final String TAG_MIN = "min";
|
||||
public static final String TAG_MAX = "max";
|
||||
public static final String TAG_TIMESTAMP = "timestamp";
|
||||
|
||||
private final ResourceLocation worldId;
|
||||
|
||||
private final BlockPos min;
|
||||
|
||||
private final BlockPos max;
|
||||
|
||||
private final Instant timestamp;
|
||||
|
||||
public TransitionInfo(ResourceLocation worldId, BlockPos min, BlockPos max, Instant timestamp) {
|
||||
this.worldId = worldId;
|
||||
this.min = min.toImmutable();
|
||||
this.max = max.toImmutable();
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public ResourceLocation getWorldId() {
|
||||
return worldId;
|
||||
}
|
||||
|
||||
public BlockPos getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public BlockPos getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public CompoundNBT toTag() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putString(TAG_WORLD_ID, worldId.toString());
|
||||
tag.put(TAG_MIN, NBTUtil.writeBlockPos(min));
|
||||
tag.put(TAG_MAX, NBTUtil.writeBlockPos(max));
|
||||
tag.putLong(TAG_TIMESTAMP, timestamp.toEpochMilli());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static TransitionInfo fromTag(CompoundNBT tag) {
|
||||
ResourceLocation worldId = new ResourceLocation(tag.getString(TAG_WORLD_ID));
|
||||
BlockPos min = NBTUtil.readBlockPos(tag.getCompound(TAG_MIN));
|
||||
BlockPos max = NBTUtil.readBlockPos(tag.getCompound(TAG_MAX));
|
||||
Instant timestamp = Instant.ofEpochMilli(tag.getLong(TAG_TIMESTAMP));
|
||||
return new TransitionInfo(worldId, min, max, timestamp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -135,14 +134,18 @@ public class SpatialIOPortTileEntity extends AENetworkInvTileEntity implements I
|
||||
if (Math.abs(pr - req) < req * 0.001) {
|
||||
final MENetworkEvent res = gi.postEvent(new MENetworkSpatialEvent(this, req));
|
||||
if (!res.isCanceled()) {
|
||||
int playerId = -1;
|
||||
// Prefer player id from security system, but if unavailable, use the
|
||||
// player who placed the grid node (if any)
|
||||
int playerId;
|
||||
if (this.getProxy().getSecurity().isAvailable()) {
|
||||
playerId = this.getProxy().getSecurity().getOwner();
|
||||
} else {
|
||||
playerId = this.getProxy().getNode().getPlayerID();
|
||||
}
|
||||
|
||||
final TransitionResult tr = sc.doSpatialTransition(cell, serverWorld, spc.getMin(),
|
||||
spc.getMax(), playerId);
|
||||
if (tr.success) {
|
||||
boolean success = sc.doSpatialTransition(cell, serverWorld, spc.getMin(), spc.getMax(),
|
||||
playerId);
|
||||
if (success) {
|
||||
energy.extractAEPower(req, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.inv.setStackInSlot(0, ItemStack.EMPTY);
|
||||
this.inv.setStackInSlot(1, cell);
|
||||
|
||||
@@ -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,13 @@ 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,
|
||||
// unless world generation is actually invoked, which means that chunks may
|
||||
// be loaded without this being registered as a structure piece!
|
||||
}
|
||||
|
||||
private PlacedMeteoriteSettings settings;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.75,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"
|
||||
|
||||
@@ -5,13 +5,25 @@
|
||||
"refmap": "appliedenergistics2.mixins.refmap.json",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"DimensionTypeMixin",
|
||||
"MinecraftServerMixin",
|
||||
"ThreadedAnvilChunkStorageAccessor",
|
||||
"DimensionStructuresSettingsMixin",
|
||||
"StructureAccessor"
|
||||
"spatial.DimensionTypeMixin",
|
||||
"spatial.DimensionOptionMixin",
|
||||
"spatial.EntityMixin",
|
||||
"spatial.BiomesMixin",
|
||||
"structure.DimensionStructuresSettingsMixin",
|
||||
"structure.ConfiguredStructureFeaturesAccessor",
|
||||
"structure.StructureFeatureAccessor",
|
||||
"structure.GenerationSettingsAccessor",
|
||||
"structure.BiomeAccessor",
|
||||
"feature.ConfiguredFeaturesAccessor"
|
||||
],
|
||||
"client": [
|
||||
"spatial.SkyRenderMixin",
|
||||
"spatial.SkyPropertiesMixin",
|
||||
"unlitquad.ModelBakeryMixin",
|
||||
"unlitquad.BlockModelMixin",
|
||||
"unlitquad.BlockPartFaceDeserializerMixin",
|
||||
"unlitquad.BakedQuadAccessor"
|
||||
],
|
||||
"client": ["SkyRenderMixin", "SkyPropertiesMixin"],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"loader": "appliedenergistics2:uvlightmap",
|
||||
"parent": "block/block",
|
||||
"textures": {
|
||||
"block": "block/stone",
|
||||
@@ -42,50 +41,32 @@
|
||||
"down": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "down",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
},
|
||||
"east": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "east",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
},
|
||||
"north": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "north",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
},
|
||||
"south": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "south",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
},
|
||||
"up": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "up",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
},
|
||||
"west": {
|
||||
"texture": "#quartz",
|
||||
"cullface": "west",
|
||||
"uvlightmap": {
|
||||
"block": 0.007,
|
||||
"sky": 0.007
|
||||
}
|
||||
"unlit": true
|
||||
}
|
||||
},
|
||||
"from": [0, 0, 0],
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user