More fixes

This commit is contained in:
Sebastian Hartte
2020-06-29 21:23:50 +02:00
parent 0d63f560d3
commit ca104912d6
121 changed files with 2623 additions and 2563 deletions
@@ -0,0 +1,202 @@
/*
* 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.block.misc;
import java.util.EnumMap;
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.effects.ParticleTypes;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.helpers.MetaRotation;
public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock {
// Cache VoxelShapes for each facing
private static final Map<Direction, VoxelShape> SHAPES;
static {
SHAPES = new EnumMap<>(Direction.class);
for (Direction facing : Direction.values()) {
final double xOff = -0.3 * facing.getOffsetX();
final double yOff = -0.3 * facing.getOffsetY();
final double zOff = -0.3 * facing.getOffsetZ();
VoxelShape shape = VoxelShapes
.cuboid(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
SHAPES.put(facing, shape);
}
}
// Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final DirectionProperty FACING = Properties.FACING;
// Used to alternate between two variants of the fixture on adjacent blocks
public static final BooleanProperty ODD = BooleanProperty.of("odd");
public QuartzFixtureBlock() {
super(defaultProps(Material.SUPPORTED).noCollision().strength(0).lightLevel(14)
.sounds(BlockSoundGroup.GLASS));
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING, ODD);
}
// For reference, see WallTorchBlock
@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext context) {
BlockState blockstate = super.getPlacementState(context);
BlockPos pos = context.getBlockPos();
// Set the even/odd property
boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0;
blockstate = blockstate.with(ODD, oddPlacement);
WorldView iworldreader = context.getWorld();
Direction[] adirection = context.getPlacementDirections();
for (Direction direction : adirection) {
if (canPlaceAt(iworldreader, pos, direction)) {
return blockstate.with(FACING, direction.getOpposite());
}
}
return null;
}
// Break the fixture if the block it is attached to is changed so that it could
// no longer be placed
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState facingState, WorldAccess worldIn,
BlockPos pos, BlockPos facingPos) {
Direction fixtureFacing = state.get(FACING);
if (facing.getOpposite() == fixtureFacing && !canPlaceAt(worldIn, pos, facing)) {
return Blocks.AIR.getDefaultState();
}
return state;
}
@Override
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
// FIXME: I think this entire method -> not required, but not sure... are quartz
// fixtures rotateable???
return this.canPlaceAt(w, pos, up.getOpposite());
}
private boolean canPlaceAt(final WorldView w, final BlockPos pos, final Direction dir) {
final BlockPos test = pos.offset(dir);
BlockState blockstate = w.getBlockState(test);
return blockstate.isSideSolidFullSquare(w, test, dir.getOpposite());
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
Direction facing = state.get(FACING);
return SHAPES.get(facing);
}
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
if (!AEConfig.instance().isEnableEffects()) {
return;
}
if (r.nextFloat() < 0.98) {
return;
}
final Direction up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getOffsetX();
final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getOffsetZ();
for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.instance().shouldAddParticles(r)) {
w.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(),
zOff + 0.5 + pos.getZ(), 0, 0, 0);
}
}
}
// FIXME: Replaced by the postPlaceupdate stuff above, but check item drops!
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final Direction up = this.getOrientable(world, pos).getUp();
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
this.dropTorch(world, pos);
}
}
private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos);
w.breakBlock(pos, true);
w.updateListeners(pos, prev, w.getBlockState(pos), 3);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView w, BlockPos pos) {
for (final Direction dir : Direction.values()) {
if (this.canPlaceAt(w, pos, dir)) {
return true;
}
}
return false;
}
@Override
public IOrientable getOrientable(final BlockView w, final BlockPos pos) {
return new MetaRotation(w, pos, FACING);
}
}
@@ -0,0 +1,37 @@
/*
* 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.block.misc;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import appeng.bootstrap.TileEntityRendering;
import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.SkyCompassTESR;
import appeng.tile.misc.SkyCompassBlockEntity;
public class SkyCompassRendering implements TileEntityRenderingCustomizer<SkyCompassBlockEntity> {
@Override
@Environment(EnvType.CLIENT)
public void customize(TileEntityRendering<SkyCompassBlockEntity> rendering) {
rendering.tileEntityRenderer(SkyCompassTESR::new);
}
}
@@ -0,0 +1,145 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block.misc;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.entity.TinyTNTPrimedEntity;
public class TinyTNTBlock extends AEBaseBlock {
private static final VoxelShape SHAPE = VoxelShapes
.cuboid(new Box(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f));
public TinyTNTBlock(Settings props) {
super(props);
}
@Override
public int getOpacity(BlockState state, BlockView worldIn, BlockPos pos) {
return 2; // FIXME: Validate that this is the correct value range
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
return SHAPE;
}
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
this.startFuse(w, pos, player);
w.removeBlock(pos, false);
heldItem.damage(1, player, p -> {
p.sendToolBreakStatus(hand);
}); // FIXME Check if onBroken is equivalent
return ActionResult.SUCCESS;
} else {
return super.onActivated(w, pos, player, hand, heldItem, hit);
}
}
public void startFuse(final World w, final BlockPos pos, final LivingEntity igniter) {
if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
w.spawnEntity(primedTinyTNTEntity);
w.playSound(null, primedTinyTNTEntity.getX(), primedTinyTNTEntity.getY(),
primedTinyTNTEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1);
}
}
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (world.isReceivingRedstonePower(pos)) {
this.startFuse(world, pos, null);
world.removeBlock(pos, false);
}
}
@Override
public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) {
super.onBlockAdded(state, w, pos, oldState, isMoving);
if (w.getReceivedStrongRedstonePower(pos) > 0) {
this.startFuse(w, pos, null);
w.removeBlock(pos, false);
}
}
@Override
public void onSteppedOn(final World w, final BlockPos pos, final Entity entity) {
if (entity instanceof PersistentProjectileEntity && !w.isClient) {
final PersistentProjectileEntity entityarrow = (PersistentProjectileEntity) entity;
if (entityarrow.isOnFire()) {
LivingEntity igniter = null;
// Check if the shooter still exists
Entity shooter = entityarrow.getOwner();
if (shooter instanceof LivingEntity) {
igniter = (LivingEntity) shooter;
}
this.startFuse(w, pos, igniter);
w.removeBlock(pos, false);
}
}
}
@Override
public boolean shouldDropItemsOnExplosion(final Explosion exp) {
return false;
}
@Override
public void onDestroyedByExplosion(final World w, final BlockPos pos, final Explosion exp) {
super.onDestroyedByExplosion(w, pos, exp);
if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getCausingEntity());
primedTinyTNTEntity
.setFuse(w.random.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
w.spawnEntity(primedTinyTNTEntity);
}
}
}
@@ -103,11 +103,11 @@ public class BlockEntityBuilder<T extends AEBaseBlockEntity> {
baseTileBlock.setTileEntity(tileClass, factory);
}
}
});
if (Platform.hasClientClasses()) {
buildClient();
}
if (Platform.hasClientClasses()) {
buildClient();
}
});
return new TileEntityDefinition(this::addBlock);
@@ -115,11 +115,9 @@ public class BlockEntityBuilder<T extends AEBaseBlockEntity> {
@Environment(EnvType.CLIENT)
private void buildClient() {
this.factory.addBootstrapComponent((IClientSetupComponent) () -> {
if (tileEntityRendering.tileEntityRenderer != null) {
BlockEntityRendererRegistry.INSTANCE.register(type, tileEntityRendering.tileEntityRenderer);
}
});
if (tileEntityRendering.tileEntityRenderer != null) {
BlockEntityRendererRegistry.INSTANCE.register(type, tileEntityRendering.tileEntityRenderer);
}
}
private void addBlock(Block block) {
@@ -7,6 +7,6 @@ import appeng.bootstrap.IBootstrapComponent;
public interface IItemColorRegistrationComponent extends IBootstrapComponent {
void register(ItemColors itemColors, BlockColors blockColors);
void register();
}
@@ -18,6 +18,7 @@
package appeng.bootstrap.components;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.client.color.item.ItemColors;
@@ -34,7 +35,7 @@ public class ItemColorComponent implements IItemColorRegistrationComponent {
}
@Override
public void register(ItemColors itemColors, BlockColors blockColors) {
itemColors.register(this.itemColor, this.item);
public void register() {
ColorProviderRegistry.ITEM.register(itemColor, item);
}
}
@@ -0,0 +1,166 @@
package appeng.client;
import appeng.api.parts.CableRenderMode;
import appeng.block.AEBaseBlock;
import appeng.bootstrap.ModelsReloadCallback;
import appeng.bootstrap.components.IItemColorRegistrationComponent;
import appeng.bootstrap.components.IModelBakeComponent;
import appeng.client.render.effects.*;
import appeng.client.render.tesr.SkyChestTESR;
import appeng.core.Api;
import appeng.core.ApiDefinitions;
import appeng.core.AppEngBase;
import appeng.core.sync.BasePacket;
import appeng.entity.*;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.entity.ItemEntityRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.HitResult;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class AppEngClient extends AppEngBase {
private final MinecraftClient client;
public AppEngClient() {
super();
client = MinecraftClient.getInstance();
ModelsReloadCallback.EVENT.register(this::onModelsReloaded);
registerParticleRenderers();
registerEntityRenderers();
registerItemColors();
registerTextures();
}
@Override
public void bindTileEntitySpecialRenderer(Class<? extends BlockEntity> tile, AEBaseBlock blk) {
}
@Override
public List<? extends PlayerEntity> getPlayers() {
return null;
}
@Override
public void sendToAllNearExcept(PlayerEntity p, double x, double y, double z, double dist, World w, BasePacket packet) {
}
@Override
public void spawnEffect(EffectType effect, World world, double posX, double posY, double posZ, Object extra) {
}
@Override
public boolean shouldAddParticles(Random r) {
return false;
}
@Override
public HitResult getRTR() {
return null;
}
@Override
public void postInit() {
}
@Override
public CableRenderMode getRenderMode() {
return null;
}
@Override
public void triggerUpdates() {
}
@Override
public void updateRenderMode(PlayerEntity player) {
}
@Override
public boolean isActionKey(@Nonnull ActionKey key, InputUtil.Key input) {
return false;
}
protected void registerParticleRenderers() {
ParticleFactoryRegistry particles = ParticleFactoryRegistry.getInstance();
particles.register(ParticleTypes.CHARGED_ORE, ChargedOreFX.Factory::new);
particles.register(ParticleTypes.CRAFTING, CraftingFx.Factory::new);
particles.register(ParticleTypes.ENERGY, EnergyFx.Factory::new);
particles.register(ParticleTypes.LIGHTNING_ARC, LightningArcFX.Factory::new);
particles.register(ParticleTypes.LIGHTNING, LightningFX.Factory::new);
particles.register(ParticleTypes.MATTER_CANNON, MatterCannonFX.Factory::new);
particles.register(ParticleTypes.VIBRANT, VibrantFX.Factory::new);
}
protected void registerEntityRenderers() {
EntityRendererRegistry registry = EntityRendererRegistry.INSTANCE;
registry.register(TinyTNTPrimedEntity.TYPE, (dispatcher, context) -> new TinyTNTPrimedRenderer(dispatcher));
EntityRendererRegistry.Factory itemEntityFactory = (dispatcher, context) -> new ItemEntityRenderer(dispatcher, context.getItemRenderer());
registry.register(SingularityEntity.TYPE, itemEntityFactory);
registry.register(GrowingCrystalEntity.TYPE, itemEntityFactory);
registry.register(ChargedQuartzEntity.TYPE, itemEntityFactory);
}
protected void registerItemColors() {
// TODO: Do not use the internal API
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(IItemColorRegistrationComponent.class)
.forEachRemaining(IItemColorRegistrationComponent::register);
}
protected void onModelsReloaded(Map<Identifier, BakedModel> loadedModels) {
// TODO: Do not use the internal API
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(IModelBakeComponent.class)
.forEachRemaining(c -> c.onModelsReloaded(loadedModels));
}
public void registerTextures() {
// FIXME FABRIC InscriberTESR.registerTexture();
Stream<Collection<SpriteIdentifier>> sprites = Stream.of(
SkyChestTESR.SPRITES
);
// Group every needed sprite by atlas, since every atlas has their own event
Map<Identifier, List<SpriteIdentifier>> groupedByAtlas = sprites.flatMap(Collection::stream)
.collect(Collectors.groupingBy(SpriteIdentifier::getAtlasId));
// Register to the stitch event for each atlas
for (Map.Entry<Identifier, List<SpriteIdentifier>> entry : groupedByAtlas.entrySet()) {
ClientSpriteRegistryCallback.event(entry.getKey())
.register((spriteAtlasTexture, registry) -> {
for (SpriteIdentifier spriteIdentifier : entry.getValue()) {
registry.register(spriteIdentifier.getTextureId());
}
});
}
}
}
@@ -0,0 +1,116 @@
/*
* 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;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
/**
* TODO: Removed useless stuff.
*/
public enum FacingToRotation implements StringIdentifiable {
// DUNSWE
// @formatter:off
DOWN_DOWN(new Vector3f(0, 0, 0)), // NOOP
DOWN_UP(new Vector3f(0, 0, 0)), // NOOP
DOWN_NORTH(new Vector3f(-90, 0, 0)), DOWN_SOUTH(new Vector3f(-90, 0, 180)), DOWN_WEST(new Vector3f(-90, 0, 90)),
DOWN_EAST(new Vector3f(-90, 0, -90)), UP_DOWN(new Vector3f(0, 0, 0)), // NOOP
UP_UP(new Vector3f(0, 0, 0)), // NOOP
UP_NORTH(new Vector3f(90, 0, 180)), UP_SOUTH(new Vector3f(90, 0, 0)), UP_WEST(new Vector3f(90, 0, 90)),
UP_EAST(new Vector3f(90, 0, -90)), NORTH_DOWN(new Vector3f(0, 0, 180)), NORTH_UP(new Vector3f(0, 0, 0)),
NORTH_NORTH(new Vector3f(0, 0, 0)), // NOOP
NORTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP
NORTH_WEST(new Vector3f(0, 0, 90)), NORTH_EAST(new Vector3f(0, 0, -90)), SOUTH_DOWN(new Vector3f(0, 180, 180)),
SOUTH_UP(new Vector3f(0, 180, 0)), SOUTH_NORTH(new Vector3f(0, 0, 0)), // NOOP
SOUTH_SOUTH(new Vector3f(0, 0, 0)), // NOOP
SOUTH_WEST(new Vector3f(0, 180, -90)), SOUTH_EAST(new Vector3f(0, 180, 90)), WEST_DOWN(new Vector3f(0, 90, 180)),
WEST_UP(new Vector3f(0, 90, 0)), WEST_NORTH(new Vector3f(0, 90, -90)), WEST_SOUTH(new Vector3f(0, 90, 90)),
WEST_WEST(new Vector3f(0, 0, 0)), // NOOP
WEST_EAST(new Vector3f(0, 0, 0)), // NOOP
EAST_DOWN(new Vector3f(0, -90, 180)), EAST_UP(new Vector3f(0, -90, 0)), EAST_NORTH(new Vector3f(0, -90, 90)),
EAST_SOUTH(new Vector3f(0, -90, -90)), EAST_WEST(new Vector3f(0, 0, 0)), // NOOP
EAST_EAST(new Vector3f(0, 0, 0)); // NOOP
// @formatter:on
private final Vector3f rot;
private final Quaternion xRot;
private final Quaternion yRot;
private final Quaternion zRot;
private final Matrix4f mat;
private FacingToRotation(Vector3f rot) {
this.rot = rot;
this.mat = new Matrix4f();
this.mat.loadIdentity();
this.mat.multiply(xRot = Vector3f.POSITIVE_X.getDegreesQuaternion(rot.getX()));
this.mat.multiply(yRot = Vector3f.POSITIVE_Y.getDegreesQuaternion(rot.getY()));
this.mat.multiply(zRot = Vector3f.POSITIVE_Z.getDegreesQuaternion(rot.getZ()));
}
public boolean isRedundant() {
return rot.getX() == 0 && rot.getY() == 0 && rot.getZ() == 0;
}
public Vector3f getRot() {
return this.rot;
}
public Matrix4f getMat() {
return new Matrix4f(this.mat);
}
public void push(MatrixStack mStack) {
mStack.multiply(xRot);
mStack.multiply(yRot);
mStack.multiply(zRot);
}
public Direction rotate(Direction facing) {
Vec3i dir = facing.getVector();
Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 1);
vec.transform(mat);
return Direction.getFacing(vec.getX(), vec.getY(), vec.getZ());
}
public Direction resultingRotate(Direction facing) {
for (Direction face : Direction.values()) {
if (this.rotate(face) == facing) {
return face;
}
}
return null;
}
public static FacingToRotation get(Direction forward, Direction up) {
return values()[forward.ordinal() * 6 + up.ordinal()];
}
@Override
public String asString() {
return name().toLowerCase();
}
}
@@ -1,6 +1,11 @@
package appeng.client.render.effects;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.ParticleType;
@@ -22,14 +27,8 @@ public final class ParticleTypes {
public static final DefaultParticleType MATTER_CANNON = FabricParticleTypes.simple(false);
public static final DefaultParticleType VIBRANT = FabricParticleTypes.simple(false);
public static void register() {
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("charged_ore_fx"), CHARGED_ORE);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("crafting_fx"), CRAFTING);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("energy_fx"), ENERGY);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("lightning_arc_fx"), LIGHTNING_ARC);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("lightning_fx"), LIGHTNING);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("matter_cannon_fx"), MATTER_CANNON);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("vibrant_fx"), VIBRANT);
public static void registerClient() {
}
}
@@ -0,0 +1,124 @@
/*
* 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.tesr;
import appeng.block.storage.SkyChestBlock;
import appeng.block.storage.SkyChestBlock.SkyChestType;
import appeng.core.AppEng;
import appeng.tile.storage.SkyChestBlockEntity;
import com.google.common.collect.ImmutableList;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
// This is mostly a copy&paste job of the vanilla chest TESR
@Environment(EnvType.CLIENT)
public class SkyChestTESR extends BlockEntityRenderer<SkyChestBlockEntity> {
public static final SpriteIdentifier TEXTURE_STONE = new SpriteIdentifier(TexturedRenderLayers.CHEST_ATLAS_TEXTURE,
new Identifier(AppEng.MOD_ID, "models/skychest"));
public static final SpriteIdentifier TEXTURE_BLOCK = new SpriteIdentifier(TexturedRenderLayers.CHEST_ATLAS_TEXTURE,
new Identifier(AppEng.MOD_ID, "models/skyblockchest"));
public static final ImmutableList<SpriteIdentifier> SPRITES = ImmutableList.of(
TEXTURE_STONE,
TEXTURE_BLOCK
);
private final ModelPart singleLid;
private final ModelPart singleBottom;
private final ModelPart singleLatch;
public SkyChestTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
this.singleBottom = new ModelPart(64, 64, 0, 19);
this.singleBottom.addCuboid(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
this.singleLid = new ModelPart(64, 64, 0, 0);
this.singleLid.addCuboid(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
this.singleLid.pivotY = 9.0F;
this.singleLid.pivotZ = 1.0F;
this.singleLatch = new ModelPart(64, 64, 0, 0);
this.singleLatch.addCuboid(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
this.singleLatch.pivotY = 8.0F;
}
@Override
public void render(SkyChestBlockEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn,
VertexConsumerProvider bufferIn, int combinedLightIn, int combinedOverlayIn) {
matrixStackIn.push();
float f = tileEntityIn.getForward().asRotation();
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
matrixStackIn.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-f));
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
float f1 = tileEntityIn.getAnimationProgress(partialTicks);
f1 = 1.0F - f1;
f1 = 1.0F - f1 * f1 * f1;
SpriteIdentifier material = this.getMaterial(tileEntityIn);
VertexConsumer ivertexbuilder = material.getVertexConsumer(bufferIn, RenderLayer::getEntityCutout);
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1,
combinedLightIn, combinedOverlayIn);
matrixStackIn.pop();
}
// See ChestBlockEntityRenderer
private void renderModels(MatrixStack matrixStackIn, VertexConsumer bufferIn, ModelPart chestLid,
ModelPart chestLatch, ModelPart chestBottom, float lidAngle, int combinedLightIn,
int combinedOverlayIn) {
chestLid.pitch = -(lidAngle * 1.5707964F);
chestLatch.pitch = chestLid.pitch;
chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
chestLatch.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
chestBottom.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
}
protected SpriteIdentifier getMaterial(SkyChestBlockEntity tileEntity) {
SkyChestType type = SkyChestType.BLOCK;
if (tileEntity.getWorld() != null) {
Block blockType = tileEntity.getCachedState().getBlock();
if (blockType instanceof SkyChestBlock) {
type = ((SkyChestBlock) blockType).type;
}
}
switch (type) {
case STONE:
return TEXTURE_STONE;
default:
case BLOCK:
return TEXTURE_BLOCK;
}
}
}
@@ -0,0 +1,108 @@
/*
* 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.tesr;
import net.fabricmc.api.EnvType;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.util.math.Direction;
import net.fabricmc.api.Environment;
import appeng.client.render.FacingToRotation;
import appeng.tile.misc.SkyCompassBlockEntity;
@Environment(EnvType.CLIENT)
public class SkyCompassTESR extends BlockEntityRenderer<SkyCompassBlockEntity> {
private static BlockRenderManager blockRenderer;
public SkyCompassTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(SkyCompassBlockEntity te, float partialTicks, MatrixStack ms, VertexConsumerProvider buffers,
int combinedLightIn, int combinedOverlayIn) {
if (blockRenderer == null) {
blockRenderer = MinecraftClient.getInstance().getBlockRenderManager();
}
VertexConsumer buffer = buffers.getBuffer(TexturedRenderLayers.getEntityTranslucentCull());
BlockState blockState = te.getCachedState();
BakedModel model = blockRenderer.getModels().getModel(blockState);
// FIXME: Rotation was previously handled by an auto rotating model I think, but
// FIXME: Should be handled using matrices instead
Direction forward = te.getForward();
Direction up = te.getUp();
// This ensures the needle isn't flipped by the model rotator. Since the model
// is symmetrical, this should
// not affect the appearance
if (forward == Direction.UP || forward == Direction.DOWN) {
up = Direction.NORTH;
}
// Flip forward/up for rendering, the base model is facing up without any
// rotation
ms.push();
ms.translate(0.5D, 0.5D, 0.5D);
FacingToRotation.get(up, forward).push(ms);
ms.translate(-0.5D, -0.5D, -0.5D);
// FIXME FABRIC ModelDataMap modelData = new ModelDataMap.Builder().withInitial(SkyCompassBakedModel.ROTATION, getRotation(te)).build();
blockRenderer.getModelRenderer().render(ms.peek(), buffer, null, model, 1, 1, 1, combinedLightIn,
combinedOverlayIn);
ms.pop();
}
// FIXME FABRIC This needs to go to the tile entity (?)
private static float getRotation(SkyCompassBlockEntity skyCompass) {
float rotation = 0;
if (skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN) {
// FIXME FABRIC rotation = SkyCompassBakedModel.getAnimatedRotation(skyCompass.getPos(), false);
} else {
// FIXME FABRIC rotation = SkyCompassBakedModel.getAnimatedRotation(null, false);
}
if (skyCompass.getForward() == Direction.DOWN) {
// FIXME FABRIC rotation = flipidiy(rotation);
}
return rotation;
}
private static float flipidiy(float rad) {
float x = (float) Math.cos(rad);
float y = (float) Math.sin(rad);
return (float) Math.atan2(-y, x);
}
}
+8 -1
View File
@@ -35,7 +35,7 @@ public final class AEConfig {
public final ClientConfig clientConfig;
public final CommonConfig commonConfig;
public AEConfig(File configDir) {
AEConfig(File configDir) {
ConfigSection clientRoot = ConfigSection.createRoot();
clientConfig = new ClientConfig(clientRoot);
syncClientConfig();
@@ -57,6 +57,13 @@ public final class AEConfig {
// Config instance
private static AEConfig instance;
static void load(File configFolder) {
if (instance != null) {
throw new IllegalStateException();
}
instance = new AEConfig(configFolder);
}
private final EnumSet<AEFeature> featureFlags = EnumSet.noneOf(AEFeature.class);
// Misc
+86
View File
@@ -0,0 +1,86 @@
/*
* 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.core;
import appeng.api.IAppEngApi;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper;
import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
import appeng.core.api.ApiClientHelper;
import appeng.core.api.ApiGrid;
import appeng.core.api.ApiPart;
import appeng.core.api.ApiStorage;
import appeng.core.features.registries.PartModels;
import appeng.core.features.registries.RegistryContainer;
public final class Api implements IAppEngApi {
public static Api INSTANCE;
private final ApiPart partHelper;
private final IRegistryContainer registryContainer;
private final IStorageHelper storageHelper;
private final IGridHelper networkHelper;
private final ApiDefinitions definitions;
private final IClientHelper client;
Api() {
this.storageHelper = new ApiStorage();
this.networkHelper = new ApiGrid();
this.registryContainer = new RegistryContainer();
this.partHelper = new ApiPart();
this.definitions = new ApiDefinitions((PartModels) this.registryContainer.partModels());
this.client = new ApiClientHelper();
}
public PartModels getPartModels() {
return (PartModels) this.registryContainer.partModels();
}
@Override
public IRegistryContainer registries() {
return this.registryContainer;
}
@Override
public IStorageHelper storage() {
return this.storageHelper;
}
@Override
public IGridHelper grid() {
return this.networkHelper;
}
@Override
public ApiPart partHelper() {
return this.partHelper;
}
@Override
public ApiDefinitions definitions() {
return this.definitions;
}
@Override
public IClientHelper client() {
return this.client;
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItems;
import appeng.api.definitions.IMaterials;
import appeng.api.definitions.IParts;
import appeng.bootstrap.FeatureFactory;
import appeng.core.api.definitions.ApiBlocks;
import appeng.core.api.definitions.ApiItems;
import appeng.core.api.definitions.ApiMaterials;
import appeng.core.api.definitions.ApiParts;
import appeng.core.features.registries.PartModels;
/**
* Internal implementation of the definitions for the API
*/
public final class ApiDefinitions implements IDefinitions {
private final ApiBlocks blocks;
private final ApiItems items;
private final ApiMaterials materials;
private final ApiParts parts;
private final FeatureFactory registry = new FeatureFactory();
public ApiDefinitions(final PartModels partModels) {
this.blocks = new ApiBlocks(this.registry);
this.materials = new ApiMaterials(this.registry);
this.items = new ApiItems(this.registry, this.materials);
this.parts = new ApiParts(this.registry, partModels);
}
public FeatureFactory getRegistry() {
return registry;
}
@Override
public ApiBlocks blocks() {
return this.blocks;
}
@Override
public IItems items() {
return items;
}
@Override
public IMaterials materials() {
return materials;
}
@Override
public IParts parts() {
return parts;
}
}
+5 -23
View File
@@ -36,9 +36,13 @@ import java.util.Random;
public interface AppEng {
String MOD_NAME = "Applied Energistics 2";
String MOD_ID = "appliedenergistics2";
AppEng INSTANCE = null;
static AppEng instance() {
return AppEngHolder.INSTANCE;
}
static Identifier makeId(String id) {
return new Identifier(MOD_ID, id);
@@ -68,28 +72,14 @@ public interface AppEng {
boolean isActionKey(@Nonnull final ActionKey key, InputUtil.Key input);
// public static final String MOD_NAME = "Applied Energistics 2";
//
// private static AppEng INSTANCE;
//
// private final Registration registration;
//
// public AppEng() {
// if (INSTANCE != null) {
// throw new IllegalStateException();
// }
// INSTANCE = this;
// ParticleTypes.register();
// ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
// ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AEConfig.COMMON_SPEC);
//
// proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
//
// CrashReportExtender.registerCrashCallable(new ModCrashEnhancement());
//
// CreativeTab.init();
// new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
//
// IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// registration = new Registration();
// modEventBus.addGenericListener(Block.class, registration::registerBlocks);
@@ -142,14 +132,6 @@ public interface AppEng {
//
// ((ClientHelper) proxy).clientInit();
//
// RenderingRegistry.registerEntityRenderingHandler(TinyTNTPrimedEntity.TYPE, TinyTNTPrimedRenderer::new);
// RenderingRegistry.registerEntityRenderingHandler(SingularityEntity.TYPE,
// m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
// RenderingRegistry.registerEntityRenderingHandler(GrowingCrystalEntity.TYPE,
// m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
// RenderingRegistry.registerEntityRenderingHandler(ChargedQuartzEntity.TYPE,
// m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
//
// // TODO: Do not use the internal API
// final ApiDefinitions definitions = Api.INSTANCE.definitions();
// definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
@@ -0,0 +1,91 @@
package appeng.core;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.pathing.IPathingGrid;
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.bootstrap.components.ITileEntityRegistrationComponent;
import appeng.client.render.effects.ParticleTypes;
import appeng.core.features.registries.cell.BasicCellHandler;
import appeng.core.features.registries.cell.BasicItemCellGuiHandler;
import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.stats.AdvancementTriggers;
import appeng.core.stats.AeStats;
import appeng.hooks.ToolItemHook;
import appeng.mixins.CriteriaRegisterMixin;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.registry.Registry;
public abstract class AppEngBase implements AppEng {
protected AdvancementTriggers advancementTriggers;
public AppEngBase() {
if (AppEng.instance() != null) {
throw new IllegalStateException();
}
AEConfig.load(FabricLoader.getInstance().getConfigDirectory());
CreativeTab.init();
// FIXME FABRIC new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
AeStats.register();
advancementTriggers = new AdvancementTriggers(CriteriaRegisterMixin::callRegister);
ToolItemHook.install();
Api.INSTANCE = new Api();
registerTileEntities();
registerParticleTypes();
setupInternalRegistries();
}
public static void setupInternalRegistries() {
// TODO: Do not use the internal API
final Api api = Api.INSTANCE;
final IRegistryContainer registries = api.registries();
final IGridCacheRegistry gcr = registries.gridCache();
// FIXME FABRIC gcr.registerGridCache(ITickManager.class, TickManagerCache.class);
// FIXME FABRIC gcr.registerGridCache(IEnergyGrid.class, EnergyGridCache.class);
// FIXME FABRIC gcr.registerGridCache(IPathingGrid.class, PathGridCache.class);
// FIXME FABRIC gcr.registerGridCache(IStorageGrid.class, GridStorageCache.class);
// FIXME FABRIC gcr.registerGridCache(P2PCache.class, P2PCache.class);
// FIXME FABRIC gcr.registerGridCache(ISpatialCache.class, SpatialPylonCache.class);
// FIXME FABRIC gcr.registerGridCache(ISecurityGrid.class, SecurityCache.class);
// FIXME FABRIC gcr.registerGridCache(ICraftingGrid.class, CraftingGridCache.class);
registries.cell().addCellHandler(new BasicCellHandler());
registries.cell().addCellHandler(new CreativeCellHandler());
registries.cell().addCellGuiHandler(new BasicItemCellGuiHandler());
// FIXME FABRIC registries.cell().addCellGuiHandler(new BasicFluidCellGuiHandler());
registries.matterCannon().registerAmmoItem(api.definitions().materials().matterBall().item(), 32);
}
protected void registerParticleTypes() {
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("charged_ore_fx"), ParticleTypes.CHARGED_ORE);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("crafting_fx"), ParticleTypes.CRAFTING);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("energy_fx"), ParticleTypes.ENERGY);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("lightning_arc_fx"), ParticleTypes.LIGHTNING_ARC);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("lightning_fx"), ParticleTypes.LIGHTNING);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("matter_cannon_fx"), ParticleTypes.MATTER_CANNON);
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("vibrant_fx"), ParticleTypes.VIBRANT);
}
public void registerTileEntities() {
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(ITileEntityRegistrationComponent.class)
.forEachRemaining(ITileEntityRegistrationComponent::register);
}
}
@@ -0,0 +1,13 @@
package appeng.core;
import appeng.client.AppEngClient;
import net.fabricmc.api.ClientModInitializer;
@SuppressWarnings("unused")
public class AppEngClientStartup implements ClientModInitializer {
@Override
public void onInitializeClient() {
AppEngHolder.INSTANCE = new AppEngClient();
}
}
@@ -0,0 +1,7 @@
package appeng.core;
class AppEngHolder {
static AppEng INSTANCE;
}
@@ -41,7 +41,7 @@ public final class CreativeTab {
.icon(() -> {
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
return blocks.controller().stack(1);
return blocks.quartzOre().stack(1); // FIXME FABRIC blocks.controller().stack(1);
})
.appendItems(CreativeTab::fill)
.build();
@@ -0,0 +1,68 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, 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.core.api;
import java.util.List;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import appeng.api.config.IncludeExclude;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IClientHelper;
import appeng.core.localization.GuiText;
public class ApiClientHelper implements IClientHelper {
@Override
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler,
List<Text> lines) {
if (handler == null) {
return;
}
final ICellInventory<?> cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(new LiteralText(cellInventory.getUsedBytes() + " ")
.append(GuiText.Of.textComponent()).append(" " + cellInventory.getTotalBytes() + " ")
.append(GuiText.BytesUsed.textComponent()));
lines.add(new LiteralText(cellInventory.getStoredItemTypes() + " ")
.append(GuiText.Of.textComponent()).append(" " + cellInventory.getTotalItemTypes() + " ")
.append(GuiText.Types.textComponent()));
}
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
if (handler.isFuzzy()) {
lines.add(GuiText.Partitioned.textComponent().copy().append(" - " + list + " ")
.append(GuiText.Fuzzy.textComponent()));
} else {
lines.add(GuiText.Partitioned.textComponent().copy().append(" - " + list + " ")
.append(GuiText.Precise.textComponent()));
}
}
}
}
@@ -0,0 +1,58 @@
/*
* 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.core.api;
import com.google.common.base.Preconditions;
import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.IGridBlock;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridHelper;
import appeng.api.networking.IGridNode;
import appeng.util.Platform;
/**
* @author yueh
* @version rv5
* @since rv5
*/
public class ApiGrid implements IGridHelper {
@Override
public IGridNode createGridNode(final IGridBlock blk) {
Preconditions.checkNotNull(blk);
if (Platform.isClient()) {
throw new IllegalStateException("Grid features for " + blk + " are server side only.");
}
// FIXME FABRIC return new GridNode(blk);
throw new IllegalStateException();
}
@Override
public IGridConnection createGridConnection(final IGridNode a, final IGridNode b) throws FailedConnectionException {
Preconditions.checkNotNull(a);
Preconditions.checkNotNull(b);
// FIXME FABRIC return GridConnection.create(a, b, AEPartLocation.INTERNAL);
throw new IllegalStateException();
}
}
@@ -0,0 +1,46 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.parts.CableRenderMode;
import appeng.api.parts.IPartHelper;
import appeng.core.AppEng;
public class ApiPart implements IPartHelper {
@Override
public ActionResult placeBus(final ItemStack is, final BlockPos pos, final Direction side,
final PlayerEntity player, final Hand hand, final World w) {
// FIXME return PartPlacement.place(is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0);
throw new IllegalStateException();
}
@Override
public CableRenderMode getCableRenderMode() {
return AppEng.instance().getRenderMode();
}
}
@@ -0,0 +1,214 @@
/*
* 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.core.api;
import java.util.Collection;
import java.util.Collections;
import alexiil.mc.lib.attributes.Attributes;
import alexiil.mc.lib.attributes.Simulation;
import alexiil.mc.lib.attributes.fluid.FluidAttributes;
import alexiil.mc.lib.attributes.fluid.FluidExtractable;
import alexiil.mc.lib.attributes.fluid.FluidVolumeUtil;
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
import appeng.fluids.util.FluidList;
import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import appeng.api.config.Actionable;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageHelper;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.util.AEFluidStack;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
public class ApiStorage implements IStorageHelper {
private final ClassToInstanceMap<IStorageChannel<?>> channels;
public ApiStorage() {
this.channels = MutableClassToInstanceMap.create();
this.registerStorageChannel(IItemStorageChannel.class, new ItemStorageChannel());
this.registerStorageChannel(IFluidStorageChannel.class, new FluidStorageChannel());
}
@Override
public <T extends IAEStack<T>, C extends IStorageChannel<T>> void registerStorageChannel(Class<C> channel,
C factory) {
Preconditions.checkNotNull(channel);
Preconditions.checkNotNull(factory);
Preconditions.checkArgument(channel.isInstance(factory));
Preconditions.checkArgument(!this.channels.containsKey(channel));
this.channels.putInstance(channel, factory);
}
@Override
public <T extends IAEStack<T>, C extends IStorageChannel<T>> C getStorageChannel(Class<C> channel) {
Preconditions.checkNotNull(channel);
final C type = this.channels.getInstance(channel);
Preconditions.checkNotNull(type);
return type;
}
@Override
public Collection<IStorageChannel<? extends IAEStack<?>>> storageChannels() {
return Collections.unmodifiableCollection(this.channels.values());
}
@Override
public ICraftingLink loadCraftingLink(final CompoundTag data, final ICraftingRequester req) {
Preconditions.checkNotNull(data);
Preconditions.checkNotNull(req);
// FIXME FABRIC return new CraftingLink(data, req);
throw new IllegalStateException();
}
@Override
public <T extends IAEStack<T>> T poweredInsert(IEnergySource energy, IMEInventory<T> inv, T input,
IActionSource src, Actionable mode) {
return Platform.poweredInsert(energy, inv, input, src, mode);
}
@Override
public <T extends IAEStack<T>> T poweredExtraction(IEnergySource energy, IMEInventory<T> inv, T request,
IActionSource src, Actionable mode) {
return Platform.poweredExtraction(energy, inv, request, src, mode);
}
@Override
public void postChanges(IStorageGrid gs, ItemStack removedCell, ItemStack addedCell, IActionSource src) {
Preconditions.checkNotNull(gs);
Preconditions.checkNotNull(removedCell);
Preconditions.checkNotNull(addedCell);
Preconditions.checkNotNull(src);
Platform.postChanges(gs, removedCell, addedCell, src);
}
private static final class ItemStorageChannel implements IItemStorageChannel {
@Override
public IItemList<IAEItemStack> createList() {
return new ItemList();
}
@Override
public IAEItemStack createStack(Object input) {
Preconditions.checkNotNull(input);
if (input instanceof ItemStack) {
return AEItemStack.fromItemStack((ItemStack) input);
}
return null;
}
@Override
public IAEItemStack createFromNBT(CompoundTag nbt) {
Preconditions.checkNotNull(nbt);
return AEItemStack.fromNBT(nbt);
}
@Override
public IAEItemStack readFromPacket(PacketByteBuf input) {
Preconditions.checkNotNull(input);
return AEItemStack.fromPacket(input);
}
}
private static final class FluidStorageChannel implements IFluidStorageChannel {
@Override
public int transferFactor() {
return 125;
}
@Override
public int getUnitsPerByte() {
return 8000;
}
@Override
public IItemList<IAEFluidStack> createList() {
return new FluidList();
}
@Override
public IAEFluidStack createStack(Object input) {
Preconditions.checkNotNull(input);
if (input instanceof FluidVolume) {
return AEFluidStack.fromFluidStack((FluidVolume) input);
}
if (input instanceof ItemStack) {
final ItemStack is = (ItemStack) input;
if (is.getItem() instanceof FluidDummyItem) {
return AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is));
} else {
FluidExtractable fluidExtractable = FluidAttributes.EXTRACTABLE.get(is);
FluidVolume fluidVolume = fluidExtractable.attemptAnyExtraction(FluidAmount.MAX_VALUE, Simulation.ACTION);
if (!fluidVolume.isEmpty()) {
return AEFluidStack.fromFluidStack(fluidVolume);
}
}
}
return null;
}
@Override
public IAEFluidStack readFromPacket(PacketByteBuf input) {
Preconditions.checkNotNull(input);
return AEFluidStack.fromPacket(input);
}
@Override
public IAEFluidStack createFromNBT(CompoundTag nbt) {
Preconditions.checkNotNull(nbt);
return AEFluidStack.fromNBT(nbt);
}
}
}
@@ -0,0 +1,941 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.ITileDefinition;
import appeng.api.features.AEFeature;
import appeng.block.misc.*;
import appeng.block.storage.SkyChestBlock;
import appeng.bootstrap.*;
import appeng.bootstrap.components.IInitComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.client.render.tesr.SkyChestTESR;
import appeng.decorative.AEDecorativeBlock;
import appeng.decorative.solid.*;
import appeng.decorative.solid.SkyStoneBlock.SkystoneType;
import appeng.entity.TinyTNTPrimedEntity;
import appeng.hooks.TinyTNTDispenseItemBehavior;
import appeng.tile.misc.LightDetectorBlockEntity;
import appeng.tile.misc.SkyCompassBlockEntity;
import appeng.tile.storage.SkyChestBlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.sound.BlockSoundGroup;
import static appeng.block.AEBaseBlock.defaultProps;
/**
* Internal implementation for the API blocks
*/
public final class ApiBlocks implements IBlocks {
private IBlockDefinition quartzOre;
private IBlockDefinition quartzOreCharged;
private IBlockDefinition matrixFrame;
private IBlockDefinition quartzBlock;
private IBlockDefinition quartzPillar;
private IBlockDefinition chiseledQuartzBlock;
private IBlockDefinition quartzGlass;
private IBlockDefinition quartzVibrantGlass;
private IBlockDefinition quartzFixture;
private IBlockDefinition fluixBlock;
private IBlockDefinition skyStoneBlock;
private IBlockDefinition smoothSkyStoneBlock;
private IBlockDefinition skyStoneBrick;
private IBlockDefinition skyStoneSmallBrick;
private IBlockDefinition skyStoneChest;
private IBlockDefinition smoothSkyStoneChest;
private IBlockDefinition skyCompass;
private ITileDefinition grindstone;
private ITileDefinition crank;
private ITileDefinition inscriber;
private ITileDefinition wirelessAccessPoint;
private ITileDefinition charger;
private IBlockDefinition tinyTNT;
private ITileDefinition securityStation;
private ITileDefinition quantumRing;
private ITileDefinition quantumLink;
private ITileDefinition spatialPylon;
private ITileDefinition spatialIOPort;
private ITileDefinition multiPart;
private ITileDefinition controller;
private ITileDefinition drive;
private ITileDefinition chest;
private ITileDefinition iface;
private ITileDefinition fluidIface;
private ITileDefinition cellWorkbench;
private ITileDefinition iOPort;
private ITileDefinition condenser;
private ITileDefinition energyAcceptor;
private ITileDefinition vibrationChamber;
private ITileDefinition quartzGrowthAccelerator;
private ITileDefinition energyCell;
private ITileDefinition energyCellDense;
private ITileDefinition energyCellCreative;
private ITileDefinition craftingUnit;
private ITileDefinition craftingAccelerator;
private ITileDefinition craftingStorage1k;
private ITileDefinition craftingStorage4k;
private ITileDefinition craftingStorage16k;
private ITileDefinition craftingStorage64k;
private ITileDefinition craftingMonitor;
private ITileDefinition molecularAssembler;
private ITileDefinition lightDetector;
private ITileDefinition paint;
private IBlockDefinition skyStoneStairs;
private IBlockDefinition smoothSkyStoneStairs;
private IBlockDefinition skyStoneBrickStairs;
private IBlockDefinition skyStoneSmallBrickStairs;
private IBlockDefinition fluixStairs;
private IBlockDefinition quartzStairs;
private IBlockDefinition chiseledQuartzStairs;
private IBlockDefinition quartzPillarStairs;
private IBlockDefinition skyStoneSlab;
private IBlockDefinition smoothSkyStoneSlab;
private IBlockDefinition skyStoneBrickSlab;
private IBlockDefinition skyStoneSmallBrickSlab;
private IBlockDefinition fluixSlab;
private IBlockDefinition quartzSlab;
private IBlockDefinition chiseledQuartzSlab;
private IBlockDefinition quartzPillarSlab;
private IBlockDefinition itemGen;
private IBlockDefinition chunkLoader;
private IBlockDefinition phantomNode;
private IBlockDefinition cubeGenerator;
private IBlockDefinition energyGenerator;
private static final FabricBlockSettings QUARTZ_PROPERTIES = defaultProps(Material.STONE).strength(3, 5);
private static final FabricBlockSettings SKYSTONE_PROPERTIES = defaultProps(Material.STONE).strength(50,
150);
private static FabricBlockSettings glassProps() {
return defaultProps(Material.GLASS)
.sounds(BlockSoundGroup.GLASS)
.nonOpaque()
.allowsSpawning((state, world, pos, type) -> false)
.solidBlock((state, world, pos) -> false)
.suffocates((state, world, pos) -> false)
.blockVision((state, world, pos) -> false);
}
public ApiBlocks(FeatureFactory registry) {
this.quartzOre = registry.block("quartz_ore", () -> new QuartzOreBlock(QUARTZ_PROPERTIES))
.features(AEFeature.CERTUS_ORE).build();
this.quartzOreCharged = registry.block("charged_quartz_ore", () -> new ChargedQuartzOreBlock(QUARTZ_PROPERTIES))
.features(AEFeature.CERTUS_ORE, AEFeature.CHARGED_CERTUS_ORE).rendering(new BlockRenderingCustomizer() {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderLayer.getCutout());
}
}).build();
// FIXME FABRIC this.matrixFrame = registry.block("matrix_frame", MatrixFrameBlock::new).features(AEFeature.SPATIAL_IO).build();
FeatureFactory deco = registry.features(AEFeature.DECORATIVE_BLOCKS);
this.quartzBlock = deco.block("quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES)).build();
this.quartzPillar = deco.block("quartz_pillar", () -> new QuartzPillarBlock(QUARTZ_PROPERTIES)).build();
this.chiseledQuartzBlock = deco.block("chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES))
.build();
this.quartzGlass = registry.features(AEFeature.QUARTZ_GLASS)
.block("quartz_glass", () -> new QuartzGlassBlock(glassProps()))
.rendering(new BlockRenderingCustomizer() {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderLayer.getCutout());
}
}).build();
this.quartzVibrantGlass = deco
.block("quartz_vibrant_glass",
() -> new QuartzLampBlock(glassProps().lightLevel(15)))
.addFeatures(AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS)
.rendering(new BlockRenderingCustomizer() {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderLayer.getCutout());
}
}).build();
this.quartzFixture = registry.block("quartz_fixture", QuartzFixtureBlock::new)
.features(AEFeature.DECORATIVE_LIGHTS).rendering(new BlockRenderingCustomizer() {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderLayer.getCutout());
}
}).build();
this.fluixBlock = registry.features(AEFeature.FLUIX)
.block("fluix_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES)).build();
this.skyStoneBlock = registry
.features(
AEFeature.SKY_STONE)
.block("sky_stone_block", () -> new SkyStoneBlock(SkystoneType.STONE,
defaultProps(Material.STONE).strength(50, 150).breakByTool(FabricToolTags.PICKAXES, 3)))
.build();
this.smoothSkyStoneBlock = registry.features(AEFeature.SKY_STONE)
.block("smooth_sky_stone_block", () -> new SkyStoneBlock(SkystoneType.BLOCK, SKYSTONE_PROPERTIES))
.build();
this.skyStoneBrick = deco
.block("sky_stone_brick", () -> new SkyStoneBlock(SkystoneType.BRICK, SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.skyStoneSmallBrick = deco
.block("sky_stone_small_brick", () -> new SkyStoneBlock(SkystoneType.SMALL_BRICK, SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
AbstractBlock.Settings skyStoneChestProps = defaultProps(Material.STONE)
.strength(50, 150)
.solidBlock((state, world, pos) -> false);
TileEntityDefinition skyChestTile = registry
.tileEntity("sky_chest", SkyChestBlockEntity.class, SkyChestBlockEntity::new)
.rendering(new TileEntityRenderingCustomizer<SkyChestBlockEntity>() {
@Override
@Environment(EnvType.CLIENT)
public void customize(TileEntityRendering<SkyChestBlockEntity> rendering) {
rendering.tileEntityRenderer(SkyChestTESR::new);
}
}).build();
this.skyStoneChest = registry
.block("sky_stone_chest", () -> new SkyChestBlock(SkyChestBlock.SkyChestType.STONE, skyStoneChestProps))
.features(AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS).tileEntity(skyChestTile).build();
this.smoothSkyStoneChest = registry
.block("smooth_sky_stone_chest",
() -> new SkyChestBlock(SkyChestBlock.SkyChestType.BLOCK, skyStoneChestProps))
.features(AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS).tileEntity(skyChestTile).build();
this.skyCompass = registry.block("sky_compass", () -> new SkyCompassBlock(defaultProps(Material.SUPPORTED)))
.features(AEFeature.METEORITE_COMPASS)
.tileEntity(registry.tileEntity("sky_compass", SkyCompassBlockEntity.class, SkyCompassBlockEntity::new)
.rendering(new SkyCompassRendering()).build())
.build();
// FIXME FABRIC this.grindstone = registry
// FIXME FABRIC .block("grindstone", () -> new GrinderBlock(defaultProps(Material.STONE).strength(3.2f)))
// FIXME FABRIC .features(AEFeature.GRIND_STONE)
// FIXME FABRIC .tileEntity(registry.tileEntity("grindstone", GrinderBlockEntity.class, GrinderBlockEntity::new).build())
// FIXME FABRIC .build();
// FIXME FABRIC this.crank = registry
// FIXME FABRIC .block("crank",
// FIXME FABRIC () -> new CrankBlock(
// FIXME FABRIC defaultProps(Material.WOOD).breakByTool(FabricToolTags.AXES, 0).notSolid()))
// FIXME FABRIC .features(AEFeature.GRIND_STONE)
// FIXME FABRIC .tileEntity(registry.tileEntity("crank", CrankBlockEntity.class, CrankBlockEntity::new)
// FIXME FABRIC .rendering(new TileEntityRenderingCustomizer<CrankBlockEntity>() {
// FIXME FABRIC @Override
// FIXME FABRIC @Environment(EnvType.CLIENT)
// FIXME FABRIC public void customize(TileEntityRendering<CrankBlockEntity> rendering) {
// FIXME FABRIC rendering.tileEntityRenderer(CrankTESR::new);
// FIXME FABRIC }
// FIXME FABRIC }).build())
// FIXME FABRIC .build();
// FIXME FABRIC this.inscriber = registry.block("inscriber", () -> new InscriberBlock(defaultProps(Material.METAL).notSolid()))
// FIXME FABRIC .features(AEFeature.INSCRIBER)
// FIXME FABRIC .tileEntity(registry.tileEntity("inscriber", InscriberBlockEntity.class, InscriberBlockEntity::new)
// FIXME FABRIC .rendering(new InscriberRendering()).build())
// FIXME FABRIC .build();
// FIXME FABRIC this.wirelessAccessPoint = registry.block("wireless_access_point", WirelessBlock::new)
// FIXME FABRIC .features(AEFeature.WIRELESS_ACCESS_TERMINAL)
// FIXME FABRIC .tileEntity(registry
// FIXME FABRIC .tileEntity("wireless_access_point", WirelessBlockEntity.class, WirelessBlockEntity::new).build())
// FIXME FABRIC .rendering(new WirelessRendering()).build();
// FIXME FABRIC this.charger = registry.block("charger", ChargerBlock::new).features(AEFeature.CHARGER)
// FIXME FABRIC .tileEntity(registry.tileEntity("charger", ChargerBlockEntity.class, ChargerBlockEntity::new)
// FIXME FABRIC .rendering(new TileEntityRenderingCustomizer<ChargerBlockEntity>() {
// FIXME FABRIC @Override
// FIXME FABRIC @Environment(EnvType.CLIENT)
// FIXME FABRIC public void customize(TileEntityRendering<ChargerBlockEntity> rendering) {
// FIXME FABRIC rendering.tileEntityRenderer(ChargerBlock.createTesr());
// FIXME FABRIC }
// FIXME FABRIC }).build())
// FIXME FABRIC .build();
TinyTNTPrimedEntity.TYPE = registry
.<TinyTNTPrimedEntity>entity("tiny_tnt_primed", TinyTNTPrimedEntity::new, SpawnGroup.MISC)
.customize(p -> p.trackable(16, 4, true))
.build();
this.tinyTNT = registry
.block("tiny_tnt",
() -> new TinyTNTBlock(
defaultProps(Material.TNT).sounds(BlockSoundGroup.GRASS).breakInstantly()))
.features(AEFeature.TINY_TNT).bootstrap((block, item) -> (IInitComponent) () -> DispenserBlock
.registerBehavior(item, new TinyTNTDispenseItemBehavior()))
.build();
// FIXME this.securityStation = registry.block("security_station", SecurityStationBlock::new)
// FIXME .features(AEFeature.SECURITY)
// FIXME .tileEntity(registry
// FIXME .tileEntity("security_station", SecurityStationBlockEntity.class, SecurityStationBlockEntity::new)
// FIXME .build())
// FIXME .rendering(new SecurityStationRendering()).build();
// FIXME
// FIXME TileEntityDefinition quantumRingTile = registry
// FIXME .tileEntity("quantum_ring", QuantumBridgeBlockEntity.class, QuantumBridgeBlockEntity::new).build();
// FIXME this.quantumRing = registry.block("quantum_ring", QuantumRingBlock::new)
// FIXME .features(AEFeature.QUANTUM_NETWORK_BRIDGE).tileEntity(quantumRingTile)
// FIXME .rendering(new QuantumBridgeRendering()).build();
// FIXME this.quantumLink = registry.block("quantum_link", QuantumLinkChamberBlock::new)
// FIXME .features(AEFeature.QUANTUM_NETWORK_BRIDGE).tileEntity(quantumRingTile)
// FIXME .rendering(new QuantumBridgeRendering()).build();
// FIXME this.spatialPylon = registry.block("spatial_pylon", SpatialPylonBlock::new).features(AEFeature.SPATIAL_IO)
// FIXME .tileEntity(registry
// FIXME .tileEntity("spatial_pylon", SpatialPylonBlockEntity.class, SpatialPylonBlockEntity::new).build())
// FIXME .rendering(new SpatialPylonRendering()).build();
// FIXME this.spatialIOPort = registry.block("spatial_io_port", SpatialIOPortBlock::new).features(AEFeature.SPATIAL_IO)
// FIXME .tileEntity(registry
// FIXME .tileEntity("spatial_io_port", SpatialIOPortBlockEntity.class, SpatialIOPortBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.controller = registry
// FIXME .block("controller", ControllerBlock::new).features(AEFeature.CHANNELS).tileEntity(registry
// FIXME .tileEntity("controller", ControllerBlockEntity.class, ControllerBlockEntity::new).build())
// FIXME .rendering(new ControllerRendering()).build();
// FIXME this.drive = registry.block("drive", DriveBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_DRIVE)
// FIXME .tileEntity(registry.tileEntity("drive", DriveBlockEntity.class, DriveBlockEntity::new)
// FIXME .rendering(new TileEntityRenderingCustomizer<DriveBlockEntity>() {
// FIXME @Override
// FIXME @Environment(EnvType.CLIENT)
// FIXME public void customize(TileEntityRendering<DriveBlockEntity> rendering) {
// FIXME rendering.tileEntityRenderer(DriveLedTileEntityRenderer::new);
// FIXME }
// FIXME }).build())
// FIXME .rendering(new DriveRendering()).build();
// FIXME this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST)
// FIXME .tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new).build())
// FIXME .rendering(new ChestRendering()).build();
// FIXME this.iface = registry.block("interface", InterfaceBlock::new).features(AEFeature.INTERFACE)
// FIXME .tileEntity(
// FIXME registry.tileEntity("interface", InterfaceBlockEntity.class, InterfaceBlockEntity::new).build())
// FIXME .build();
// FIXME this.fluidIface = registry.block("fluid_interface", FluidInterfaceBlock::new)
// FIXME .features(AEFeature.FLUID_INTERFACE)
// FIXME .tileEntity(registry
// FIXME .tileEntity("fluid_interface", FluidInterfaceBlockEntity.class, FluidInterfaceBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.cellWorkbench = registry.block("cell_workbench", CellWorkbenchBlock::new).features(AEFeature.STORAGE_CELLS)
// FIXME .tileEntity(registry
// FIXME .tileEntity("cell_workbench", CellWorkbenchBlockEntity.class, CellWorkbenchBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.iOPort = registry.block("io_port", IOPortBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.IO_PORT)
// FIXME .tileEntity(registry.tileEntity("io_port", IOPortBlockEntity.class, IOPortBlockEntity::new).build())
// FIXME .build();
// FIXME this.condenser = registry.block("condenser", CondenserBlock::new).features(AEFeature.CONDENSER)
// FIXME .tileEntity(
// FIXME registry.tileEntity("condenser", CondenserBlockEntity.class, CondenserBlockEntity::new).build())
// FIXME .build();
// FIXME this.energyAcceptor = registry.block("energy_acceptor", EnergyAcceptorBlock::new)
// FIXME .features(AEFeature.ENERGY_ACCEPTOR)
// FIXME .tileEntity(registry
// FIXME .tileEntity("energy_acceptor", EnergyAcceptorBlockEntity.class, EnergyAcceptorBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.vibrationChamber = registry.block("vibration_chamber", VibrationChamberBlock::new)
// FIXME .features(AEFeature.POWER_GEN).tileEntity(registry.tileEntity("vibration_chamber",
// FIXME VibrationChamberBlockEntity.class, VibrationChamberBlockEntity::new).build())
// FIXME .build();
// FIXME this.quartzGrowthAccelerator = registry.block("quartz_growth_accelerator", QuartzGrowthAcceleratorBlock::new)
// FIXME .tileEntity(registry.tileEntity("quartz_growth_accelerator", QuartzGrowthAcceleratorBlockEntity.class,
// FIXME QuartzGrowthAcceleratorBlockEntity::new).build())
// FIXME .features(AEFeature.CRYSTAL_GROWTH_ACCELERATOR).build();
// FIXME this.energyCell = registry.block("energy_cell", EnergyCellBlock::new).features(AEFeature.ENERGY_CELLS)
// FIXME .item(AEBaseBlockItemChargeable::new).tileEntity(registry
// FIXME .tileEntity("energy_cell", EnergyCellBlockEntity.class, EnergyCellBlockEntity::new).build())
// FIXME .build();
// FIXME this.energyCellDense = registry.block("dense_energy_cell", DenseEnergyCellBlock::new)
// FIXME .features(AEFeature.ENERGY_CELLS, AEFeature.DENSE_ENERGY_CELLS).item(AEBaseBlockItemChargeable::new)
// FIXME .tileEntity(registry.tileEntity("dense_energy_cell", DenseEnergyCellBlockEntity.class,
// FIXME DenseEnergyCellBlockEntity::new).build())
// FIXME .build();
// FIXME this.energyCellCreative = registry.block("creative_energy_cell", CreativeEnergyCellBlock::new)
// FIXME .features(AEFeature.CREATIVE).tileEntity(registry.tileEntity("creative_energy_cell",
// FIXME CreativeEnergyCellBlockEntity.class, CreativeEnergyCellBlockEntity::new).build())
// FIXME .build();
// FIXME
// FIXME TileEntityDefinition craftingUnit = registry
// FIXME .tileEntity("crafting_unit", CraftingBlockEntity.class, CraftingBlockEntity::new).build();
// FIXME
// FIXME FeatureFactory crafting = registry.features(AEFeature.CRAFTING_CPU);
// FIXME AbstractBlock.Settings craftingBlockProps = defaultProps(Material.METAL);
// FIXME this.craftingUnit = crafting
// FIXME .block("crafting_unit", () -> new CraftingUnitBlock(craftingBlockProps, CraftingUnitType.UNIT))
// FIXME .rendering(new CraftingCubeRendering()).tileEntity(craftingUnit).build();
// FIXME this.craftingAccelerator = crafting
// FIXME .block("crafting_accelerator",
// FIXME () -> new CraftingUnitBlock(craftingBlockProps, CraftingUnitType.ACCELERATOR))
// FIXME .rendering(new CraftingCubeRendering()).tileEntity(craftingUnit).build();
// FIXME
// FIXME TileEntityDefinition craftingStorage = registry
// FIXME .tileEntity("crafting_storage", CraftingStorageBlockEntity.class, CraftingStorageBlockEntity::new)
// FIXME .build();
// FIXME this.craftingStorage1k = crafting
// FIXME .block("1k_crafting_storage",
// FIXME () -> new CraftingStorageBlock(craftingBlockProps, CraftingUnitType.STORAGE_1K))
// FIXME .item(CraftingStorageItem::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering())
// FIXME .build();
// FIXME this.craftingStorage4k = crafting
// FIXME .block("4k_crafting_storage",
// FIXME () -> new CraftingStorageBlock(craftingBlockProps, CraftingUnitType.STORAGE_4K))
// FIXME .item(CraftingStorageItem::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering())
// FIXME .build();
// FIXME this.craftingStorage16k = crafting
// FIXME .block("16k_crafting_storage",
// FIXME () -> new CraftingStorageBlock(craftingBlockProps, CraftingUnitType.STORAGE_16K))
// FIXME .item(CraftingStorageItem::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering())
// FIXME .build();
// FIXME this.craftingStorage64k = crafting
// FIXME .block("64k_crafting_storage",
// FIXME () -> new CraftingStorageBlock(craftingBlockProps, CraftingUnitType.STORAGE_64K))
// FIXME .item(CraftingStorageItem::new).tileEntity(craftingStorage).rendering(new CraftingCubeRendering())
// FIXME .build();
// FIXME this.craftingMonitor = crafting.block("crafting_monitor", () -> new CraftingMonitorBlock(craftingBlockProps))
// FIXME .tileEntity(registry
// FIXME .tileEntity("crafting_monitor", CraftingMonitorBlockEntity.class, CraftingMonitorBlockEntity::new)
// FIXME .rendering(new TileEntityRenderingCustomizer<CraftingMonitorBlockEntity>() {
// FIXME @Environment(EnvType.CLIENT)
// FIXME @Override
// FIXME public void customize(TileEntityRendering<CraftingMonitorBlockEntity> rendering) {
// FIXME rendering.tileEntityRenderer(CraftingMonitorTESR::new);
// FIXME }
// FIXME }).build())
// FIXME .rendering(new BlockRenderingCustomizer() {
// FIXME @Override
// FIXME @Environment(EnvType.CLIENT)
// FIXME public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// FIXME rendering.renderType(RenderLayer.getCutout());
// FIXME rendering.modelCustomizer((path, model) -> {
// FIXME // The formed model handles rotations itself, the unformed one does not
// FIXME if (model instanceof MonitorBakedModel) {
// FIXME return model;
// FIXME }
// FIXME return new AutoRotatingBakedModel(model);
// FIXME });
// FIXME }
// FIXME }).build();
// FIXME
// FIXME this.molecularAssembler = registry
// FIXME .block("molecular_assembler", () -> new MolecularAssemblerBlock(defaultProps(Material.METAL).notSolid()))
// FIXME .features(AEFeature.MOLECULAR_ASSEMBLER).rendering(new BlockRenderingCustomizer() {
// FIXME @Environment(EnvType.CLIENT)
// FIXME @Override
// FIXME public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// FIXME rendering.renderType(RenderLayer.getCutout());
// FIXME }
// FIXME })
// FIXME .tileEntity(registry
// FIXME .tileEntity("molecular_assembler", MolecularAssemblerBlockEntity.class,
// FIXME MolecularAssemblerBlockEntity::new)
// FIXME .rendering(new TileEntityRenderingCustomizer<MolecularAssemblerBlockEntity>() {
// FIXME @Override
// FIXME @Environment(EnvType.CLIENT)
// FIXME public void customize(TileEntityRendering<MolecularAssemblerBlockEntity> rendering) {
// FIXME rendering.tileEntityRenderer(MolecularAssemblerRenderer::new);
// FIXME }
// FIXME }).build())
// FIXME .build();
this.lightDetector = registry.block("light_detector", LightDetectorBlock::new)
.features(AEFeature.LIGHT_DETECTOR)
.tileEntity(registry
.tileEntity("light_detector", LightDetectorBlockEntity.class, LightDetectorBlockEntity::new)
.build())
.rendering(new BlockRenderingCustomizer() {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderLayer.getCutout());
}
}).build();
// FIXME this.paint = registry
// FIXME .block("paint", PaintSplotchesBlock::new).features(AEFeature.PAINT_BALLS).tileEntity(registry
// FIXME .tileEntity("paint", PaintSplotchesBlockEntity.class, PaintSplotchesBlockEntity::new).build())
// FIXME .rendering(new PaintSplotchesRendering()).build();
this.skyStoneStairs = deco
.block("sky_stone_stairs",
() -> new AEStairsBlock(this.skyStoneBlock().block().getDefaultState(), SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.smoothSkyStoneStairs = deco
.block("smooth_sky_stone_stairs",
() -> new AEStairsBlock(this.smoothSkyStoneBlock().block().getDefaultState(), SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.skyStoneBrickStairs = deco
.block("sky_stone_brick_stairs",
() -> new AEStairsBlock(this.skyStoneBrick().block().getDefaultState(), SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.skyStoneSmallBrickStairs = deco
.block("sky_stone_small_brick_stairs",
() -> new AEStairsBlock(this.skyStoneSmallBrick().block().getDefaultState(), SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.fluixStairs = deco
.block("fluix_stairs",
() -> new AEStairsBlock(this.fluixBlock().block().getDefaultState(), QUARTZ_PROPERTIES))
.addFeatures(AEFeature.FLUIX).build();
this.quartzStairs = deco
.block("quartz_stairs",
() -> new AEStairsBlock(this.quartzBlock().block().getDefaultState(), QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
this.chiseledQuartzStairs = deco
.block("chiseled_quartz_stairs",
() -> new AEStairsBlock(this.chiseledQuartzBlock().block().getDefaultState(), QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
this.quartzPillarStairs = deco
.block("quartz_pillar_stairs",
() -> new AEStairsBlock(this.quartzPillar().block().getDefaultState(), QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
// FIXME this.multiPart = registry.block("cable_bus", CableBusBlock::new).rendering(new CableBusRendering())
// FIXME .tileEntity(registry.tileEntity("cable_bus", CableBusBlockEntity.class, CableBusBlockEntity::new)
// FIXME .rendering(new TileEntityRenderingCustomizer<CableBusBlockEntity>() {
// FIXME @Override
// FIXME @Environment(EnvType.CLIENT)
// FIXME public void customize(TileEntityRendering<CableBusBlockEntity> rendering) {
// FIXME rendering.tileEntityRenderer(CableBusTESR::new);
// FIXME }
// FIXME }).build())
// FIXME .build();
this.skyStoneSlab = deco.block("sky_stone_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.smoothSkyStoneSlab = deco.block("smooth_sky_stone_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.skyStoneBrickSlab = deco.block("sky_stone_brick_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.skyStoneSmallBrickSlab = deco.block("sky_stone_small_brick_slab", () -> new SlabBlock(SKYSTONE_PROPERTIES))
.addFeatures(AEFeature.SKY_STONE).build();
this.fluixSlab = deco.block("fluix_slab", () -> new SlabBlock(QUARTZ_PROPERTIES)).addFeatures(AEFeature.FLUIX)
.build();
this.quartzSlab = deco.block("quartz_slab", () -> new SlabBlock(QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
this.chiseledQuartzSlab = deco.block("chiseled_quartz_slab", () -> new SlabBlock(QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
this.quartzPillarSlab = deco.block("quartz_pillar_slab", () -> new SlabBlock(QUARTZ_PROPERTIES))
.addFeatures(AEFeature.CERTUS).build();
// FIXME this.itemGen = registry.block("debug_item_gen", ItemGenBlock::new)
// FIXME .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE)
// FIXME .tileEntity(
// FIXME registry.tileEntity("debug_item_gen", ItemGenBlockEntity.class, ItemGenBlockEntity::new).build())
// FIXME .build();
// FIXME this.chunkLoader = registry.block("debug_chunk_loader", ChunkLoaderBlock::new)
// FIXME .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE)
// FIXME .tileEntity(registry
// FIXME .tileEntity("debug_chunk_loader", ChunkLoaderBlockEntity.class, ChunkLoaderBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.phantomNode = registry.block("debug_phantom_node", PhantomNodeBlock::new)
// FIXME .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE)
// FIXME .tileEntity(registry
// FIXME .tileEntity("debug_phantom_node", PhantomNodeBlockEntity.class, PhantomNodeBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.cubeGenerator = registry.block("debug_cube_gen", CubeGeneratorBlock::new)
// FIXME .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE)
// FIXME .tileEntity(registry
// FIXME .tileEntity("debug_cube_gen", CubeGeneratorBlockEntity.class, CubeGeneratorBlockEntity::new)
// FIXME .build())
// FIXME .build();
// FIXME this.energyGenerator = registry.block("debug_energy_gen", EnergyGeneratorBlock::new)
// FIXME .features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE)
// FIXME .tileEntity(registry
// FIXME .tileEntity("debug_energy_gen", EnergyGeneratorBlockEntity.class, EnergyGeneratorBlockEntity::new)
// FIXME .build())
// FIXME .build();
}
@Override
public IBlockDefinition quartzOre() {
return this.quartzOre;
}
@Override
public IBlockDefinition quartzOreCharged() {
return this.quartzOreCharged;
}
@Override
public IBlockDefinition matrixFrame() {
return this.matrixFrame;
}
@Override
public IBlockDefinition quartzBlock() {
return this.quartzBlock;
}
@Override
public IBlockDefinition quartzPillar() {
return this.quartzPillar;
}
@Override
public IBlockDefinition chiseledQuartzBlock() {
return this.chiseledQuartzBlock;
}
@Override
public IBlockDefinition quartzGlass() {
return this.quartzGlass;
}
@Override
public IBlockDefinition quartzVibrantGlass() {
return this.quartzVibrantGlass;
}
@Override
public IBlockDefinition quartzFixture() {
return this.quartzFixture;
}
@Override
public IBlockDefinition fluixBlock() {
return this.fluixBlock;
}
@Override
public IBlockDefinition skyStoneBlock() {
return this.skyStoneBlock;
}
@Override
public IBlockDefinition smoothSkyStoneBlock() {
return this.smoothSkyStoneBlock;
}
@Override
public IBlockDefinition skyStoneBrick() {
return this.skyStoneBrick;
}
@Override
public IBlockDefinition skyStoneSmallBrick() {
return this.skyStoneSmallBrick;
}
@Override
public IBlockDefinition skyStoneChest() {
return this.skyStoneChest;
}
@Override
public IBlockDefinition smoothSkyStoneChest() {
return this.smoothSkyStoneChest;
}
@Override
public IBlockDefinition skyCompass() {
return this.skyCompass;
}
@Override
public IBlockDefinition skyStoneStairs() {
return this.skyStoneStairs;
}
@Override
public IBlockDefinition smoothSkyStoneStairs() {
return this.smoothSkyStoneStairs;
}
@Override
public IBlockDefinition skyStoneBrickStairs() {
return this.skyStoneBrickStairs;
}
@Override
public IBlockDefinition skyStoneSmallBrickStairs() {
return this.skyStoneSmallBrickStairs;
}
@Override
public IBlockDefinition fluixStairs() {
return this.fluixStairs;
}
@Override
public IBlockDefinition quartzStairs() {
return this.quartzStairs;
}
@Override
public IBlockDefinition chiseledQuartzStairs() {
return this.chiseledQuartzStairs;
}
@Override
public IBlockDefinition quartzPillarStairs() {
return this.quartzPillarStairs;
}
@Override
public IBlockDefinition skyStoneSlab() {
return this.skyStoneSlab;
}
@Override
public IBlockDefinition smoothSkyStoneSlab() {
return this.smoothSkyStoneSlab;
}
@Override
public IBlockDefinition skyStoneBrickSlab() {
return this.skyStoneBrickSlab;
}
@Override
public IBlockDefinition skyStoneSmallBrickSlab() {
return this.skyStoneSmallBrickSlab;
}
@Override
public IBlockDefinition fluixSlab() {
return this.fluixSlab;
}
@Override
public IBlockDefinition quartzSlab() {
return this.quartzSlab;
}
@Override
public IBlockDefinition chiseledQuartzSlab() {
return this.chiseledQuartzSlab;
}
@Override
public IBlockDefinition quartzPillarSlab() {
return this.quartzPillarSlab;
}
@Override
public ITileDefinition grindstone() {
return this.grindstone;
}
@Override
public ITileDefinition crank() {
return this.crank;
}
@Override
public ITileDefinition inscriber() {
return this.inscriber;
}
@Override
public ITileDefinition wirelessAccessPoint() {
return this.wirelessAccessPoint;
}
@Override
public ITileDefinition charger() {
return this.charger;
}
@Override
public IBlockDefinition tinyTNT() {
return this.tinyTNT;
}
@Override
public ITileDefinition securityStation() {
return this.securityStation;
}
@Override
public ITileDefinition quantumRing() {
return this.quantumRing;
}
@Override
public ITileDefinition quantumLink() {
return this.quantumLink;
}
@Override
public ITileDefinition spatialPylon() {
return this.spatialPylon;
}
@Override
public ITileDefinition spatialIOPort() {
return this.spatialIOPort;
}
@Override
public ITileDefinition multiPart() {
return this.multiPart;
}
@Override
public ITileDefinition controller() {
return this.controller;
}
@Override
public ITileDefinition drive() {
return this.drive;
}
@Override
public ITileDefinition chest() {
return this.chest;
}
@Override
public ITileDefinition iface() {
return this.iface;
}
@Override
public ITileDefinition fluidIface() {
return this.fluidIface;
}
@Override
public ITileDefinition cellWorkbench() {
return this.cellWorkbench;
}
@Override
public ITileDefinition iOPort() {
return this.iOPort;
}
@Override
public ITileDefinition condenser() {
return this.condenser;
}
@Override
public ITileDefinition energyAcceptor() {
return this.energyAcceptor;
}
@Override
public ITileDefinition vibrationChamber() {
return this.vibrationChamber;
}
@Override
public ITileDefinition quartzGrowthAccelerator() {
return this.quartzGrowthAccelerator;
}
@Override
public ITileDefinition energyCell() {
return this.energyCell;
}
@Override
public ITileDefinition energyCellDense() {
return this.energyCellDense;
}
@Override
public ITileDefinition energyCellCreative() {
return this.energyCellCreative;
}
@Override
public ITileDefinition craftingUnit() {
return this.craftingUnit;
}
@Override
public ITileDefinition craftingAccelerator() {
return this.craftingAccelerator;
}
@Override
public ITileDefinition craftingStorage1k() {
return this.craftingStorage1k;
}
@Override
public ITileDefinition craftingStorage4k() {
return this.craftingStorage4k;
}
@Override
public ITileDefinition craftingStorage16k() {
return this.craftingStorage16k;
}
@Override
public ITileDefinition craftingStorage64k() {
return this.craftingStorage64k;
}
@Override
public ITileDefinition craftingMonitor() {
return this.craftingMonitor;
}
@Override
public ITileDefinition molecularAssembler() {
return this.molecularAssembler;
}
@Override
public ITileDefinition lightDetector() {
return this.lightDetector;
}
@Override
public ITileDefinition paint() {
return this.paint;
}
public IBlockDefinition chunkLoader() {
return this.chunkLoader;
}
public IBlockDefinition itemGen() {
return this.itemGen;
}
public IBlockDefinition phantomNode() {
return this.phantomNode;
}
public IBlockDefinition cubeGenerator() {
return this.cubeGenerator;
}
public IBlockDefinition energyGenerator() {
return this.energyGenerator;
}
}
@@ -0,0 +1,509 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
/**
* Internal implementation for the API items
*/
public final class ApiItems implements IItems {
private IItemDefinition certusQuartzAxe;
private IItemDefinition certusQuartzHoe;
private IItemDefinition certusQuartzShovel;
private IItemDefinition certusQuartzPick;
private IItemDefinition certusQuartzSword;
private IItemDefinition certusQuartzWrench;
private IItemDefinition certusQuartzKnife;
private IItemDefinition netherQuartzAxe;
private IItemDefinition netherQuartzHoe;
private IItemDefinition netherQuartzShovel;
private IItemDefinition netherQuartzPick;
private IItemDefinition netherQuartzSword;
private IItemDefinition netherQuartzWrench;
private IItemDefinition netherQuartzKnife;
private IItemDefinition entropyManipulator;
private IItemDefinition wirelessTerminal;
private IItemDefinition biometricCard;
private IItemDefinition chargedStaff;
private IItemDefinition massCannon;
private IItemDefinition memoryCard;
private IItemDefinition networkTool;
private IItemDefinition portableCell;
private IItemDefinition cellCreative;
private IItemDefinition viewCell;
private IItemDefinition cell1k;
private IItemDefinition cell4k;
private IItemDefinition cell16k;
private IItemDefinition cell64k;
private IItemDefinition fluidCell1k;
private IItemDefinition fluidCell4k;
private IItemDefinition fluidCell16k;
private IItemDefinition fluidCell64k;
private IItemDefinition spatialCell2;
private IItemDefinition spatialCell16;
private IItemDefinition spatialCell128;
private IItemDefinition facade;
private IItemDefinition certusCrystalSeed;
private IItemDefinition fluixCrystalSeed;
private IItemDefinition netherQuartzSeed;
// rv1
private IItemDefinition encodedPattern;
private IItemDefinition colorApplicator;
private AEColoredItemDefinition coloredPaintBall;
private AEColoredItemDefinition coloredLumenPaintBall;
// unsupported dev tools
private IItemDefinition toolEraser;
private IItemDefinition toolMeteoritePlacer;
private IItemDefinition toolDebugCard;
private IItemDefinition toolReplicatorCard;
private IItemDefinition dummyFluidItem;
public ApiItems(FeatureFactory registry, ApiMaterials materials) {
// FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS);
// this.certusQuartzAxe = certusTools
// .item("certus_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
// this.certusQuartzHoe = certusTools
// .item("certus_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
// this.certusQuartzShovel = certusTools
// .item("certus_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
// this.certusQuartzPick = certusTools
// .item("certus_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
// this.certusQuartzSword = certusTools
// .item("certus_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
// this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", QuartzWrenchItem::new)
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
// .build();
// this.certusQuartzKnife = certusTools
// .item("certus_quartz_cutting_knife",
// props -> new QuartzCuttingKnifeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair())
// .addFeatures(AEFeature.QUARTZ_KNIFE).build();
//
// FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS);
// this.netherQuartzAxe = netherTools
// .item("nether_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
// this.netherQuartzHoe = netherTools
// .item("nether_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
// this.netherQuartzShovel = netherTools
// .item("nether_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
// this.netherQuartzPick = netherTools
// .item("nether_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
// this.netherQuartzSword = netherTools
// .item("nether_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
// this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", QuartzWrenchItem::new)
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
// .build();
// this.netherQuartzKnife = netherTools
// .item("nether_quartz_cutting_knife",
// props -> new QuartzCuttingKnifeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair())
// .addFeatures(AEFeature.QUARTZ_KNIFE).build();
//
// Consumer<Item.Settings> chargedDefaults = props -> props.maxStackSize(1).maxDamage(32).setNoRepair();
//
// FeatureFactory powerTools = registry.features(AEFeature.POWERED_TOOLS);
// this.entropyManipulator = powerTools.item("entropy_manipulator", EntropyManipulatorItem::new)
// .props(chargedDefaults).addFeatures(AEFeature.ENTROPY_MANIPULATOR)
// .dispenserBehavior(BlockToolDispenseItemBehavior::new).build();
// this.wirelessTerminal = powerTools.item("wireless_terminal", WirelessTerminalItem::new).props(chargedDefaults)
// .addFeatures(AEFeature.WIRELESS_ACCESS_TERMINAL).build();
// this.chargedStaff = powerTools.item("charged_staff", ChargedStaffItem::new).props(chargedDefaults)
// .addFeatures(AEFeature.CHARGED_STAFF).build();
// this.massCannon = powerTools.item("matter_cannon", MatterCannonItem::new).props(chargedDefaults)
// .addFeatures(AEFeature.MATTER_CANNON).dispenserBehavior(MatterCannonDispenseItemBehavior::new).build();
// this.portableCell = powerTools.item("portable_cell", PortableCellItem::new).props(chargedDefaults)
// .addFeatures(AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS).build();
// this.colorApplicator = powerTools.item("color_applicator", ColorApplicatorItem::new).props(chargedDefaults)
// .addFeatures(AEFeature.COLOR_APPLICATOR).dispenserBehavior(BlockToolDispenseItemBehavior::new)
// .rendering(new ColorApplicatorItemRendering()).build();
//
// this.biometricCard = registry.item("biometric_card", BiometricCardItem::new)
// .props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build();
// this.memoryCard = registry.item("memory_card", MemoryCardItem::new).props(props -> props.maxStackSize(1))
// .features(AEFeature.MEMORY_CARD).build();
// this.networkTool = registry.item("network_tool", NetworkToolItem::new)
// .props(props -> props.maxStackSize(1).addToolType(FabricToolTags.get("wrench"), 0))
// .features(AEFeature.NETWORK_TOOL).build();
//
// this.cellCreative = registry.item("creative_storage_cell", CreativeStorageCellItem::new)
// .props(props -> props.maxStackSize(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build();
// this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxStackSize(1))
// .features(AEFeature.VIEW_CELL).build();
//
// Consumer<Item.Settings> storageCellProps = p -> p.maxStackSize(1);
//
// FeatureFactory storageCells = registry.features(AEFeature.STORAGE_CELLS);
// this.cell1k = storageCells
// .item("1k_storage_cell",
// props -> new BasicStorageCellItem(props, MaterialType.ITEM_1K_CELL_COMPONENT, 1))
// .props(storageCellProps).build();
// this.cell4k = storageCells
// .item("4k_storage_cell",
// props -> new BasicStorageCellItem(props, MaterialType.ITEM_4K_CELL_COMPONENT, 4))
// .props(storageCellProps).build();
// this.cell16k = storageCells
// .item("16k_storage_cell",
// props -> new BasicStorageCellItem(props, MaterialType.ITEM_16K_CELL_COMPONENT, 16))
// .props(storageCellProps).build();
// this.cell64k = storageCells
// .item("64k_storage_cell",
// props -> new BasicStorageCellItem(props, MaterialType.ITEM_64K_CELL_COMPONENT, 64))
// .props(storageCellProps).build();
//
// this.fluidCell1k = storageCells
// .item("1k_fluid_storage_cell",
// props -> new BasicFluidStorageCell(props, MaterialType.FLUID_1K_CELL_COMPONENT, 1))
// .props(storageCellProps).build();
// this.fluidCell4k = storageCells
// .item("4k_fluid_storage_cell",
// props -> new BasicFluidStorageCell(props, MaterialType.FLUID_4K_CELL_COMPONENT, 4))
// .props(storageCellProps).build();
// this.fluidCell16k = storageCells
// .item("16k_fluid_storage_cell",
// props -> new BasicFluidStorageCell(props, MaterialType.FLUID_16K_CELL_COMPONENT, 16))
// .props(storageCellProps).build();
// this.fluidCell64k = storageCells
// .item("64k_fluid_storage_cell",
// props -> new BasicFluidStorageCell(props, MaterialType.FLUID_64K_CELL_COMPONENT, 64))
// .props(storageCellProps).build();
//
// FeatureFactory spatialCells = registry.features(AEFeature.SPATIAL_IO);
// this.spatialCell2 = spatialCells
// .item("2_cubed_spatial_storage_cell", props -> new SpatialStorageCellItem(props, 2))
// .props(storageCellProps).build();
// this.spatialCell16 = spatialCells
// .item("16_cubed_spatial_storage_cell", props -> new SpatialStorageCellItem(props, 16))
// .props(storageCellProps).build();
// this.spatialCell128 = spatialCells
// .item("128_cubed_spatial_storage_cell", props -> new SpatialStorageCellItem(props, 128))
// .props(storageCellProps).build();
//
// this.facade = registry.item("facade", FacadeItem::new).features(AEFeature.FACADES).build();
//
// this.certusCrystalSeed = registry
// .item("certus_crystal_seed",
// props -> new CrystalSeedItem(props, materials.purifiedCertusQuartzCrystal().item()))
// .features(AEFeature.CRYSTAL_SEEDS).build();
// this.fluixCrystalSeed = registry
// .item("fluix_crystal_seed",
// props -> new CrystalSeedItem(props, materials.purifiedFluixCrystal().item()))
// .features(AEFeature.CRYSTAL_SEEDS).build();
// this.netherQuartzSeed = registry
// .item("nether_quartz_seed",
// props -> new CrystalSeedItem(props, materials.purifiedNetherQuartzCrystal().item()))
// .features(AEFeature.CRYSTAL_SEEDS).build();
//
// GrowingCrystalEntity.TYPE = registry
// .<GrowingCrystalEntity>entity("growing_crystal", GrowingCrystalEntity::new, SpawnGroup.MISC)
// .customize(builder -> builder.size(0.25F, 0.25F)).build();
//
// // rv1
// this.encodedPattern = registry.item("encoded_pattern", EncodedPatternItem::new)
// .props(props -> props.maxStackSize(1)).features(AEFeature.PATTERNS).build();
//
// this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false);
// this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true);
//
// FeatureFactory debugTools = registry.features(AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE);
// this.toolEraser = debugTools.item("debug_eraser", EraserItem::new).build();
// this.toolMeteoritePlacer = debugTools.item("debug_meteorite_placer", MeteoritePlacerItem::new).build();
// this.toolDebugCard = debugTools.item("debug_card", DebugCardItem::new).build();
// this.toolReplicatorCard = debugTools.item("debug_replicator_card", ReplicatorCardItem::new).build();
// debugTools.item("debug_part_placer", DebugPartPlacerItem::new).build();
//
// this.dummyFluidItem = registry.item("dummy_fluid_item", FluidDummyItem::new)
// .rendering(new FluidDummyItemRendering()).build();
}
// private static AEColoredItemDefinition createPaintBalls(FeatureFactory registry, String idSuffix, boolean lumen) {
// ColoredItemDefinition colors = new ColoredItemDefinition();
// for (AEColor color : AEColor.values()) {
// if (color == AEColor.TRANSPARENT) {
// continue; // Fluix paintballs don't exist
// }
//
// String id = color.registryPrefix + idSuffix;
// IItemDefinition paintBall = registry.item(id, props -> new PaintBallItem(props, color, lumen))
// .features(AEFeature.PAINT_BALLS).rendering(new PaintBallItemRendering(color, lumen)).build();
// colors.add(color, new ItemStackSrc(paintBall.item(), ActivityState.Enabled));
// }
// return colors;
// }
//
@Override
public IItemDefinition certusQuartzAxe() {
return this.certusQuartzAxe;
}
@Override
public IItemDefinition certusQuartzHoe() {
return this.certusQuartzHoe;
}
@Override
public IItemDefinition certusQuartzShovel() {
return this.certusQuartzShovel;
}
@Override
public IItemDefinition certusQuartzPick() {
return this.certusQuartzPick;
}
@Override
public IItemDefinition certusQuartzSword() {
return this.certusQuartzSword;
}
@Override
public IItemDefinition certusQuartzWrench() {
return this.certusQuartzWrench;
}
@Override
public IItemDefinition certusQuartzKnife() {
return this.certusQuartzKnife;
}
@Override
public IItemDefinition netherQuartzAxe() {
return this.netherQuartzAxe;
}
@Override
public IItemDefinition netherQuartzHoe() {
return this.netherQuartzHoe;
}
@Override
public IItemDefinition netherQuartzShovel() {
return this.netherQuartzShovel;
}
@Override
public IItemDefinition netherQuartzPick() {
return this.netherQuartzPick;
}
@Override
public IItemDefinition netherQuartzSword() {
return this.netherQuartzSword;
}
@Override
public IItemDefinition netherQuartzWrench() {
return this.netherQuartzWrench;
}
@Override
public IItemDefinition netherQuartzKnife() {
return this.netherQuartzKnife;
}
@Override
public IItemDefinition entropyManipulator() {
return this.entropyManipulator;
}
@Override
public IItemDefinition wirelessTerminal() {
return this.wirelessTerminal;
}
@Override
public IItemDefinition biometricCard() {
return this.biometricCard;
}
@Override
public IItemDefinition chargedStaff() {
return this.chargedStaff;
}
@Override
public IItemDefinition massCannon() {
return this.massCannon;
}
@Override
public IItemDefinition memoryCard() {
return this.memoryCard;
}
@Override
public IItemDefinition networkTool() {
return this.networkTool;
}
@Override
public IItemDefinition portableCell() {
return this.portableCell;
}
@Override
public IItemDefinition cellCreative() {
return this.cellCreative;
}
@Override
public IItemDefinition viewCell() {
return this.viewCell;
}
@Override
public IItemDefinition cell1k() {
return this.cell1k;
}
@Override
public IItemDefinition cell4k() {
return this.cell4k;
}
@Override
public IItemDefinition cell16k() {
return this.cell16k;
}
@Override
public IItemDefinition cell64k() {
return this.cell64k;
}
@Override
public IItemDefinition fluidCell1k() {
return this.fluidCell1k;
}
@Override
public IItemDefinition fluidCell4k() {
return this.fluidCell4k;
}
@Override
public IItemDefinition fluidCell16k() {
return this.fluidCell16k;
}
@Override
public IItemDefinition fluidCell64k() {
return this.fluidCell64k;
}
@Override
public IItemDefinition spatialCell2() {
return this.spatialCell2;
}
@Override
public IItemDefinition spatialCell16() {
return this.spatialCell16;
}
@Override
public IItemDefinition spatialCell128() {
return this.spatialCell128;
}
@Override
public IItemDefinition facade() {
return this.facade;
}
@Override
public IItemDefinition certusCrystalSeed() {
return certusCrystalSeed;
}
@Override
public IItemDefinition fluixCrystalSeed() {
return fluixCrystalSeed;
}
@Override
public IItemDefinition netherQuartzSeed() {
return netherQuartzSeed;
}
@Override
public IItemDefinition encodedPattern() {
return this.encodedPattern;
}
@Override
public IItemDefinition colorApplicator() {
return this.colorApplicator;
}
@Override
public AEColoredItemDefinition coloredPaintBall() {
return this.coloredPaintBall;
}
@Override
public AEColoredItemDefinition coloredLumenPaintBall() {
return this.coloredLumenPaintBall;
}
public IItemDefinition toolEraser() {
return this.toolEraser;
}
public IItemDefinition toolMeteoritePlacer() {
return this.toolMeteoritePlacer;
}
public IItemDefinition toolDebugCard() {
return this.toolDebugCard;
}
public IItemDefinition toolReplicatorCard() {
return this.toolReplicatorCard;
}
@Override
public IItemDefinition dummyFluidItem() {
return this.dummyFluidItem;
}
}
@@ -0,0 +1,491 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import com.google.common.base.Preconditions;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.SpawnGroup;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature;
import appeng.bootstrap.FeatureFactory;
import appeng.core.AEConfig;
import appeng.entity.ChargedQuartzEntity;
import appeng.entity.SingularityEntity;
import appeng.items.materials.MaterialItem;
import appeng.items.materials.MaterialType;
/**
* Internal implementation for the API materials
*/
public final class ApiMaterials implements IMaterials {
private final IItemDefinition cell2SpatialPart;
private final IItemDefinition cell16SpatialPart;
private final IItemDefinition cell128SpatialPart;
private final IItemDefinition silicon;
private final IItemDefinition skyDust;
private final IItemDefinition calcProcessorPress;
private final IItemDefinition engProcessorPress;
private final IItemDefinition logicProcessorPress;
private final IItemDefinition calcProcessorPrint;
private final IItemDefinition engProcessorPrint;
private final IItemDefinition logicProcessorPrint;
private final IItemDefinition siliconPress;
private final IItemDefinition siliconPrint;
private final IItemDefinition namePress;
private final IItemDefinition logicProcessor;
private final IItemDefinition calcProcessor;
private final IItemDefinition engProcessor;
private final IItemDefinition basicCard;
private final IItemDefinition advCard;
private final IItemDefinition purifiedCertusQuartzCrystal;
private final IItemDefinition purifiedNetherQuartzCrystal;
private final IItemDefinition purifiedFluixCrystal;
private final IItemDefinition cell1kPart;
private final IItemDefinition cell4kPart;
private final IItemDefinition cell16kPart;
private final IItemDefinition cell64kPart;
private final IItemDefinition emptyStorageCell;
private final IItemDefinition cardRedstone;
private final IItemDefinition cardSpeed;
private final IItemDefinition cardCapacity;
private final IItemDefinition cardFuzzy;
private final IItemDefinition cardInverter;
private final IItemDefinition cardCrafting;
private final IItemDefinition enderDust;
private final IItemDefinition flour;
private final IItemDefinition goldDust;
private final IItemDefinition ironDust;
private final IItemDefinition fluixDust;
private final IItemDefinition certusQuartzDust;
private final IItemDefinition netherQuartzDust;
private final IItemDefinition matterBall;
private final IItemDefinition certusQuartzCrystal;
private final IItemDefinition certusQuartzCrystalCharged;
private final IItemDefinition fluixCrystal;
private final IItemDefinition fluixPearl;
private final IItemDefinition woodenGear;
private final IItemDefinition wirelessReceiver;
private final IItemDefinition wirelessBooster;
private final IItemDefinition annihilationCore;
private final IItemDefinition formationCore;
private final IItemDefinition singularity;
private final IItemDefinition qESingularity;
private final IItemDefinition blankPattern;
private final IItemDefinition fluidCell1kPart;
private final IItemDefinition fluidCell4kPart;
private final IItemDefinition fluidCell16kPart;
private final IItemDefinition fluidCell64kPart;
private final FeatureFactory registry;
public ApiMaterials(FeatureFactory registry) {
this.registry = registry;
SingularityEntity.TYPE = registry
.<SingularityEntity>entity("singularity", SingularityEntity::new, SpawnGroup.MISC)
.customize(b -> b.trackable(16, 4, true).dimensions(EntityDimensions.fixed(0.2f, 0.2f)))
.build();
ChargedQuartzEntity.TYPE = registry
.<ChargedQuartzEntity>entity("charged_quartz", ChargedQuartzEntity::new, SpawnGroup.MISC)
.customize(b -> b.trackable(16, 4, true).dimensions(EntityDimensions.fixed(0.2f, 0.2f)))
.build();
this.cell2SpatialPart = createMaterial(MaterialType.SPATIAL_2_CELL_COMPONENT);
this.cell16SpatialPart = createMaterial(MaterialType.SPATIAL_16_CELL_COMPONENT);
this.cell128SpatialPart = createMaterial(MaterialType.SPATIAL_128_CELL_COMPONENT);
this.silicon = createMaterial(MaterialType.SILICON);
this.skyDust = createMaterial(MaterialType.SKY_DUST);
this.calcProcessorPress = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRESS);
this.engProcessorPress = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRESS);
this.logicProcessorPress = createMaterial(MaterialType.LOGIC_PROCESSOR_PRESS);
this.siliconPress = createMaterial(MaterialType.SILICON_PRESS);
this.namePress = createMaterial(MaterialType.NAME_PRESS);
this.calcProcessorPrint = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRINT);
this.engProcessorPrint = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRINT);
this.logicProcessorPrint = createMaterial(MaterialType.LOGIC_PROCESSOR_PRINT);
this.siliconPrint = createMaterial(MaterialType.SILICON_PRINT);
this.logicProcessor = createMaterial(MaterialType.LOGIC_PROCESSOR);
this.calcProcessor = createMaterial(MaterialType.CALCULATION_PROCESSOR);
this.engProcessor = createMaterial(MaterialType.ENGINEERING_PROCESSOR);
this.basicCard = createMaterial(MaterialType.BASIC_CARD);
this.advCard = createMaterial(MaterialType.ADVANCED_CARD);
this.purifiedCertusQuartzCrystal = createMaterial(MaterialType.PURIFIED_CERTUS_QUARTZ_CRYSTAL);
this.purifiedNetherQuartzCrystal = createMaterial(MaterialType.PURIFIED_NETHER_QUARTZ_CRYSTAL);
this.purifiedFluixCrystal = createMaterial(MaterialType.PURIFIED_FLUIX_CRYSTAL);
this.cell1kPart = createMaterial(MaterialType.ITEM_1K_CELL_COMPONENT);
this.cell4kPart = createMaterial(MaterialType.ITEM_4K_CELL_COMPONENT);
this.cell16kPart = createMaterial(MaterialType.ITEM_16K_CELL_COMPONENT);
this.cell64kPart = createMaterial(MaterialType.ITEM_64K_CELL_COMPONENT);
this.emptyStorageCell = createMaterial(MaterialType.EMPTY_STORAGE_CELL);
this.cardRedstone = createMaterial(MaterialType.CARD_REDSTONE);
this.cardSpeed = createMaterial(MaterialType.CARD_SPEED);
this.cardCapacity = createMaterial(MaterialType.CARD_CAPACITY);
this.cardFuzzy = createMaterial(MaterialType.CARD_FUZZY);
this.cardInverter = createMaterial(MaterialType.CARD_INVERTER);
this.cardCrafting = createMaterial(MaterialType.CARD_CRAFTING);
this.enderDust = createMaterial(MaterialType.ENDER_DUST);
this.flour = createMaterial(MaterialType.FLOUR);
this.goldDust = createMaterial(MaterialType.GOLD_DUST);
this.ironDust = createMaterial(MaterialType.IRON_DUST);
this.fluixDust = createMaterial(MaterialType.FLUIX_DUST);
this.certusQuartzDust = createMaterial(MaterialType.CERTUS_QUARTZ_DUST);
this.netherQuartzDust = createMaterial(MaterialType.NETHER_QUARTZ_DUST);
this.matterBall = createMaterial(MaterialType.MATTER_BALL);
this.certusQuartzCrystal = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL);
this.certusQuartzCrystalCharged = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL_CHARGED);
this.fluixCrystal = createMaterial(MaterialType.FLUIX_CRYSTAL);
this.fluixPearl = createMaterial(MaterialType.FLUIX_PEARL);
this.woodenGear = createMaterial(MaterialType.WOODEN_GEAR);
this.wirelessReceiver = createMaterial(MaterialType.WIRELESS_RECEIVER);
this.wirelessBooster = createMaterial(MaterialType.WIRELESS_BOOSTER);
this.annihilationCore = createMaterial(MaterialType.ANNIHILATION_CORE);
this.formationCore = createMaterial(MaterialType.FORMATION_CORE);
this.singularity = createMaterial(MaterialType.SINGULARITY);
this.qESingularity = createMaterial(MaterialType.QUANTUM_ENTANGLED_SINGULARITY);
this.blankPattern = createMaterial(MaterialType.BLANK_PATTERN);
this.fluidCell1kPart = createMaterial(MaterialType.FLUID_1K_CELL_COMPONENT);
this.fluidCell4kPart = createMaterial(MaterialType.FLUID_4K_CELL_COMPONENT);
this.fluidCell16kPart = createMaterial(MaterialType.FLUID_16K_CELL_COMPONENT);
this.fluidCell64kPart = createMaterial(MaterialType.FLUID_64K_CELL_COMPONENT);
}
private IItemDefinition createMaterial(final MaterialType mat) {
Preconditions.checkState(!mat.isRegistered(), "Cannot create the same material twice.");
IItemDefinition def = registry.item(mat.getId(), props -> new MaterialItem(props, mat))
.features(mat.getFeature().toArray(new AEFeature[0])).build();
boolean enabled = true;
for (final AEFeature f : mat.getFeature()) {
enabled = enabled && AEConfig.instance().isFeatureEnabled(f);
}
mat.setItemInstance(def.item());
mat.markReady();
return def;
}
@Override
public IItemDefinition cell2SpatialPart() {
return this.cell2SpatialPart;
}
@Override
public IItemDefinition cell16SpatialPart() {
return this.cell16SpatialPart;
}
@Override
public IItemDefinition cell128SpatialPart() {
return this.cell128SpatialPart;
}
@Override
public IItemDefinition silicon() {
return this.silicon;
}
@Override
public IItemDefinition skyDust() {
return this.skyDust;
}
@Override
public IItemDefinition calcProcessorPress() {
return this.calcProcessorPress;
}
@Override
public IItemDefinition engProcessorPress() {
return this.engProcessorPress;
}
@Override
public IItemDefinition logicProcessorPress() {
return this.logicProcessorPress;
}
@Override
public IItemDefinition calcProcessorPrint() {
return this.calcProcessorPrint;
}
@Override
public IItemDefinition engProcessorPrint() {
return this.engProcessorPrint;
}
@Override
public IItemDefinition logicProcessorPrint() {
return this.logicProcessorPrint;
}
@Override
public IItemDefinition siliconPress() {
return this.siliconPress;
}
@Override
public IItemDefinition siliconPrint() {
return this.siliconPrint;
}
@Override
public IItemDefinition namePress() {
return this.namePress;
}
@Override
public IItemDefinition logicProcessor() {
return this.logicProcessor;
}
@Override
public IItemDefinition calcProcessor() {
return this.calcProcessor;
}
@Override
public IItemDefinition engProcessor() {
return this.engProcessor;
}
@Override
public IItemDefinition basicCard() {
return this.basicCard;
}
@Override
public IItemDefinition advCard() {
return this.advCard;
}
@Override
public IItemDefinition purifiedCertusQuartzCrystal() {
return this.purifiedCertusQuartzCrystal;
}
@Override
public IItemDefinition purifiedNetherQuartzCrystal() {
return this.purifiedNetherQuartzCrystal;
}
@Override
public IItemDefinition purifiedFluixCrystal() {
return this.purifiedFluixCrystal;
}
@Override
public IItemDefinition cell1kPart() {
return this.cell1kPart;
}
@Override
public IItemDefinition cell4kPart() {
return this.cell4kPart;
}
@Override
public IItemDefinition cell16kPart() {
return this.cell16kPart;
}
@Override
public IItemDefinition cell64kPart() {
return this.cell64kPart;
}
@Override
public IItemDefinition emptyStorageCell() {
return this.emptyStorageCell;
}
@Override
public IItemDefinition cardRedstone() {
return this.cardRedstone;
}
@Override
public IItemDefinition cardSpeed() {
return this.cardSpeed;
}
@Override
public IItemDefinition cardCapacity() {
return this.cardCapacity;
}
@Override
public IItemDefinition cardFuzzy() {
return this.cardFuzzy;
}
@Override
public IItemDefinition cardInverter() {
return this.cardInverter;
}
@Override
public IItemDefinition cardCrafting() {
return this.cardCrafting;
}
@Override
public IItemDefinition enderDust() {
return this.enderDust;
}
@Override
public IItemDefinition flour() {
return this.flour;
}
@Override
public IItemDefinition goldDust() {
return this.goldDust;
}
@Override
public IItemDefinition ironDust() {
return this.ironDust;
}
@Override
public IItemDefinition fluixDust() {
return this.fluixDust;
}
@Override
public IItemDefinition certusQuartzDust() {
return this.certusQuartzDust;
}
@Override
public IItemDefinition netherQuartzDust() {
return this.netherQuartzDust;
}
@Override
public IItemDefinition matterBall() {
return this.matterBall;
}
@Override
public IItemDefinition certusQuartzCrystal() {
return this.certusQuartzCrystal;
}
@Override
public IItemDefinition certusQuartzCrystalCharged() {
return this.certusQuartzCrystalCharged;
}
@Override
public IItemDefinition fluixCrystal() {
return this.fluixCrystal;
}
@Override
public IItemDefinition fluixPearl() {
return this.fluixPearl;
}
@Override
public IItemDefinition woodenGear() {
return this.woodenGear;
}
@Override
public IItemDefinition wirelessReceiver() {
return this.wirelessReceiver;
}
@Override
public IItemDefinition wirelessBooster() {
return this.wirelessBooster;
}
@Override
public IItemDefinition annihilationCore() {
return this.annihilationCore;
}
@Override
public IItemDefinition formationCore() {
return this.formationCore;
}
@Override
public IItemDefinition singularity() {
return this.singularity;
}
@Override
public IItemDefinition qESingularity() {
return this.qESingularity;
}
@Override
public IItemDefinition blankPattern() {
return this.blankPattern;
}
@Override
public IItemDefinition fluidCell1kPart() {
return this.fluidCell1kPart;
}
@Override
public IItemDefinition fluidCell4kPart() {
return this.fluidCell4kPart;
}
@Override
public IItemDefinition fluidCell16kPart() {
return this.fluidCell16kPart;
}
@Override
public IItemDefinition fluidCell64kPart() {
return this.fluidCell64kPart;
}
}
@@ -0,0 +1,385 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.features.registries.PartModels;
/**
* Internal implementation for the API parts
*/
public final class ApiParts implements IParts {
private AEColoredItemDefinition cableSmart;
private AEColoredItemDefinition cableCovered;
private AEColoredItemDefinition cableGlass;
private AEColoredItemDefinition cableDenseCovered;
private AEColoredItemDefinition cableDenseSmart;
private IItemDefinition quartzFiber;
private IItemDefinition toggleBus;
private IItemDefinition invertedToggleBus;
private IItemDefinition storageBus;
private IItemDefinition importBus;
private IItemDefinition exportBus;
private IItemDefinition iface;
private IItemDefinition fluidIface;
private IItemDefinition levelEmitter;
private IItemDefinition fluidLevelEmitter;
private IItemDefinition annihilationPlane;
private IItemDefinition identityAnnihilationPlane;
private IItemDefinition fluidAnnihilationPlane;
private IItemDefinition formationPlane;
private IItemDefinition fluidFormationPlane;
private IItemDefinition p2PTunnelME;
private IItemDefinition p2PTunnelRedstone;
private IItemDefinition p2PTunnelItems;
private IItemDefinition p2PTunnelFluids;
private IItemDefinition p2PTunnelEU;
private IItemDefinition p2PTunnelFE;
private IItemDefinition p2PTunnelLight;
private IItemDefinition cableAnchor;
private IItemDefinition monitor;
private IItemDefinition semiDarkMonitor;
private IItemDefinition darkMonitor;
private IItemDefinition interfaceTerminal;
private IItemDefinition patternTerminal;
private IItemDefinition craftingTerminal;
private IItemDefinition terminal;
private IItemDefinition storageMonitor;
private IItemDefinition conversionMonitor;
private IItemDefinition fluidImportBus;
private IItemDefinition fluidExportBus;
private IItemDefinition fluidTerminal;
private IItemDefinition fluidStorageBus;
public ApiParts(FeatureFactory registry, PartModels partModels) {
registerPartModels(partModels);
// FIXME this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART,
// FIXME SmartCablePart::new);
// FIXME this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED,
// FIXME CoveredCablePart::new);
// FIXME this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS,
// FIXME GlassCablePart::new);
// FIXME this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable",
// FIXME PartType.CABLE_DENSE_COVERED, CoveredDenseCablePart::new);
// FIXME this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART,
// FIXME SmartDenseCablePart::new);
// FIXME this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, QuartzFiberPart::new);
// FIXME this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, ToggleBusPart::new);
// FIXME this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS,
// FIXME InvertedToggleBusPart::new);
// FIXME this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, CableAnchorPart::new);
// FIXME this.monitor = createPart(registry, "monitor", PartType.MONITOR, PanelPart::new);
// FIXME this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR,
// FIXME SemiDarkPanelPart::new);
// FIXME this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, DarkPanelPart::new);
// FIXME this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, StorageBusPart::new);
// FIXME this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS,
// FIXME FluidStorageBusPart::new);
// FIXME this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, ImportBusPart::new);
// FIXME this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS,
// FIXME FluidImportBusPart::new);
// FIXME this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, ExportBusPart::new);
// FIXME this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS,
// FIXME FluidExportBusPart::new);
// FIXME this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, LevelEmitterPart::new);
// FIXME this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER,
// FIXME FluidLevelEmitterPart::new);
// FIXME this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE,
// FIXME AnnihilationPlanePart::new);
// FIXME this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane",
// FIXME PartType.IDENTITY_ANNIHILATION_PLANE, IdentityAnnihilationPlanePart::new);
// FIXME this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane",
// FIXME PartType.FLUID_ANNIHILATION_PLANE, FluidAnnihilationPlanePart::new);
// FIXME this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE,
// FIXME FormationPlanePart::new);
// FIXME this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE,
// FIXME FluidFormationPlanePart::new);
// FIXME this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL,
// FIXME PatternTerminalPart::new);
// FIXME this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL,
// FIXME CraftingTerminalPart::new);
// FIXME this.terminal = createPart(registry, "terminal", PartType.TERMINAL, TerminalPart::new);
// FIXME this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR,
// FIXME StorageMonitorPart::new);
// FIXME this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR,
// FIXME ConversionMonitorPart::new);
// FIXME this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, InterfacePart::new);
// FIXME this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE,
// FIXME FluidInterfacePart::new);
// FIXME this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, MEP2PTunnelPart::new);
// FIXME this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE,
// FIXME RedstoneP2PTunnelPart::new);
// FIXME this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, ItemP2PTunnelPart::new);
// FIXME this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID,
// FIXME FluidP2PTunnelPart::new);
// FIXME this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2,
// FIXME // PartP2PIC2Power::new);
// FIXME this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, FEP2PTunnelPart::new);
// FIXME this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT,
// FIXME LightP2PTunnelPart::new);
// FIXME this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL,
// FIXME InterfaceTerminalPart::new);
// FIXME this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, FluidTerminalPart::new);
}
private void registerPartModels(PartModels partModels) {
// FIXME // Register the built-in models for annihilation planes
// FIXME Identifier fluidFormationPlaneTexture = new Identifier(AppEng.MOD_ID,
// FIXME "item/part/fluid_formation_plane");
// FIXME Identifier fluidFormationPlaneOnTexture = new Identifier(AppEng.MOD_ID,
// FIXME "parts/fluid_formation_plane_on");
// FIXME
// FIXME // Register all part models
// FIXME for (PartType partType : PartType.values()) {
// FIXME partModels.registerModels(partType.getModels());
// FIXME }
}
// FIXME private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id, PartType type,
// FIXME Function<ItemStack, T> factory) {
// FIXME return registry.item(id, props -> new PartItem<>(props, type, factory)).itemGroup(CreativeTab.INSTANCE)
// FIXME .rendering(new PartItemRendering()).build();
// FIXME }
// FIXME
// FIXME private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry,
// FIXME String idSuffix, PartType type, Function<ItemStack, T> factory) {
// FIXME final ColoredItemDefinition definition = new ColoredItemDefinition();
// FIXME
// FIXME for (final AEColor color : AEColor.values()) {
// FIXME String id = color.registryPrefix + '_' + idSuffix;
// FIXME
// FIXME IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color))
// FIXME .itemGroup(CreativeTab.INSTANCE).rendering(new PartItemRendering(color)).build();
// FIXME
// FIXME definition.add(color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled));
// FIXME }
// FIXME
// FIXME return definition;
// FIXME }
@Override
public AEColoredItemDefinition cableSmart() {
return this.cableSmart;
}
@Override
public AEColoredItemDefinition cableCovered() {
return this.cableCovered;
}
@Override
public AEColoredItemDefinition cableGlass() {
return this.cableGlass;
}
@Override
public AEColoredItemDefinition cableDenseCovered() {
return this.cableDenseCovered;
}
@Override
public AEColoredItemDefinition cableDenseSmart() {
return this.cableDenseSmart;
}
@Override
public IItemDefinition quartzFiber() {
return this.quartzFiber;
}
@Override
public IItemDefinition toggleBus() {
return this.toggleBus;
}
@Override
public IItemDefinition invertedToggleBus() {
return this.invertedToggleBus;
}
@Override
public IItemDefinition storageBus() {
return this.storageBus;
}
@Override
public IItemDefinition importBus() {
return this.importBus;
}
@Override
public IItemDefinition exportBus() {
return this.exportBus;
}
@Override
public IItemDefinition iface() {
return this.iface;
}
@Override
public IItemDefinition fluidIface() {
return this.fluidIface;
}
@Override
public IItemDefinition levelEmitter() {
return this.levelEmitter;
}
@Override
public IItemDefinition annihilationPlane() {
return this.annihilationPlane;
}
@Override
public IItemDefinition identityAnnihilationPlane() {
return this.identityAnnihilationPlane;
}
@Override
public IItemDefinition formationPlane() {
return this.formationPlane;
}
@Override
public IItemDefinition p2PTunnelME() {
return this.p2PTunnelME;
}
@Override
public IItemDefinition p2PTunnelRedstone() {
return this.p2PTunnelRedstone;
}
@Override
public IItemDefinition p2PTunnelItems() {
return this.p2PTunnelItems;
}
@Override
public IItemDefinition p2PTunnelFluids() {
return this.p2PTunnelFluids;
}
@Override
public IItemDefinition p2PTunnelEU() {
return this.p2PTunnelEU;
}
@Override
public IItemDefinition p2PTunnelFE() {
return this.p2PTunnelFE;
}
@Override
public IItemDefinition p2PTunnelLight() {
return this.p2PTunnelLight;
}
@Override
public IItemDefinition cableAnchor() {
return this.cableAnchor;
}
@Override
public IItemDefinition monitor() {
return this.monitor;
}
@Override
public IItemDefinition semiDarkMonitor() {
return this.semiDarkMonitor;
}
@Override
public IItemDefinition darkMonitor() {
return this.darkMonitor;
}
@Override
public IItemDefinition interfaceTerminal() {
return this.interfaceTerminal;
}
@Override
public IItemDefinition patternTerminal() {
return this.patternTerminal;
}
@Override
public IItemDefinition craftingTerminal() {
return this.craftingTerminal;
}
@Override
public IItemDefinition terminal() {
return this.terminal;
}
@Override
public IItemDefinition storageMonitor() {
return this.storageMonitor;
}
@Override
public IItemDefinition conversionMonitor() {
return this.conversionMonitor;
}
@Override
public IItemDefinition fluidTerminal() {
return this.fluidTerminal;
}
@Override
public IItemDefinition fluidImportBus() {
return this.fluidImportBus;
}
@Override
public IItemDefinition fluidExportBus() {
return this.fluidExportBus;
}
@Override
public IItemDefinition fluidStorageBus() {
return this.fluidStorageBus;
}
@Override
public IItemDefinition fluidLevelEmitter() {
return this.fluidLevelEmitter;
}
@Override
public IItemDefinition fluidAnnihilationPlane() {
return this.fluidAnnihilationPlane;
}
@Override
public IItemDefinition fluidFormationnPlane() {
return this.fluidFormationPlane;
}
}
@@ -0,0 +1,71 @@
/*
* 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.core.features.registries;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridCacheRegistry;
import appeng.core.AELog;
public final class GridCacheRegistry implements IGridCacheRegistry {
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
@Override
public void registerGridCache(final Class<? extends IGridCache> iface,
final Class<? extends IGridCache> implementation) {
if (iface.isAssignableFrom(implementation)) {
this.caches.put(iface, implementation);
} else {
throw new IllegalArgumentException(
"Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: "
+ iface + " and " + implementation);
}
}
@Override
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(final IGrid g) {
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
for (final Class<? extends IGridCache> iface : this.caches.keySet()) {
try {
final Constructor<? extends IGridCache> c = this.caches.get(iface).getConstructor(IGrid.class);
map.put(iface, c.newInstance(g));
} catch (final NoSuchMethodException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalArgumentException(e);
} catch (final InvocationTargetException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
} catch (final InstantiationException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
} catch (final IllegalAccessException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
}
}
return map;
}
}
@@ -0,0 +1,53 @@
/*
* 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.core.features.registries;
import java.util.HashMap;
import java.util.Map;
import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.features.ILocatable;
import appeng.api.features.ILocatableRegistry;
import appeng.util.Platform;
public final class LocatableRegistry implements ILocatableRegistry {
private final Map<Long, ILocatable> set;
public LocatableRegistry() {
this.set = new HashMap<>();
LocatableEventAnnounce.EVENT.register((target, change) -> {
if (Platform.isClient()) {
return; // IGNORE!
}
if (change == LocatableEvent.REGISTER) {
this.set.put(target.getLocatableSerial(), target);
} else if (change == LocatableEvent.UNREGISTER) {
this.set.remove(target.getLocatableSerial());
}
});
}
@Override
public ILocatable getLocatableBy(final long serial) {
return this.set.get(serial);
}
}
@@ -0,0 +1,149 @@
/*
* 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.core.features.registries;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tag.ItemTags;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import appeng.api.features.IMatterCannonAmmoRegistry;
public class MatterCannonAmmoRegistry implements IMatterCannonAmmoRegistry {
/**
* Contains a mapping from
*/
private final Map<Identifier, Double> tagDamageModifiers = new HashMap<>();
private final Map<Item, Double> itemDamageModifiers = new IdentityHashMap<>();
public MatterCannonAmmoRegistry() {
this.addTagWeight("forge:nuggets/meatraw", 32);
this.addTagWeight("forge:nuggets/meatcooked", 32);
this.addTagWeight("forge:nuggets/meat", 32);
this.addTagWeight("forge:nuggets/chicken", 32);
this.addTagWeight("forge:nuggets/beef", 32);
this.addTagWeight("forge:nuggets/sheep", 32);
this.addTagWeight("forge:nuggets/fish", 32);
// real world...
this.addTagWeight("forge:nuggets/lithium", 6.941);
this.addTagWeight("forge:nuggets/beryllium", 9.0122);
this.addTagWeight("forge:nuggets/boron", 10.811);
this.addTagWeight("forge:nuggets/carbon", 12.0107);
this.addTagWeight("forge:nuggets/coal", 12.0107);
this.addTagWeight("forge:nuggets/charcoal", 12.0107);
this.addTagWeight("forge:nuggets/sodium", 22.9897);
this.addTagWeight("forge:nuggets/magnesium", 24.305);
this.addTagWeight("forge:nuggets/aluminum", 26.9815);
this.addTagWeight("forge:nuggets/silicon", 28.0855);
this.addTagWeight("forge:nuggets/phosphorus", 30.9738);
this.addTagWeight("forge:nuggets/sulfur", 32.065);
this.addTagWeight("forge:nuggets/potassium", 39.0983);
this.addTagWeight("forge:nuggets/calcium", 40.078);
this.addTagWeight("forge:nuggets/scandium", 44.9559);
this.addTagWeight("forge:nuggets/titanium", 47.867);
this.addTagWeight("forge:nuggets/vanadium", 50.9415);
this.addTagWeight("forge:nuggets/manganese", 54.938);
this.addTagWeight("forge:nuggets/iron", 55.845);
this.addTagWeight("forge:nuggets/gold", 196.96655);
this.addTagWeight("forge:nuggets/nickel", 58.6934);
this.addTagWeight("forge:nuggets/cobalt", 58.9332);
this.addTagWeight("forge:nuggets/copper", 63.546);
this.addTagWeight("forge:nuggets/zinc", 65.39);
this.addTagWeight("forge:nuggets/gallium", 69.723);
this.addTagWeight("forge:nuggets/germanium", 72.64);
this.addTagWeight("forge:nuggets/bromine", 79.904);
this.addTagWeight("forge:nuggets/krypton", 83.8);
this.addTagWeight("forge:nuggets/rubidium", 85.4678);
this.addTagWeight("forge:nuggets/strontium", 87.62);
this.addTagWeight("forge:nuggets/yttrium", 88.9059);
this.addTagWeight("forge:nuggets/zirconium", 91.224);
this.addTagWeight("forge:nuggets/niobium", 92.9064);
this.addTagWeight("forge:nuggets/technetium", 98);
this.addTagWeight("forge:nuggets/ruthenium", 101.07);
this.addTagWeight("forge:nuggets/rhodium", 102.9055);
this.addTagWeight("forge:nuggets/palladium", 106.42);
this.addTagWeight("forge:nuggets/silver", 107.8682);
this.addTagWeight("forge:nuggets/cadmium", 112.411);
this.addTagWeight("forge:nuggets/indium", 114.818);
this.addTagWeight("forge:nuggets/tin", 118.71);
this.addTagWeight("forge:nuggets/antimony", 121.76);
this.addTagWeight("forge:nuggets/iodine", 126.9045);
this.addTagWeight("forge:nuggets/tellurium", 127.6);
this.addTagWeight("forge:nuggets/xenon", 131.293);
this.addTagWeight("forge:nuggets/cesium", 132.9055);
this.addTagWeight("forge:nuggets/barium", 137.327);
this.addTagWeight("forge:nuggets/lanthanum", 138.9055);
this.addTagWeight("forge:nuggets/cerium", 140.116);
this.addTagWeight("forge:nuggets/tantalum", 180.9479);
this.addTagWeight("forge:nuggets/tungsten", 183.84);
this.addTagWeight("forge:nuggets/osmium", 190.23);
this.addTagWeight("forge:nuggets/iridium", 192.217);
this.addTagWeight("forge:nuggets/platinum", 195.078);
this.addTagWeight("forge:nuggets/lead", 207.2);
this.addTagWeight("forge:nuggets/bismuth", 208.9804);
this.addTagWeight("forge:nuggets/uranium", 238.0289);
this.addTagWeight("forge:nuggets/plutonium", 244);
// TE stuff...
this.addTagWeight("forge:nuggets/invar", (58.6934 + 55.845 + 55.845) / 3.0);
this.addTagWeight("forge:nuggets/electrum", (107.8682 + 196.96655) / 2.0);
}
@Override
public void registerAmmoItem(final Item ammo, final double weight) {
this.itemDamageModifiers.put(ammo, weight);
}
@Override
public void registerAmmoTag(final Identifier ammoTag, final double weight) {
this.tagDamageModifiers.put(ammoTag, weight);
}
@Override
public float getPenetration(final ItemStack is) {
// Check for an exact item match first
Item item = is.getItem();
Double weight = itemDamageModifiers.get(item);
if (weight != null) {
return weight.floatValue();
}
// Next, check each item tag
for (Map.Entry<Identifier, Double> entry : tagDamageModifiers.entrySet()) {
Tag<Item> itemTag = ItemTags.getContainer().get(entry.getKey());
if (itemTag != null && itemTag.contains(item)) {
return entry.getValue().floatValue();
}
}
return 0;
}
private void addTagWeight(String name, final double weight) {
this.registerAmmoTag(new Identifier(name), weight);
}
}
@@ -0,0 +1,146 @@
/*
* 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.core.features.registries;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import appeng.api.exceptions.AppEngException;
import appeng.api.movable.IMovableHandler;
import appeng.api.movable.IMovableRegistry;
import appeng.api.movable.IMovableTile;
import appeng.spatial.DefaultSpatialHandler;
public class MovableTileRegistry implements IMovableRegistry {
private final HashSet<Block> blacklisted = new HashSet<>();
private final HashMap<Class<? extends BlockEntity>, IMovableHandler> Valid = new HashMap<>();
private final List<Class<? extends BlockEntity>> test = new ArrayList<>();
private final List<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
@Override
public void blacklistBlock(final Block blk) {
this.blacklisted.add(blk);
}
@Override
public void whiteListTileEntity(final Class<? extends BlockEntity> c) {
if (c.getName().equals(BlockEntity.class.getName())) {
throw new IllegalArgumentException(new AppEngException("Someone tried to make all tiles movable with " + c
+ ", this is a clear violation of the purpose of the white list."));
}
this.test.add(c);
}
@Override
public boolean askToMove(final BlockEntity te) {
final Class myClass = te.getClass();
IMovableHandler canMove = this.Valid.get(myClass);
if (canMove == null) {
canMove = this.testClass(myClass, te);
}
if (canMove != this.nullHandler) {
if (te instanceof IMovableTile) {
((IMovableTile) te).prepareToMove();
}
te.markRemoved();
return true;
}
return false;
}
private IMovableHandler testClass(final Class myClass, final BlockEntity te) {
IMovableHandler handler = null;
// ask handlers...
for (final IMovableHandler han : this.handlers) {
if (han.canHandle(myClass, te)) {
handler = han;
break;
}
}
// if you have a handler your opted in
if (handler != null) {
this.Valid.put(myClass, handler);
return handler;
}
// if your movable our opted in
if (te instanceof IMovableTile) {
this.Valid.put(myClass, this.dsh);
return this.dsh;
}
// if you are on the white list your opted in.
for (final Class<? extends BlockEntity> testClass : this.test) {
if (testClass.isAssignableFrom(myClass)) {
this.Valid.put(myClass, this.dsh);
return this.dsh;
}
}
this.Valid.put(myClass, this.nullHandler);
return this.nullHandler;
}
@Override
public void doneMoving(final BlockEntity te) {
if (te instanceof IMovableTile) {
final IMovableTile mt = (IMovableTile) te;
mt.doneMoving();
}
}
@Override
public void addHandler(final IMovableHandler han) {
this.handlers.add(han);
}
@Override
public IMovableHandler getHandler(final BlockEntity te) {
final Class myClass = te.getClass();
final IMovableHandler h = this.Valid.get(myClass);
return h == null ? this.dsh : h;
}
@Override
public IMovableHandler getDefaultHandler() {
return this.dsh;
}
@Override
public boolean isBlacklisted(final Block blk) {
return this.blacklisted.contains(blk);
}
}
@@ -0,0 +1,262 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.Attribute;
import alexiil.mc.lib.attributes.fluid.FluidAttributes;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Identifier;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor;
import net.minecraft.util.registry.Registry;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
private static final int INITIAL_CAPACITY = 40;
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>(INITIAL_CAPACITY);
private final Map<String, TunnelType> modIdTunnels = new HashMap<>(INITIAL_CAPACITY);
private final Map<Attribute<?>, TunnelType> attrTunnels = new HashMap<>(INITIAL_CAPACITY);
public void configure() {
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
/*
* light!
*/
this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT);
this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT);
/*
* Forge energy tunnel items
*/
this.addNewAttunement(blocks.energyCellDense(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyAcceptor(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER);
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
*/
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 2 ), TunnelType.IC2_POWER ); // Gold cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
/**
* attune based on most redstone base items.
*/
this.addNewAttunement(new ItemStack(Items.REDSTONE), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Items.REPEATER), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_LAMP), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.COMPARATOR), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.DAYLIGHT_DETECTOR), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_WIRE), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_BLOCK), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.LEVER), TunnelType.REDSTONE);
/**
* attune based on lots of random item related stuff
*/
this.addNewAttunement(blocks.iface(), TunnelType.ITEM);
this.addNewAttunement(parts.iface(), TunnelType.ITEM);
this.addNewAttunement(parts.storageBus(), TunnelType.ITEM);
this.addNewAttunement(parts.importBus(), TunnelType.ITEM);
this.addNewAttunement(parts.exportBus(), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.HOPPER), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.CHEST), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.TRAPPED_CHEST), TunnelType.ITEM);
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 1 ), TunnelType.ITEM ); // itemduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 2 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// (opaque)
/**
* attune based on lots of random item related stuff
*/
this.addNewAttunement(new ItemStack(Items.BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID);
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 0 ), TunnelType.FLUID ); // fluiduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 1 ), TunnelType.FLUID ); // fluiduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 2 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 3 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME // (opaque)
// FIXME
for (final AEColor c : AEColor.values()) {
this.addNewAttunement(parts.cableGlass().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableCovered().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableSmart().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableDenseSmart().stack(c, 1), TunnelType.ME);
}
/**
* attune based caps
*/
// FIXME FABRIC this.addNewAttunement(Capabilities.FORGE_ENERGY, TunnelType.FE_POWER);
this.addNewAttunement(FluidAttributes.EXTRACTABLE, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.INSERTABLE, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.FIXED_INV, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.GROUPED_INV, TunnelType.FLUID);
/**
* attune based on the ItemStack's modId
*/
this.addNewAttunement("thermaldynamics", TunnelType.FE_POWER);
this.addNewAttunement("thermalexpansion", TunnelType.FE_POWER);
this.addNewAttunement("thermalfoundation", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will
// support FE.
this.addNewAttunement("enderio", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will
// support FE.
this.addNewAttunement("mekanism", TunnelType.FE_POWER);
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement("rftools", TunnelType.FE_POWER);
this.addNewAttunement("ic2", TunnelType.IC2_POWER);
}
@Override
public void addNewAttunement(@Nonnull final String modId, @Nullable final TunnelType type) {
if (type == null || modId == null) {
return;
}
this.modIdTunnels.put(modId, type);
}
@Override
public void addNewAttunement(@Nonnull final Attribute<?> attr, @Nullable final TunnelType type) {
if (type == null || attr == null) {
return;
}
this.attrTunnels.put(attr, type);
}
@Override
public void addNewAttunement(@Nonnull final ItemStack trigger, @Nullable final TunnelType type) {
if (type == null || trigger.isEmpty()) {
return;
}
this.tunnels.put(trigger, type);
}
@Nullable
@Override
public TunnelType getTunnelTypeByItem(final ItemStack trigger) {
if (!trigger.isEmpty()) {
// First match exact items
for (final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet()) {
final ItemStack is = entry.getKey();
if (is.getItem() == trigger.getItem()) {
return entry.getValue();
}
if (ItemStack.areItemsEqual(is, trigger)) {
return entry.getValue();
}
}
// Next, check if the Item you're holding supports any registered capability
for (Entry<Attribute<?>, TunnelType> entry : this.attrTunnels.entrySet()) {
if (entry.getKey().getFirstOrNull(trigger) != null) {
return entry.getValue();
}
}
// Use the mod id as last option.
Identifier itemId = Registry.ITEM.getId(trigger.getItem());
if (itemId == Registry.ITEM.getDefaultId()) {
return null; // Unregistered item
}
for (final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet()) {
if (itemId.getNamespace().equals(entry.getKey())) {
return entry.getValue();
}
}
}
return null;
}
@Nonnull
private ItemStack getModItem(final String modID, final String name) {
final Item item = Registry.ITEM.getOrEmpty(new Identifier(modID, name)).orElse(null);
if (item == null) {
return ItemStack.EMPTY;
}
return new ItemStack(item);
}
private void addNewAttunement(final IItemDefinition definition, final TunnelType type) {
definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type));
}
}
@@ -0,0 +1,51 @@
/*
* 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.core.features.registries;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.util.Identifier;
import appeng.api.parts.IPartModels;
public class PartModels implements IPartModels {
private final Set<Identifier> models = new HashSet<>();
private boolean initialized = false;
@Override
public void registerModels(Collection<Identifier> partModels) {
if (this.initialized) {
throw new IllegalStateException("Cannot register models after the pre-initialization phase!");
}
this.models.addAll(partModels);
}
public Set<Identifier> getModels() {
return this.models;
}
public void setInitialized(boolean initialized) {
this.initialized = initialized;
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import java.util.UUID;
import javax.annotation.Nullable;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import appeng.api.features.IPlayerRegistry;
import appeng.core.AppEng;
import appeng.core.worlddata.WorldData;
public class PlayerRegistry implements IPlayerRegistry {
@Override
public int getID(final GameProfile username) {
if (username == null || !username.isComplete()) {
return -1;
}
return WorldData.instance().playerData().getMePlayerId(username);
}
@Override
public int getID(final PlayerEntity player) {
return this.getID(player.getGameProfile());
}
@Nullable
@Override
public PlayerEntity findPlayer(final int playerID) {
UUID profileId = WorldData.instance().playerData().getProfileId(playerID);
if (profileId == null) {
return null;
}
for (final PlayerEntity player : AppEng.instance().getPlayers()) {
if (player.getGameProfile().getId().equals(profileId)) {
return player;
}
}
return null;
}
}
@@ -0,0 +1,112 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import appeng.api.features.IChargerRegistry;
import appeng.api.features.ILocatableRegistry;
import appeng.api.features.IMatterCannonAmmoRegistry;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.features.IPlayerRegistry;
import appeng.api.features.IRegistryContainer;
import appeng.api.features.IWirelessTermRegistry;
import appeng.api.features.IWorldGen;
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
import appeng.api.storage.ICellRegistry;
import appeng.core.features.registries.cell.CellRegistry;
import appeng.core.features.registries.charger.ChargerRegistry;
/**
* represents all registries
*
* @author AlgorithmX2
* @author thatsIch
* @author yueh
* @version rv5
* @since rv0
*/
public class RegistryContainer implements IRegistryContainer {
private final IChargerRegistry charger = new ChargerRegistry();
private final ICellRegistry cell = new CellRegistry();
private final ILocatableRegistry locatable = new LocatableRegistry();
private final IWirelessTermRegistry wireless = new WirelessRegistry();
private final IGridCacheRegistry gridCache = new GridCacheRegistry();
private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry();
private final IMovableRegistry movable = new MovableTileRegistry();
private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
private final IPlayerRegistry playerRegistry = new PlayerRegistry();
private final IPartModels partModels = new PartModels();
@Override
public IMovableRegistry movable() {
return this.movable;
}
@Override
public IGridCacheRegistry gridCache() {
return this.gridCache;
}
@Override
public IWirelessTermRegistry wireless() {
return this.wireless;
}
@Override
public ICellRegistry cell() {
return this.cell;
}
@Override
public IChargerRegistry charger() {
return this.charger;
}
@Override
public ILocatableRegistry locatable() {
return this.locatable;
}
@Override
public IP2PTunnelRegistry p2pTunnel() {
return this.p2pTunnel;
}
@Override
public IMatterCannonAmmoRegistry matterCannon() {
return this.matterCannonReg;
}
@Override
public IPlayerRegistry players() {
return this.playerRegistry;
}
@Override
public IWorldGen worldgen() {
return WorldGenRegistry.INSTANCE;
}
@Override
public IPartModels partModels() {
return this.partModels;
}
}
@@ -0,0 +1,103 @@
/*
* 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.core.features.registries;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.world.BlockView;
import appeng.api.AEApi;
import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
public final class WirelessRegistry implements IWirelessTermRegistry {
private final List<IWirelessTermHandler> handlers;
public WirelessRegistry() {
this.handlers = new ArrayList<>();
}
@Override
public void registerWirelessHandler(final IWirelessTermHandler handler) {
if (handler != null) {
this.handlers.add(handler);
}
}
@Override
public boolean isWirelessTerminal(final ItemStack is) {
for (final IWirelessTermHandler h : this.handlers) {
if (h.canHandle(is)) {
return true;
}
}
return false;
}
@Override
public IWirelessTermHandler getWirelessTerminalHandler(final ItemStack is) {
for (final IWirelessTermHandler h : this.handlers) {
if (h.canHandle(is)) {
return h;
}
}
return null;
}
@Override
public void openWirelessTerminalGui(ItemStack item, BlockView world, PlayerEntity player, Hand hand) {
if (Platform.isClient()) {
return;
}
if (!this.isWirelessTerminal(item)) {
player.sendSystemMessage(PlayerMessages.DeviceNotWirelessTerminal.get(), Util.NIL_UUID);
return;
}
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.sendSystemMessage(PlayerMessages.DeviceNotLinked.get(), Util.NIL_UUID);
return;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.sendSystemMessage(PlayerMessages.StationCanNotBeLocated.get(), Util.NIL_UUID);
return;
}
if (handler.hasPower(player, 0.5, item)) {
// FIXME FABRIC ContainerOpener.openContainer(WirelessTermContainer.TYPE, player, ContainerLocator.forHand(player, hand));
throw new IllegalStateException();
} else {
player.sendSystemMessage(PlayerMessages.DeviceNotPowered.get(), Util.NIL_UUID);
}
}
}
@@ -0,0 +1,88 @@
/*
* 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.core.features.registries;
import appeng.api.features.IWorldGen;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import java.util.HashSet;
public final class WorldGenRegistry implements IWorldGen {
public static final WorldGenRegistry INSTANCE = new WorldGenRegistry();
private final TypeSet[] types;
private WorldGenRegistry() {
this.types = new TypeSet[WorldGenType.values().length];
for (final WorldGenType type : WorldGenType.values()) {
this.types[type.ordinal()] = new TypeSet();
}
}
@Override
public void enableWorldGenForDimension(final WorldGenType type, final Identifier dimensionID) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
this.types[type.ordinal()].enabledDimensions.add(dimensionID);
}
@Override
public void disableWorldGenForDimension(final WorldGenType type, final Identifier dimensionID) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
this.types[type.ordinal()].badDimensions.add(dimensionID);
}
@Override
public boolean isWorldGenEnabled(final WorldGenType type, final ServerWorld w) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
if (w == null) {
throw new IllegalArgumentException("Bad Provider Passed");
}
Identifier id = w.getDimensionRegistryKey().getValue();
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains(id);
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains(id);
if (isBadDimension) {
return false;
}
if (!isGoodDimension && type == WorldGenType.METEORITES) {
return false;
}
return true;
}
private static class TypeSet {
final HashSet<Identifier> badDimensions = new HashSet<>();
final HashSet<Identifier> enabledDimensions = new HashSet<>();
}
}
@@ -0,0 +1,49 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.data.IAEStack;
import appeng.me.storage.BasicCellInventory;
import appeng.me.storage.BasicCellInventoryHandler;
public class BasicCellHandler implements ICellHandler {
@Override
public boolean isCell(final ItemStack is) {
return BasicCellInventory.isCell(is);
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
final ISaveProvider container, final IStorageChannel<T> channel) {
final ICellInventory<T> inv = BasicCellInventory.createInventory(is, container);
if (inv == null || inv.getChannel() != channel) {
return null;
}
return new BasicCellInventoryHandler<>(inv, channel);
}
}
@@ -0,0 +1,29 @@
package appeng.core.features.registries.cell;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellGuiHandler;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack;
public class BasicItemCellGuiHandler implements ICellGuiHandler {
@Override
public <T extends IAEStack<T>> boolean isHandlerFor(final IStorageChannel<T> channel) {
return channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
@Override
public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler,
final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) {
// FIXME FABRIC ContainerOpener.openContainer(MEMonitorableContainer.TYPE, player,
// FIXME FABRIC ContainerLocator.forTileEntitySide((BlockEntity) chest, chest.getUp()));
}
}
@@ -0,0 +1,121 @@
/*
* 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.core.features.registries.cell;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellGuiHandler;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.data.IAEStack;
public class CellRegistry implements ICellRegistry {
private final List<ICellHandler> handlers;
private final List<ICellGuiHandler> guiHandlers;
public CellRegistry() {
this.handlers = new ArrayList<>();
this.guiHandlers = new ArrayList<>();
}
@Override
public void addCellHandler(final ICellHandler handler) {
Preconditions.checkNotNull(handler, "Called before FMLCommonSetupEvent.");
Preconditions.checkArgument(!this.handlers.contains(handler),
"Tried to register the same handler instance twice.");
this.handlers.add(handler);
// Verify that the first entry is always our own handler.
Verify.verify(this.handlers.get(0) instanceof BasicCellHandler);
}
@Override
public boolean isCellHandled(final ItemStack is) {
if (is.isEmpty()) {
return false;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return true;
}
}
return false;
}
@Override
public ICellHandler getHandler(final ItemStack is) {
if (is.isEmpty()) {
return null;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return ch;
}
}
return null;
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
final ISaveProvider container, final IStorageChannel<T> chan) {
if (is.isEmpty()) {
return null;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return ch.getCellInventory(is, container, chan);
}
}
return null;
}
@Override
public void addCellGuiHandler(ICellGuiHandler handler) {
this.guiHandlers.add(handler);
}
@Override
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler(final IStorageChannel<T> channel, final ItemStack is) {
ICellGuiHandler fallBack = null;
for (final ICellGuiHandler ch : this.guiHandlers) {
if (ch.isHandlerFor(channel)) {
if (ch.isSpecializedFor(is)) {
return ch;
}
if (fallBack == null) {
fallBack = ch;
}
}
}
return fallBack;
}
}
@@ -0,0 +1,60 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.CellState;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.items.storage.CreativeStorageCellItem;
import appeng.me.storage.CreativeCellInventory;
public final class CreativeCellHandler implements ICellHandler {
@Override
public boolean isCell(final ItemStack is) {
return !is.isEmpty() && is.getItem() instanceof CreativeStorageCellItem;
}
@Override
public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
final IStorageChannel channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty()
&& is.getItem() instanceof CreativeStorageCellItem) {
return CreativeCellInventory.getCell(is);
}
return null;
}
@Override
public CellState getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) {
return CellState.TYPES_FULL;
}
@Override
public double cellIdleDrain(final ItemStack is, final ICellInventoryHandler handler) {
return 0;
}
}
@@ -0,0 +1,68 @@
/*
* 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.core.features.registries.charger;
import java.util.IdentityHashMap;
import java.util.Map;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import appeng.api.features.IChargerRegistry;
public class ChargerRegistry implements IChargerRegistry {
private static final double DEFAULT_CHARGE_RATE = 160d;
private static final double CAPPED_CHARGE_RATE = 16000d;
private final Map<Item, Double> chargeRates;
public ChargerRegistry() {
this.chargeRates = new IdentityHashMap<>();
}
@Override
@Nonnegative
public double getChargeRate(@Nonnull Item item) {
Preconditions.checkNotNull(item);
return this.chargeRates.getOrDefault(item, DEFAULT_CHARGE_RATE);
}
@Override
public void addChargeRate(@Nonnull Item item, @Nonnegative double value) {
Preconditions.checkNotNull(item);
Preconditions.checkArgument(value > 0d);
final double cappedValue = Math.min(value, CAPPED_CHARGE_RATE);
this.chargeRates.put(item, cappedValue);
}
@Override
public void removeChargeRate(@Nonnull Item item) {
Preconditions.checkNotNull(item);
this.chargeRates.remove(item);
}
}
@@ -0,0 +1,12 @@
package appeng.decorative.solid;
import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;
public class AEStairsBlock extends StairsBlock {
public AEStairsBlock(BlockState baseBlockState, Settings settings) {
super(baseBlockState, settings);
}
}
@@ -71,7 +71,7 @@ public class ChargedQuartzOreBlock extends QuartzOreBlock {
break;
}
if (AppEng.INSTANCE.shouldAddParticles(r)) {
if (AppEng.instance().shouldAddParticles(r)) {
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.CHARGED_ORE, pos.getX() + xOff,
pos.getY() + yOff, pos.getZ() + zOff, 0.0f, 0.0f, 0.0f);
}
@@ -43,7 +43,7 @@ public class QuartzLampBlock extends QuartzGlassBlock {
return;
}
if (AppEng.INSTANCE.shouldAddParticles(r)) {
if (AppEng.instance().shouldAddParticles(r)) {
final double d0 = (r.nextFloat() - 0.5F) * 0.96D;
final double d1 = (r.nextFloat() - 0.5F) * 0.96D;
final double d2 = (r.nextFloat() - 0.5F) * 0.96D;
@@ -0,0 +1,174 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.fluids.util;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
public final class FluidList implements IItemList<IAEFluidStack> {
private final Map<IAEFluidStack, IAEFluidStack> records = new HashMap<>();
@Override
public void add(final IAEFluidStack option) {
if (option == null) {
return;
}
final IAEFluidStack st = this.getFluidRecord(option);
if (st != null) {
st.add(option);
return;
}
final IAEFluidStack opt = option.copy();
this.putFluidRecord(opt);
}
@Override
public IAEFluidStack findPrecise(final IAEFluidStack fluidStack) {
if (fluidStack == null) {
return null;
}
return this.getFluidRecord(fluidStack);
}
@Override
public Collection<IAEFluidStack> findFuzzy(final IAEFluidStack filter, final FuzzyMode fuzzy) {
if (filter == null) {
return Collections.emptyList();
}
return Collections.singletonList(this.findPrecise(filter));
}
@Override
public boolean isEmpty() {
return !this.iterator().hasNext();
}
@Override
public void addStorage(final IAEFluidStack option) {
if (option == null) {
return;
}
final IAEFluidStack st = this.getFluidRecord(option);
if (st != null) {
st.incStackSize(option.getStackSize());
return;
}
final IAEFluidStack opt = option.copy();
this.putFluidRecord(opt);
}
/*
* public synchronized void clean() { Iterator<StackType> i = iterator(); while
* (i.hasNext()) { StackType AEI = i.next(); if ( !AEI.isMeaningful() )
* i.remove(); } }
*/
@Override
public void addCrafting(final IAEFluidStack option) {
if (option == null) {
return;
}
final IAEFluidStack st = this.getFluidRecord(option);
if (st != null) {
st.setCraftable(true);
return;
}
final IAEFluidStack opt = option.copy();
opt.setStackSize(0);
opt.setCraftable(true);
this.putFluidRecord(opt);
}
@Override
public void addRequestable(final IAEFluidStack option) {
if (option == null) {
return;
}
final IAEFluidStack st = this.getFluidRecord(option);
if (st != null) {
st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable());
return;
}
final IAEFluidStack opt = option.copy();
opt.setStackSize(0);
opt.setCraftable(false);
opt.setCountRequestable(option.getCountRequestable());
this.putFluidRecord(opt);
}
@Override
public IAEFluidStack getFirstItem() {
for (final IAEFluidStack stackType : this) {
return stackType;
}
return null;
}
@Override
public int size() {
return this.records.values().size();
}
@Override
public Iterator<IAEFluidStack> iterator() {
return new MeaningfulFluidIterator<>(this.records.values().iterator());
}
@Override
public void resetStatus() {
for (final IAEFluidStack i : this) {
i.reset();
}
}
private IAEFluidStack getFluidRecord(final IAEFluidStack fluid) {
return this.records.get(fluid);
}
private IAEFluidStack putFluidRecord(final IAEFluidStack fluid) {
return this.records.put(fluid, fluid);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.fluids.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
import appeng.api.storage.data.IAEStack;
public class MeaningfulFluidIterator<T extends IAEStack> implements Iterator<T> {
private final Iterator<T> parent;
private T next;
public MeaningfulFluidIterator(final Iterator<T> iterator) {
this.parent = iterator;
}
@Override
public boolean hasNext() {
while (this.parent.hasNext()) {
this.next = this.parent.next();
if (this.next.isMeaningful()) {
return true;
} else {
this.parent.remove(); // self cleaning :3
}
}
this.next = null;
return false;
}
@Override
public T next() {
if (this.next == null) {
throw new NoSuchElementException();
}
return this.next;
}
@Override
public void remove() {
this.parent.remove();
}
}
@@ -0,0 +1,9 @@
package appeng.hooks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
public interface AEToolItem {
ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context);
}
@@ -0,0 +1,45 @@
/*
* 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.hooks;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import appeng.entity.TinyTNTPrimedEntity;
public final class TinyTNTDispenseItemBehavior extends ItemDispenserBehavior {
@Override
protected ItemStack dispenseSilently(final BlockPointer dispenser, final ItemStack dispensedItem) {
final Direction Direction = dispenser.getBlockState().get(DispenserBlock.FACING);
final World world = dispenser.getWorld();
final int i = dispenser.getBlockPos().getX() + Direction.getOffsetX();
final int j = dispenser.getBlockPos().getY() + Direction.getOffsetY();
final int k = dispenser.getBlockPos().getZ() + Direction.getOffsetZ();
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(world, i + 0.5F, j + 0.5F, k + 0.5F,
null);
world.spawnEntity(primedTinyTNTEntity);
dispensedItem.setCount(dispensedItem.getCount() - 1);
return dispensedItem;
}
}
@@ -0,0 +1,40 @@
package appeng.hooks;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
/**
* This hooks allows item-specific behavior to be triggered when an item is used on a block,
* without shift being held or the block being called first.
*/
public class ToolItemHook {
public static void install() {
UseBlockCallback.EVENT.register(ToolItemHook::handleItemUse);
}
private static ActionResult handleItemUse(PlayerEntity playerEntity, World world, Hand hand, BlockHitResult blockHitResult) {
if (playerEntity.isSpectator()) {
return ActionResult.PASS;
}
ItemStack itemStack = playerEntity.getStackInHand(hand);
Item item = itemStack.getItem();
if (item instanceof AEToolItem) {
ItemUsageContext context = new ItemUsageContext(playerEntity, hand, blockHitResult);
AEToolItem toolItem = (AEToolItem) item;
return toolItem.onItemUseFirst(itemStack, context);
}
return ActionResult.PASS;
}
}
@@ -0,0 +1,40 @@
/*
* 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.items.contents;
import alexiil.mc.lib.attributes.item.FixedItemInvView;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
public class CellConfig extends AppEngInternalInventory {
private final ItemStack is;
public CellConfig(final ItemStack is) {
super(null, 63);
this.is = is;
this.readFromNBT(is.getOrCreateTag(), "list");
}
@Override
protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) {
this.writeToNBT(this.is.getOrCreateTag(), "list");
}
}
@@ -0,0 +1,260 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.materials;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import appeng.hooks.AEToolItem;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
import appeng.items.AEBaseItem;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.AdaptorFixedInv;
public final class MaterialItem extends AEBaseItem implements IStorageComponent, IUpgradeModule, AEToolItem {
/**
* NBT property used by the name press to store the name to be inscribed.
*/
public static final String TAG_INSCRIBE_NAME = "InscribeName";
private static final int KILO_SCALAR = 1024;
private final MaterialType materialType;
public MaterialItem(Settings properties, MaterialType materialType) {
super(properties);
this.materialType = materialType;
}
@Environment(EnvType.CLIENT)
@Override
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
final TooltipContext advancedTooltips) {
super.appendTooltip(stack, world, lines, advancedTooltips);
if (materialType == MaterialType.NAME_PRESS) {
final CompoundTag c = stack.getOrCreateTag();
if (c.contains(TAG_INSCRIBE_NAME)) {
lines.add(new LiteralText(c.getString(TAG_INSCRIBE_NAME)));
}
}
final Upgrades u = this.getType(stack);
if (u != null) {
final List<Text> textList = new ArrayList<>();
for (final Entry<ItemStack, Integer> j : u.getSupported().entrySet()) {
Text name = null;
final int limit = j.getValue();
if (j.getKey().getItem() instanceof IItemGroup) {
final IItemGroup ig = (IItemGroup) j.getKey().getItem();
final String str = ig.getUnlocalizedGroupName(u.getSupported().keySet(), j.getKey());
if (str != null) {
name = new TranslatableText(str).append(limit > 1 ? " (" + limit + ')' : "");
}
}
if (name == null) {
name = j.getKey().getName().copy().append((limit > 1 ? " (" + limit + ')' : ""));
}
if (!textList.contains(name)) {
textList.add(name);
}
}
final Pattern p = Pattern.compile("(\\d+)[^\\d]");
// FIXME This comparison is not great...
final SlightlyBetterSort s = new SlightlyBetterSort(p);
textList.sort(s);
lines.addAll(textList);
}
}
@Override
public Upgrades getType(final ItemStack itemstack) {
switch (materialType) {
case CARD_CAPACITY:
return Upgrades.CAPACITY;
case CARD_FUZZY:
return Upgrades.FUZZY;
case CARD_REDSTONE:
return Upgrades.REDSTONE;
case CARD_SPEED:
return Upgrades.SPEED;
case CARD_INVERTER:
return Upgrades.INVERTER;
case CARD_CRAFTING:
return Upgrades.CRAFTING;
default:
return null;
}
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
return super.use(world, user, hand);
}
@Override
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
PlayerEntity player = context.getPlayer();
Hand hand = context.getHand();
if (player.isInSneakingPose()) {
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
FixedItemInv upgrades = null;
if (te instanceof IPartHost) {
final SelectedPart sp = ((IPartHost) te).selectPart(context.getHitPos());
if (sp.part instanceof IUpgradeableHost) {
upgrades = ((ISegmentedInventory) sp.part).getInventoryByName("upgrades");
}
} else if (te instanceof IUpgradeableHost) {
upgrades = ((ISegmentedInventory) te).getInventoryByName("upgrades");
}
if (upgrades != null && !player.getStackInHand(hand).isEmpty()
&& player.getStackInHand(hand).getItem() instanceof IUpgradeModule) {
final IUpgradeModule um = (IUpgradeModule) player.getStackInHand(hand).getItem();
final Upgrades u = um.getType(player.getStackInHand(hand));
if (u != null) {
if (player.world.isClient) {
return ActionResult.PASS;
}
final InventoryAdaptor ad = new AdaptorFixedInv(upgrades);
player.setStackInHand(hand, ad.addItems(player.getStackInHand(hand)));
return ActionResult.SUCCESS;
}
}
}
return ActionResult.PASS;
}
// FIXME FABRIC @Override
// FIXME FABRIC public boolean hasCustomEntity(final ItemStack is) {
// FIXME FABRIC return materialType.hasCustomEntity();
// FIXME FABRIC }
// FIXME FABRIC @Override
// FIXME FABRIC public Entity createEntity(final World w, final Entity location, final ItemStack itemstack) {
// FIXME FABRIC final Class<? extends Entity> droppedEntity = materialType.getCustomEntityClass();
// FIXME FABRIC final Entity eqi;
// FIXME FABRIC try {
// FIXME FABRIC eqi = droppedEntity.getConstructor(World.class, double.class, double.class, double.class, ItemStack.class)
// FIXME FABRIC .newInstance(w, location.getX(), location.getY(), location.getZ(), itemstack);
// FIXME FABRIC } catch (final Throwable t) {
// FIXME FABRIC throw new IllegalStateException(t);
// FIXME FABRIC }
// FIXME FABRIC eqi.setVelocity(location.getVelocity());
// FIXME FABRIC if (location instanceof ItemEntity && eqi instanceof ItemEntity) {
// FIXME FABRIC ((ItemEntity) eqi).setDefaultPickupDelay();
// FIXME FABRIC }
// FIXME FABRIC return eqi;
// FIXME FABRIC }
@Override
public int getBytes(final ItemStack is) {
switch (materialType) {
case ITEM_1K_CELL_COMPONENT:
return KILO_SCALAR;
case ITEM_4K_CELL_COMPONENT:
return KILO_SCALAR * 4;
case ITEM_16K_CELL_COMPONENT:
return KILO_SCALAR * 16;
case ITEM_64K_CELL_COMPONENT:
return KILO_SCALAR * 64;
default:
}
return 0;
}
@Override
public boolean isStorageComponent(final ItemStack is) {
switch (materialType) {
case ITEM_1K_CELL_COMPONENT:
case ITEM_4K_CELL_COMPONENT:
case ITEM_16K_CELL_COMPONENT:
case ITEM_64K_CELL_COMPONENT:
return true;
default:
}
return false;
}
private static class SlightlyBetterSort implements Comparator<Text> {
private final Pattern pattern;
public SlightlyBetterSort(final Pattern pattern) {
this.pattern = pattern;
}
@Override
public int compare(final Text o1, final Text o2) {
try {
final Matcher a = this.pattern.matcher(o1.getString());
final Matcher b = this.pattern.matcher(o2.getString());
if (a.find() && b.find()) {
final int ia = Integer.parseInt(a.group(1));
final int ib = Integer.parseInt(b.group(1));
return Integer.compare(ia, ib);
}
} catch (final Throwable t) {
// ek!
}
return o1.getString().compareTo(o2.getString());
}
}
}
@@ -0,0 +1,88 @@
/*
* 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.items.storage;
import java.util.List;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
public class CreativeStorageCellItem extends AEBaseItem implements ICellWorkbenchItem {
public CreativeStorageCellItem(Settings props) {
super(props);
}
@Override
public boolean isEditable(final ItemStack is) {
return true;
}
@Override
public FixedItemInv getUpgradesInventory(final ItemStack is) {
return null;
}
@Override
public FixedItemInv getConfigInventory(final ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(final ItemStack is) {
return FuzzyMode.IGNORE_ALL;
}
@Override
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
}
@Environment(EnvType.CLIENT)
@Override
public void appendTooltip(final ItemStack stack, final World world, final List<Text> lines,
final TooltipContext advancedTooltips) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory(stack, null,
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
if (inventory instanceof ICellInventoryHandler) {
final CellConfig cc = new CellConfig(stack);
for (final ItemStack is : cc) {
if (!is.isEmpty()) {
lines.add(is.getName());
}
}
}
}
}
@@ -0,0 +1,306 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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.me.storage;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import appeng.api.config.FuzzyMode;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.cells.CellState;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
/**
* @author DrummerMC
* @version rv6 - 2018-01-17
* @since rv6 2018-01-17
*/
public abstract class AbstractCellInventory<T extends IAEStack<T>> implements ICellInventory<T> {
private static final int MAX_ITEM_TYPES = 63;
private static final String ITEM_TYPE_TAG = "it";
private static final String ITEM_COUNT_TAG = "ic";
private static final String ITEM_SLOT = "#";
private static final String ITEM_SLOT_COUNT = "@";
protected static final String ITEM_PRE_FORMATTED_COUNT = "PF";
protected static final String ITEM_PRE_FORMATTED_SLOT = "PF#";
protected static final String ITEM_PRE_FORMATTED_NAME = "PN";
protected static final String ITEM_PRE_FORMATTED_FUZZY = "FP";
private static final String[] ITEM_SLOT_KEYS = new String[MAX_ITEM_TYPES];
private static final String[] ITEM_SLOT_COUNT_KEYS = new String[MAX_ITEM_TYPES];
private final CompoundTag tagCompound;
protected final ISaveProvider container;
private int maxItemTypes = MAX_ITEM_TYPES;
private short storedItems = 0;
private int storedItemCount = 0;
protected IItemList<T> cellItems;
private final ItemStack i;
protected final IStorageCell<T> cellType;
protected final int itemsPerByte;
private boolean isPersisted = true;
static {
for (int x = 0; x < MAX_ITEM_TYPES; x++) {
ITEM_SLOT_KEYS[x] = ITEM_SLOT + x;
ITEM_SLOT_COUNT_KEYS[x] = ITEM_SLOT_COUNT + x;
}
}
protected AbstractCellInventory(final IStorageCell<T> cellType, final ItemStack o, final ISaveProvider container) {
this.i = o;
this.cellType = cellType;
this.itemsPerByte = this.cellType.getChannel().getUnitsPerByte();
this.maxItemTypes = this.cellType.getTotalTypes(this.i);
if (this.maxItemTypes > MAX_ITEM_TYPES) {
this.maxItemTypes = MAX_ITEM_TYPES;
}
if (this.maxItemTypes < 1) {
this.maxItemTypes = 1;
}
this.container = container;
this.tagCompound = o.getOrCreateTag();
this.storedItems = this.tagCompound.getShort(ITEM_TYPE_TAG);
this.storedItemCount = this.tagCompound.getInt(ITEM_COUNT_TAG);
this.cellItems = null;
}
protected IItemList<T> getCellItems() {
if (this.cellItems == null) {
this.cellItems = this.getChannel().createList();
this.loadCellItems();
}
return this.cellItems;
}
@Override
public void persist() {
if (this.isPersisted) {
return;
}
int itemCount = 0;
// add new pretty stuff...
int x = 0;
for (final T v : this.cellItems) {
itemCount += v.getStackSize();
final CompoundTag g = new CompoundTag();
v.writeToNBT(g);
this.tagCompound.put(ITEM_SLOT_KEYS[x], g);
this.tagCompound.putInt(ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize());
x++;
}
final short oldStoredItems = this.storedItems;
this.storedItems = (short) this.cellItems.size();
if (this.cellItems.isEmpty()) {
this.tagCompound.remove(ITEM_TYPE_TAG);
} else {
this.tagCompound.putShort(ITEM_TYPE_TAG, this.storedItems);
}
this.storedItemCount = itemCount;
if (itemCount == 0) {
this.tagCompound.remove(ITEM_COUNT_TAG);
} else {
this.tagCompound.putInt(ITEM_COUNT_TAG, itemCount);
}
// clean any old crusty stuff...
for (; x < oldStoredItems && x < this.maxItemTypes; x++) {
this.tagCompound.remove(ITEM_SLOT_KEYS[x]);
this.tagCompound.remove(ITEM_SLOT_COUNT_KEYS[x]);
}
this.isPersisted = true;
}
protected void saveChanges() {
// recalculate values
this.storedItems = (short) this.cellItems.size();
this.storedItemCount = 0;
for (final T v : this.cellItems) {
this.storedItemCount += v.getStackSize();
}
this.isPersisted = false;
if (this.container != null) {
this.container.saveChanges(this);
} else {
// if there is no ISaveProvider, store to NBT immediately
this.persist();
}
}
private void loadCellItems() {
if (this.cellItems == null) {
this.cellItems = this.getChannel().createList();
}
this.cellItems.resetStatus(); // clears totals and stuff.
final int types = (int) this.getStoredItemTypes();
boolean needsUpdate = false;
for (int slot = 0; slot < types; slot++) {
CompoundTag compoundTag = this.tagCompound.getCompound(ITEM_SLOT_KEYS[slot]);
int stackSize = this.tagCompound.getInt(ITEM_SLOT_COUNT_KEYS[slot]);
needsUpdate |= !this.loadCellItem(compoundTag, stackSize);
}
if (needsUpdate) {
this.saveChanges();
}
}
/**
* Load a single item.
*
* @param compoundTag
* @param stackSize
* @return true when successfully loaded
*/
protected abstract boolean loadCellItem(CompoundTag compoundTag, int stackSize);
@Override
public IItemList<T> getAvailableItems(final IItemList<T> out) {
for (final T item : this.getCellItems()) {
out.add(item);
}
return out;
}
@Override
public ItemStack getItemStack() {
return this.i;
}
@Override
public double getIdleDrain() {
return this.cellType.getIdleDrain();
}
@Override
public FuzzyMode getFuzzyMode() {
return this.cellType.getFuzzyMode(this.i);
}
@Override
public FixedItemInv getConfigInventory() {
return this.cellType.getConfigInventory(this.i);
}
@Override
public FixedItemInv getUpgradesInventory() {
return this.cellType.getUpgradesInventory(this.i);
}
@Override
public int getBytesPerType() {
return this.cellType.getBytesPerType(this.i);
}
@Override
public boolean canHoldNewItem() {
final long bytesFree = this.getFreeBytes();
return (bytesFree > this.getBytesPerType()
|| (bytesFree == this.getBytesPerType() && this.getUnusedItemCount() > 0))
&& this.getRemainingItemTypes() > 0;
}
@Override
public long getTotalBytes() {
return this.cellType.getBytes(this.i);
}
@Override
public long getFreeBytes() {
return this.getTotalBytes() - this.getUsedBytes();
}
@Override
public long getTotalItemTypes() {
return this.maxItemTypes;
}
@Override
public long getStoredItemCount() {
return this.storedItemCount;
}
@Override
public long getStoredItemTypes() {
return this.storedItems;
}
@Override
public long getRemainingItemTypes() {
final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
final long baseOnTotal = this.getTotalItemTypes() - this.getStoredItemTypes();
return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage;
}
@Override
public long getUsedBytes() {
final long bytesForItemCount = (this.getStoredItemCount() + this.getUnusedItemCount()) / this.itemsPerByte;
return this.getStoredItemTypes() * this.getBytesPerType() + bytesForItemCount;
}
@Override
public long getRemainingItemCount() {
final long remaining = this.getFreeBytes() * this.itemsPerByte + this.getUnusedItemCount();
return remaining > 0 ? remaining : 0;
}
@Override
public int getUnusedItemCount() {
final int div = (int) (this.getStoredItemCount() % 8);
if (div == 0) {
return 0;
}
return this.itemsPerByte - div;
}
@Override
public CellState getStatusForCell() {
if (this.getStoredItemTypes() == 0) {
return CellState.EMPTY;
}
if (this.canHoldNewItem()) {
return CellState.NOT_EMPTY;
}
if (this.getRemainingItemCount() > 0) {
return CellState.TYPES_FULL;
}
return CellState.FULL;
}
}
@@ -0,0 +1,238 @@
package appeng.me.storage;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.util.item.AEStack;
public class BasicCellInventory<T extends IAEStack<T>> extends AbstractCellInventory<T> {
private final IStorageChannel<T> channel;
private BasicCellInventory(final IStorageCell<T> cellType, final ItemStack o, final ISaveProvider container) {
super(cellType, o, container);
this.channel = cellType.getChannel();
}
public static <T extends IAEStack<T>> ICellInventory<T> createInventory(final ItemStack o,
final ISaveProvider container) {
try {
if (o == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
final Item type = o.getItem();
final IStorageCell<T> cellType;
if (type instanceof IStorageCell) {
cellType = (IStorageCell<T>) type;
} else {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
if (!cellType.isStorageCell(o)) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
return new BasicCellInventory<T>(cellType, o, container);
} catch (final AppEngException e) {
AELog.error(e);
return null;
}
}
public static <T extends AEStack<T>> boolean isCellOfType(final ItemStack input, IStorageChannel<?> channel) {
final IStorageCell<?> type = getStorageCell(input);
return type != null && type.getChannel() == channel;
}
public static boolean isCell(final ItemStack input) {
return getStorageCell(input) != null;
}
private boolean isStorageCell(final T input) {
if (input instanceof IAEItemStack) {
final IAEItemStack stack = (IAEItemStack) input;
final IStorageCell<?> type = getStorageCell(stack.getDefinition());
return type != null && !type.storableInStorageCell();
}
return false;
}
private static IStorageCell<?> getStorageCell(final ItemStack input) {
if (input != null) {
final Item type = input.getItem();
if (type instanceof IStorageCell) {
return (IStorageCell<?>) type;
}
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private static boolean isCellEmpty(ICellInventory inv) {
if (inv != null) {
return inv.getAvailableItems(inv.getChannel().createList()).isEmpty();
}
return true;
}
@Override
public T injectItems(T input, Actionable mode, IActionSource src) {
if (input == null) {
return null;
}
if (input.getStackSize() == 0) {
return null;
}
if (this.cellType.isBlackListed(this.getItemStack(), input)) {
return input;
}
// This is slightly hacky as it expects a read-only access, but fine for now.
// TODO: Guarantee a read-only access. E.g. provide an isEmpty() method and
// ensure CellInventory does not write
// any NBT data for empty cells instead of relying on an empty IItemContainer
if (this.isStorageCell(input)) {
final ICellInventory<?> meInventory = createInventory(((IAEItemStack) input).createItemStack(), null);
if (!isCellEmpty(meInventory)) {
return input;
}
}
final T l = this.getCellItems().findPrecise(input);
if (l != null) {
final long remainingItemCount = this.getRemainingItemCount();
if (remainingItemCount <= 0) {
return input;
}
if (input.getStackSize() > remainingItemCount) {
final T r = input.copy();
r.setStackSize(r.getStackSize() - remainingItemCount);
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() + remainingItemCount);
this.saveChanges();
}
return r;
} else {
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() + input.getStackSize());
this.saveChanges();
}
return null;
}
}
if (this.canHoldNewItem()) // room for new type, and for at least one item!
{
final int remainingItemCount = (int) this.getRemainingItemCount()
- this.getBytesPerType() * this.itemsPerByte;
if (remainingItemCount > 0) {
if (input.getStackSize() > remainingItemCount) {
final T toReturn = input.copy();
toReturn.setStackSize(input.getStackSize() - remainingItemCount);
if (mode == Actionable.MODULATE) {
final T toWrite = input.copy();
toWrite.setStackSize(remainingItemCount);
this.cellItems.add(toWrite);
this.saveChanges();
}
return toReturn;
}
if (mode == Actionable.MODULATE) {
this.cellItems.add(input);
this.saveChanges();
}
return null;
}
}
return input;
}
@Override
public T extractItems(T request, Actionable mode, IActionSource src) {
if (request == null) {
return null;
}
final long size = Math.min(Integer.MAX_VALUE, request.getStackSize());
T Results = null;
final T l = this.getCellItems().findPrecise(request);
if (l != null) {
Results = l.copy();
if (l.getStackSize() <= size) {
Results.setStackSize(l.getStackSize());
if (mode == Actionable.MODULATE) {
l.setStackSize(0);
this.saveChanges();
}
} else {
Results.setStackSize(size);
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() - size);
this.saveChanges();
}
}
}
return Results;
}
@Override
public IStorageChannel<T> getChannel() {
return this.channel;
}
@Override
protected boolean loadCellItem(CompoundTag compoundTag, int stackSize) {
// Now load the item stack
final T t;
try {
t = this.getChannel().createFromNBT(compoundTag);
if (t == null) {
AELog.warn("Removing item " + compoundTag
+ " from storage cell because the associated item type couldn't be found.");
return false;
}
} catch (Throwable ex) {
if (AEConfig.instance().isRemoveCrashingItemsOnLoad()) {
AELog.warn(ex,
"Removing item " + compoundTag + " from storage cell because loading the ItemStack crashed.");
return false;
}
throw ex;
}
t.setStackSize(stackSize);
if (stackSize > 0) {
this.cellItems.add(t);
}
return true;
}
}
@@ -0,0 +1,128 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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.me.storage;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
/**
* @author DrummerMC
* @version rv6 - 2018-01-23
* @since rv6 2018-01-23
*/
public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventoryHandler<T>
implements ICellInventoryHandler<T> {
public BasicCellInventoryHandler(final IMEInventory c, final IStorageChannel<T> channel) {
super(c, channel);
final ICellInventory ci = this.getCellInv();
if (ci != null) {
final IItemList<T> priorityList = channel.createList();
final FixedItemInv upgrades = ci.getUpgradesInventory();
final FixedItemInv config = ci.getConfigInventory();
final FuzzyMode fzMode = ci.getFuzzyMode();
boolean hasInverter = false;
boolean hasFuzzy = false;
for (int x = 0; x < upgrades.getSlotCount(); x++) {
final ItemStack is = upgrades.getInvStack(x);
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
if (u != null) {
switch (u) {
case FUZZY:
hasFuzzy = true;
break;
case INVERTER:
hasInverter = true;
break;
default:
}
}
}
}
for (int x = 0; x < config.getSlotCount(); x++) {
final ItemStack is = config.getInvStack(x);
if (!is.isEmpty()) {
final T configItem = channel.createStack(is);
if (configItem != null) {
priorityList.add(configItem);
}
}
}
this.setWhitelist(hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
if (!priorityList.isEmpty()) {
if (hasFuzzy) {
this.setPartitionList(new FuzzyPriorityList<>(priorityList, fzMode));
} else {
this.setPartitionList(new PrecisePriorityList<>(priorityList));
}
}
}
}
@Override
public ICellInventory getCellInv() {
Object o = this.getInternal();
if (o instanceof MEPassThrough) {
o = ((MEPassThrough) o).getInternal();
}
return (ICellInventory) (o instanceof ICellInventory ? o : null);
}
@Override
public boolean isPreformatted() {
return !this.getPartitionList().isEmpty();
}
@Override
public boolean isFuzzy() {
return this.getPartitionList() instanceof FuzzyPriorityList;
}
@Override
public IncludeExclude getIncludeExcludeMode() {
return this.getWhitelist();
}
CompoundTag openNbtData() {
return this.getCellInv().getItemStack().getOrCreateTag();
}
}
@@ -0,0 +1,119 @@
/*
* 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.me.storage;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.items.contents.CellConfig;
import appeng.util.item.AEItemStack;
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack> {
private final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
protected CreativeCellInventory(final ItemStack o) {
final CellConfig cc = new CellConfig(o);
for (final ItemStack is : cc) {
if (!is.isEmpty()) {
final IAEItemStack i = AEItemStack.fromItemStack(is);
i.setStackSize(Integer.MAX_VALUE);
this.itemListCache.add(i);
}
}
}
public static ICellInventoryHandler getCell(final ItemStack o) {
return new BasicCellInventoryHandler(new CreativeCellInventory(o),
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
}
@Override
public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final IActionSource src) {
final IAEItemStack local = this.itemListCache.findPrecise(input);
if (local == null) {
return input;
}
return null;
}
@Override
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final IActionSource src) {
final IAEItemStack local = this.itemListCache.findPrecise(request);
if (local == null) {
return null;
}
return request.copy();
}
@Override
public IItemList<IAEItemStack> getAvailableItems(final IItemList out) {
for (final IAEItemStack ais : this.itemListCache) {
out.add(ais);
}
return out;
}
@Override
public IStorageChannel getChannel() {
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
@Override
public AccessRestriction getAccess() {
return AccessRestriction.READ_WRITE;
}
@Override
public boolean isPrioritized(final IAEItemStack input) {
return this.itemListCache.findPrecise(input) != null;
}
@Override
public boolean canAccept(final IAEItemStack input) {
return this.itemListCache.findPrecise(input) != null;
}
@Override
public int getPriority() {
return 0;
}
@Override
public int getSlot() {
return 0;
}
@Override
public boolean validForPass(final int i) {
return true;
}
}
@@ -0,0 +1,167 @@
/*
* 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.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.IncludeExclude;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.util.prioritylist.DefaultPriorityList;
import appeng.util.prioritylist.IPartitionList;
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T> {
private final IMEInventoryHandler<T> internal;
private int myPriority;
private IncludeExclude myWhitelist;
private AccessRestriction myAccess;
private IPartitionList<T> myPartitionList;
private AccessRestriction cachedAccessRestriction;
private boolean hasReadAccess;
private boolean hasWriteAccess;
public MEInventoryHandler(final IMEInventory<T> i, final IStorageChannel<T> channel) {
if (i instanceof IMEInventoryHandler) {
this.internal = (IMEInventoryHandler<T>) i;
} else {
this.internal = new MEPassThrough<>(i, channel);
}
this.myPriority = 0;
this.myWhitelist = IncludeExclude.WHITELIST;
this.setBaseAccess(AccessRestriction.READ_WRITE);
this.myPartitionList = new DefaultPriorityList<>();
}
IncludeExclude getWhitelist() {
return this.myWhitelist;
}
public void setWhitelist(final IncludeExclude myWhitelist) {
this.myWhitelist = myWhitelist;
}
public AccessRestriction getBaseAccess() {
return this.myAccess;
}
public void setBaseAccess(final AccessRestriction myAccess) {
this.myAccess = myAccess;
this.cachedAccessRestriction = this.myAccess.restrictPermissions(this.internal.getAccess());
this.hasReadAccess = this.cachedAccessRestriction.hasPermission(AccessRestriction.READ);
this.hasWriteAccess = this.cachedAccessRestriction.hasPermission(AccessRestriction.WRITE);
}
IPartitionList<T> getPartitionList() {
return this.myPartitionList;
}
public void setPartitionList(final IPartitionList<T> myPartitionList) {
this.myPartitionList = myPartitionList;
}
@Override
public T injectItems(final T input, final Actionable type, final IActionSource src) {
if (!this.canAccept(input)) {
return input;
}
return this.internal.injectItems(input, type, src);
}
@Override
public T extractItems(final T request, final Actionable type, final IActionSource src) {
if (!this.hasReadAccess) {
return null;
}
return this.internal.extractItems(request, type, src);
}
@Override
public IItemList<T> getAvailableItems(final IItemList<T> out) {
if (!this.hasReadAccess) {
return out;
}
return this.internal.getAvailableItems(out);
}
@Override
public IStorageChannel<T> getChannel() {
return this.internal.getChannel();
}
@Override
public AccessRestriction getAccess() {
return this.cachedAccessRestriction;
}
@Override
public boolean isPrioritized(final T input) {
if (this.myWhitelist == IncludeExclude.WHITELIST) {
return this.myPartitionList.isListed(input) || this.internal.isPrioritized(input);
}
return false;
}
@Override
public boolean canAccept(final T input) {
if (!this.hasWriteAccess) {
return false;
}
if (this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed(input)) {
return false;
}
if (this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST) {
return this.internal.canAccept(input);
}
return this.myPartitionList.isListed(input) && this.internal.canAccept(input);
}
@Override
public int getPriority() {
return this.myPriority;
}
public void setPriority(final int myPriority) {
this.myPriority = myPriority;
}
@Override
public int getSlot() {
return this.internal.getSlot();
}
@Override
public boolean validForPass(final int i) {
return true;
}
public IMEInventory<T> getInternal() {
return this.internal;
}
}
@@ -0,0 +1,101 @@
/*
* 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.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler<T> {
private final IStorageChannel wrappedChannel;
private IMEInventory<T> internal;
public MEPassThrough(final IMEInventory<T> i, final IStorageChannel channel) {
this.wrappedChannel = channel;
this.setInternal(i);
}
protected IMEInventory<T> getInternal() {
return this.internal;
}
public void setInternal(final IMEInventory<T> i) {
this.internal = i;
}
@Override
public T injectItems(final T input, final Actionable type, final IActionSource src) {
return this.internal.injectItems(input, type, src);
}
@Override
public T extractItems(final T request, final Actionable type, final IActionSource src) {
return this.internal.extractItems(request, type, src);
}
@Override
public IItemList<T> getAvailableItems(final IItemList out) {
return this.internal.getAvailableItems(out);
}
@Override
public IStorageChannel getChannel() {
return this.internal.getChannel();
}
@Override
public AccessRestriction getAccess() {
return AccessRestriction.READ_WRITE;
}
@Override
public boolean isPrioritized(final T input) {
return false;
}
@Override
public boolean canAccept(final T input) {
return true;
}
@Override
public int getPriority() {
return 0;
}
@Override
public int getSlot() {
return 0;
}
@Override
public boolean validForPass(final int i) {
return true;
}
IStorageChannel getWrappedChannel() {
return this.wrappedChannel;
}
}
@@ -0,0 +1,16 @@
package appeng.mixins;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.advancement.criterion.Criterion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Criteria.class)
public interface CriteriaRegisterMixin {
@Invoker("register")
static <T extends Criterion<?>> T callRegister(T object) {
throw new AssertionError("Mixin dummy");
}
}
@@ -0,0 +1,58 @@
/*
* 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.spatial;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import appeng.api.movable.IMovableHandler;
public class DefaultSpatialHandler implements IMovableHandler {
/**
* never called for the default.
*
* @param tile block entity
*
* @return true
*/
@Override
public boolean canHandle(final Class<? extends BlockEntity> myClass, final BlockEntity tile) {
return true;
}
@Override
public void moveTile(final BlockEntity te, final World w, final BlockPos newPosition) {
te.setLocation(w, newPosition);
final Chunk c = w.getChunk(newPosition);
c.setBlockEntity(newPosition, te);
ChunkPos chunkPos = c.getPos();
if (w.getChunkManager().isChunkLoaded(chunkPos.x, chunkPos.z)) {
final BlockState state = w.getBlockState(newPosition);
w.addBlockEntity(te);
w.updateListeners(newPosition, state, state, 1);
}
}
}
@@ -35,7 +35,6 @@ import appeng.helpers.IPriorityHost;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import com.sun.org.apache.bcel.internal.classfile.AttributeReader;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
@@ -3,7 +3,9 @@
"minVersion": "0.8",
"package": "appeng.mixins",
"compatibilityLevel": "JAVA_8",
"mixins": [],
"mixins": [
"CriteriaRegisterMixin"
],
"client": [
"ModelsReloadMixin"
],
+3
View File
@@ -19,6 +19,9 @@
"environment": "*",
"entrypoints": {
"main": [
],
"client": [
"appeng.core.AppEngClientStartup"
]
},
"mixins": [