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
@@ -1,202 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.proxy.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);
}
}
@@ -1,37 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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);
}
}
@@ -1,145 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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);
}
}
}
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -35,16 +35,16 @@ import appeng.tile.misc.PaintSplotchesBlockEntity;
*/
class PaintSplotchesBakedModel implements IDynamicBakedModel {
private static final Material TEXTURE_PAINT1 = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_PAINT1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/paint1"));
private static final Material TEXTURE_PAINT2 = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_PAINT2 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/paint2"));
private static final Material TEXTURE_PAINT3 = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_PAINT3 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/paint3"));
private final Sprite[] textures;
PaintSplotchesBakedModel(Function<Material, Sprite> bakedTextureGetter) {
PaintSplotchesBakedModel(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
this.textures = new Sprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) };
}
@@ -171,7 +171,7 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
return false;
}
static List<Material> getRequiredTextures() {
static List<SpriteIdentifier> getRequiredTextures() {
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
}
}
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -22,14 +22,14 @@ public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel>
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
return new PaintSplotchesBakedModel(spriteGetter);
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return PaintSplotchesBakedModel.getRequiredTextures();
}
@@ -17,7 +17,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -32,17 +32,17 @@ import appeng.tile.qnb.QuantumBridgeBlockEntity;
class QnbFormedBakedModel implements IDynamicBakedModel {
private static final Material TEXTURE_LINK = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_LINK = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/quantum_link"));
private static final Material TEXTURE_RING = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_RING = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/quantum_ring"));
private static final Material TEXTURE_RING_LIGHT = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_RING_LIGHT = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/quantum_ring_light"));
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_RING_LIGHT_CORNER = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/quantum_ring_light_corner"));
private static final Material TEXTURE_CABLE_GLASS = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_CABLE_GLASS = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "parts/cable/glass/transparent"));
private static final Material TEXTURE_COVERED_CABLE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_COVERED_CABLE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "parts/cable/covered/transparent"));
private static final float DEFAULT_RENDER_MIN = 2.0f;
@@ -65,7 +65,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
private final Sprite lightTexture;
private final Sprite lightCornerTexture;
public QnbFormedBakedModel(BakedModel baseModel, Function<Material, Sprite> bakedTextureGetter) {
public QnbFormedBakedModel(BakedModel baseModel, Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
this.baseModel = baseModel;
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
@@ -220,7 +220,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
return this.baseModel.getOverrides();
}
public static List<Material> getRequiredTextures() {
public static List<SpriteIdentifier> getRequiredTextures() {
return ImmutableList.of(TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE,
TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER);
}
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -26,15 +26,15 @@ public class QnbFormedModel implements IModelGeometry<QnbFormedModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
return new QnbFormedBakedModel(ringModel, spriteGetter);
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return QnbFormedBakedModel.getRequiredTextures();
}
@@ -31,10 +31,10 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.AffineTransformation;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.texture.Sprite;
import net.minecraft.entity.LivingEntity;
import net.minecraft.fluid.Fluids;
@@ -53,10 +53,10 @@ import appeng.fluids.items.FluidDummyItem;
* Override List is used to accomplish this.
*/
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
private final Function<Material, Sprite> bakedTextureGetter;
private final Function<SpriteIdentifier, Sprite> bakedTextureGetter;
public DummyFluidDispatcherBakedModel(BakedModel baseModel,
Function<Material, Sprite> bakedTextureGetter) {
Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
super(baseModel);
this.bakedTextureGetter = bakedTextureGetter;
}
@@ -101,7 +101,7 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
FluidAttributes attributes = fluidStack.getFluidKey().getAttributes();
Identifier stillTexture = attributes.getStillTexture(fluidStack);
Material stillMaterial = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, stillTexture);
SpriteIdentifier stillMaterial = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, stillTexture);
Sprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial);
if (sprite == null) {
return new DummyFluidBakedModel(ImmutableList.of());
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -49,7 +49,7 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
@@ -57,8 +57,8 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.emptyList();
}
@@ -27,6 +27,7 @@ import com.mojang.datafixers.util.Pair;
import net.minecraft.client.render.model.*;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
@@ -45,7 +46,7 @@ public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
FacadeBuilder facadeBuilder = new FacadeBuilder();
@@ -54,8 +55,8 @@ public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return modelGetter.apply(MODEL_BASE).getTextures(modelGetter, missingTextureErrors);
}
@@ -1,116 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.renderer.Vector4f;
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.setIdentity();
this.mat.mul(xRot = Vector3f.POSITIVE_X.getDegreesQuaternion(rot.getX()));
this.mat.mul(yRot = Vector3f.POSITIVE_Y.getDegreesQuaternion(rot.getY()));
this.mat.mul(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.getDirectionVec();
Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 1);
vec.transform(mat);
return Direction.getFacingFromVector(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();
}
}
@@ -27,7 +27,7 @@ import org.lwjgl.opengl.GL11;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@@ -127,7 +127,7 @@ public class TesrRenderHelper {
matrixStack.scale(1.0f / 62.0f, -1.0f / 62.0f, 1.0f / 62.0f);
matrixStack.scale(0.5f, 0.5f, 0);
matrixStack.translate(-0.5f * width, 0.0f, 0.5f);
fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.getLast().getMatrix(), buffers, false, 0,
fr.renderString(renderedStackSize, 0, 0, -1, false, matrixStack.peek().getMatrix(), buffers, false, 0,
15728880);
matrixStack.pop();
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.function.Function;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.math.Direction;
@@ -49,7 +49,7 @@ class CableBuilder {
private final SmartCableTextures smartCableTextures;
CableBuilder(Function<Material, Sprite> bakedTextureGetter) {
CableBuilder(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
this.coreTextures = new EnumMap<>(CableCoreType.class);
for (CableCoreType type : CableCoreType.values()) {
@@ -77,7 +77,7 @@ class CableBuilder {
this.smartCableTextures = new SmartCableTextures(bakedTextureGetter);
}
static Material getConnectionTexture(AECableType cableType, AEColor color) {
static SpriteIdentifier getConnectionTexture(AECableType cableType, AEColor color) {
String textureFolder;
switch (cableType) {
case GLASS:
@@ -99,7 +99,7 @@ class CableBuilder {
throw new IllegalStateException("Cable type " + cableType + " does not support connections.");
}
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, textureFolder + color.name().toLowerCase()));
}
@@ -701,8 +701,8 @@ class CableBuilder {
}
// Get all textures needed for building the actual cable quads
public static List<Material> getTextures() {
List<Material> locations = new ArrayList<>();
public static List<SpriteIdentifier> getTextures() {
List<SpriteIdentifier> locations = new ArrayList<>();
for (CableCoreType coreType : CableCoreType.values()) {
for (AEColor color : AEColor.values()) {
@@ -31,7 +31,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -55,7 +55,7 @@ public class CableBusModel implements IModelGeometry<CableBusModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
Map<Identifier, BakedModel> partModels = this.loadPartModels(bakery, spriteGetter, modelTransform);
@@ -71,13 +71,13 @@ public class CableBusModel implements IModelGeometry<CableBusModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.unmodifiableList(CableBuilder.getTextures());
}
private Map<Identifier, BakedModel> loadPartModels(ModelLoader bakery,
Function<Material, Sprite> spriteGetterIn, IModelTransform transformIn) {
Function<SpriteIdentifier, Sprite> spriteGetterIn, IModelTransform transformIn) {
ImmutableMap.Builder<Identifier, BakedModel> result = ImmutableMap.builder();
for (Identifier location : this.partModels.getModels()) {
@@ -23,7 +23,7 @@ import java.util.Map;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.util.Identifier;
@@ -72,8 +72,8 @@ public enum CableCoreType {
return cableMapping.get(cableType);
}
public Material getTexture(AEColor color) {
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
public SpriteIdentifier getTexture(AEColor color) {
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase()));
}
@@ -25,7 +25,7 @@ import java.util.List;
import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.Vector4f;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -22,12 +22,12 @@ import net.minecraftforge.client.model.geometry.IModelGeometry;
import appeng.core.AppEng;
public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequencyModel> {
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "parts/p2p_tunnel_frequency"));
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
try {
final Sprite texture = spriteGetter.apply(TEXTURE);
@@ -38,8 +38,8 @@ public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequenc
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.singleton(TEXTURE);
}
@@ -21,7 +21,7 @@ package appeng.client.render.cablebus;
import java.util.Arrays;
import java.util.function.Function;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -33,7 +33,7 @@ import appeng.core.AppEng;
*/
public class SmartCableTextures {
public static final Material[] SMART_CHANNELS_TEXTURES = Arrays
public static final SpriteIdentifier[] SMART_CHANNELS_TEXTURES = Arrays
.stream(new Identifier[] { new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_00"), //
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_01"), //
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_02"), //
@@ -44,14 +44,14 @@ public class SmartCableTextures {
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_12"), //
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_13"), //
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_14")//
}).map(e -> new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, e)).toArray(Material[]::new);
}).map(e -> new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, e)).toArray(SpriteIdentifier[]::new);
// Textures used to display channels on smart cables. There's two sets of 5
// textures each, and
// one of each set are composed together to get even/odd colored channels
private final Sprite[] textures;
public SmartCableTextures(Function<Material, Sprite> bakedTextureGetter) {
public SmartCableTextures(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
this.textures = Arrays.stream(SMART_CHANNELS_TEXTURES)//
.map(bakedTextureGetter)//
.toArray(Sprite[]::new);
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -45,20 +45,20 @@ import appeng.core.AppEng;
*/
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
private final static Material RING_CORNER = texture("ring_corner");
private final static Material RING_SIDE_HOR = texture("ring_side_hor");
private final static Material RING_SIDE_VER = texture("ring_side_ver");
private final static Material UNIT_BASE = texture("unit_base");
private final static Material LIGHT_BASE = texture("light_base");
private final static Material ACCELERATOR_LIGHT = texture("accelerator_light");
private final static Material STORAGE_1K_LIGHT = texture("1k_storage_light");
private final static Material STORAGE_4K_LIGHT = texture("4k_storage_light");
private final static Material STORAGE_16K_LIGHT = texture("16k_storage_light");
private final static Material STORAGE_64K_LIGHT = texture("64k_storage_light");
private final static Material MONITOR_BASE = texture("monitor_base");
private final static Material MONITOR_LIGHT_DARK = texture("monitor_light_dark");
private final static Material MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium");
private final static Material MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright");
private final static SpriteIdentifier RING_CORNER = texture("ring_corner");
private final static SpriteIdentifier RING_SIDE_HOR = texture("ring_side_hor");
private final static SpriteIdentifier RING_SIDE_VER = texture("ring_side_ver");
private final static SpriteIdentifier UNIT_BASE = texture("unit_base");
private final static SpriteIdentifier LIGHT_BASE = texture("light_base");
private final static SpriteIdentifier ACCELERATOR_LIGHT = texture("accelerator_light");
private final static SpriteIdentifier STORAGE_1K_LIGHT = texture("1k_storage_light");
private final static SpriteIdentifier STORAGE_4K_LIGHT = texture("4k_storage_light");
private final static SpriteIdentifier STORAGE_16K_LIGHT = texture("16k_storage_light");
private final static SpriteIdentifier STORAGE_64K_LIGHT = texture("64k_storage_light");
private final static SpriteIdentifier MONITOR_BASE = texture("monitor_base");
private final static SpriteIdentifier MONITOR_LIGHT_DARK = texture("monitor_light_dark");
private final static SpriteIdentifier MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium");
private final static SpriteIdentifier MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright");
private final AbstractCraftingUnitBlock.CraftingUnitType type;
@@ -67,8 +67,8 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return ImmutableList.of(RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT,
STORAGE_1K_LIGHT, STORAGE_4K_LIGHT, STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE,
MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT);
@@ -76,7 +76,7 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
// Retrieve our textures and pass them on to the baked model
Sprite ringCorner = spriteGetter.apply(RING_CORNER);
@@ -102,7 +102,7 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
}
}
private static Sprite getLightTexture(Function<Material, Sprite> textureGetter,
private static Sprite getLightTexture(Function<SpriteIdentifier, Sprite> textureGetter,
AbstractCraftingUnitBlock.CraftingUnitType type) {
switch (type) {
case ACCELERATOR:
@@ -120,8 +120,8 @@ class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
}
}
private static Material texture(String name) {
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static SpriteIdentifier texture(String name) {
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/crafting/" + name));
}
}
@@ -10,7 +10,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -29,14 +29,14 @@ public class EncodedPatternModel implements IModelGeometry<EncodedPatternModel>
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return modelGetter.apply(baseModel).getTextures(modelGetter, missingTextureErrors);
}
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel baseModel = bakery.getBakedModel(this.baseModel, modelTransform, spriteGetter);
return new EncodedPatternBakedModel(baseModel);
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.renderer.Vector4f;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.texture.Sprite;
@@ -262,11 +262,11 @@ public class AutoRotatingBakedModel implements BakedModel {
} else {
switch (fs.length) {
case 3:
Vec3i vec = this.f2r.rotate(this.face).getDirectionVec();
Vec3i vec = this.f2r.rotate(this.face).getVector();
return new float[] { vec.getX(), vec.getY(), vec.getZ() };
case 4:
Vector4f veccc = new Vector4f(fs[0], fs[1], fs[2], fs[3]);
Vec3i vecc = this.f2r.rotate(this.face).getDirectionVec();
Vec3i vecc = this.f2r.rotate(this.face).getVector();
return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), veccc.getW() };
default:
@@ -13,7 +13,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -30,19 +30,19 @@ import appeng.core.AppEng;
public class BiometricCardModel implements IModelGeometry<BiometricCardModel> {
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/biometric_card_base");
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "item/biometric_card_hash"));
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.singleton(TEXTURE);
}
@Nullable
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform transformIn,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform transformIn,
ModelOverrideList overrides, Identifier locationIn) {
Sprite texture = spriteGetter.apply(TEXTURE);
@@ -11,7 +11,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -30,22 +30,22 @@ public class ColorApplicatorModel implements IModelGeometry<ColorApplicatorModel
private static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID,
"item/color_applicator_colored");
private static final Material TEXTURE_DARK = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_DARK = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_dark"));
private static final Material TEXTURE_MEDIUM = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_MEDIUM = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_medium"));
private static final Material TEXTURE_BRIGHT = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE_BRIGHT = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "item/color_applicator_tip_bright"));
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Arrays.asList(TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK);
}
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
@@ -33,7 +33,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -57,7 +57,7 @@ public class DriveModel implements IModelGeometry<DriveModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
EnumMap<DriveSlotCellType, BakedModel> cellModels = new EnumMap<>(DriveSlotCellType.class);
@@ -72,8 +72,8 @@ public class DriveModel implements IModelGeometry<DriveModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.emptyList();
}
@@ -34,7 +34,7 @@ import com.google.common.base.Strings;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -64,30 +64,30 @@ class GlassBakedModel implements IDynamicBakedModel {
private static final byte[][][] OFFSETS = generateOffsets();
// Alternating textures based on position
static final Material TEXTURE_A = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
static final SpriteIdentifier TEXTURE_A = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier("appliedenergistics2:block/glass/quartz_glass_a"));
static final Material TEXTURE_B = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
static final SpriteIdentifier TEXTURE_B = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier("appliedenergistics2:block/glass/quartz_glass_b"));
static final Material TEXTURE_C = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
static final SpriteIdentifier TEXTURE_C = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier("appliedenergistics2:block/glass/quartz_glass_c"));
static final Material TEXTURE_D = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
static final SpriteIdentifier TEXTURE_D = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier("appliedenergistics2:block/glass/quartz_glass_d"));
// Frame texture
static final Material[] TEXTURES_FRAME = generateTexturesFrame();
static final SpriteIdentifier[] TEXTURES_FRAME = generateTexturesFrame();
// Generates the required textures for the frame
private static Material[] generateTexturesFrame() {
private static SpriteIdentifier[] generateTexturesFrame() {
return IntStream.range(1, 16).mapToObj(Integer::toBinaryString).map(s -> Strings.padStart(s, 4, '0'))
.map(s -> new Identifier("appliedenergistics2:block/glass/quartz_glass_frame" + s))
.map(rl -> new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, rl)).toArray(Material[]::new);
.map(rl -> new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, rl)).toArray(SpriteIdentifier[]::new);
}
private final Sprite[] glassTextures;
private final Sprite[] frameTextures;
public GlassBakedModel(Function<Material, Sprite> bakedTextureGetter) {
public GlassBakedModel(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
this.glassTextures = new Sprite[] { bakedTextureGetter.apply(TEXTURE_A),
bakedTextureGetter.apply(TEXTURE_B), bakedTextureGetter.apply(TEXTURE_C),
bakedTextureGetter.apply(TEXTURE_D) };
@@ -212,7 +212,7 @@ class GlassBakedModel implements IDynamicBakedModel {
private BakedQuad createQuad(Direction side, Vec3d c1, Vec3d c2, Vec3d c3, Vec3d c4, Sprite sprite,
float uOffset, float vOffset) {
Vec3d normal = new Vec3d(side.getDirectionVec());
Vec3d normal = new Vec3d(side.getVector());
// Apply the u,v shift.
// This mirrors the logic from OffsetIcon from 1.7
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -43,16 +43,16 @@ public class GlassModel implements IModelGeometry<GlassModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
return new GlassBakedModel(spriteGetter);
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return ImmutableSet
.<Material>builder().add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B,
.<SpriteIdentifier>builder().add(GlassBakedModel.TEXTURE_A, GlassBakedModel.TEXTURE_B,
GlassBakedModel.TEXTURE_C, GlassBakedModel.TEXTURE_D)
.add(GlassBakedModel.TEXTURES_FRAME).build();
}
@@ -20,8 +20,8 @@ package appeng.client.render.model;
import java.util.List;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.client.renderer.Vector4f;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
@@ -13,7 +13,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -30,19 +30,19 @@ import appeng.core.AppEng;
public class MemoryCardModel implements IModelGeometry<MemoryCardModel> {
public static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/memory_card_base");
private static final Material TEXTURE = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static final SpriteIdentifier TEXTURE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "item/memory_card_hash"));
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.singleton(TEXTURE);
}
@Nullable
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
Sprite texture = spriteGetter.apply(TEXTURE);
@@ -29,7 +29,7 @@ import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.texture.Sprite;
@@ -89,8 +89,8 @@ public class SkyCompassBakedModel implements IDynamicBakedModel {
if (side == null) {
// Set up the rotation around the Y-axis for the pointer
Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
matrix.mul(new Quaternion(0, rotation, 0, false));
matrix.loadIdentity();
matrix.multiply(new Quaternion(0, rotation, 0, false));
MatrixVertexTransformer transformer = new MatrixVertexTransformer(matrix);
for (BakedQuad bakedQuad : this.pointer.getQuads(state, side, rand, extraData)) {
@@ -31,7 +31,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.Identifier;
@@ -54,7 +54,7 @@ public class SkyCompassModel implements IModelGeometry<SkyCompassModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
BakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
BakedModel pointerModel = bakery.getBakedModel(MODEL_POINTER, modelTransform, spriteGetter);
@@ -62,8 +62,8 @@ public class SkyCompassModel implements IModelGeometry<SkyCompassModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.emptyList();
}
@@ -53,7 +53,7 @@ import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverride;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.ItemTransformVec3f;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.resources.IResourceManager;
import net.minecraft.util.math.Direction;
import net.minecraft.util.JSONUtils;
@@ -143,7 +143,7 @@ public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapp
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
Sprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
@@ -199,9 +199,9 @@ public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapp
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter,
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter,
Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors) {
return parent.getTextures(modelGetter, missingTextureErrors);
}
@@ -32,7 +32,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -46,7 +46,7 @@ public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel> {
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
Map<SpatialPylonTextureType, Sprite> textures = new EnumMap<>(SpatialPylonTextureType.class);
@@ -58,14 +58,14 @@ public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Arrays.stream(SpatialPylonTextureType.values()).map(SpatialPylonModel::getTexturePath)
.collect(Collectors.toList());
}
private static Material getTexturePath(SpatialPylonTextureType type) {
return new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
private static SpriteIdentifier getTexturePath(SpatialPylonTextureType type) {
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
new Identifier(AppEng.MOD_ID, "block/spatial_pylon/" + type.name().toLowerCase()));
}
@@ -27,9 +27,9 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
@@ -62,8 +62,8 @@ public class CrankTESR extends BlockEntityRenderer<CrankBlockEntity> {
BlockState blockState = te.getCachedState();
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
BakedModel model = dispatcher.getModelForState(blockState);
VertexConsumer buffer = buffers.getBuffer(Atlases.getTranslucentBlockType());
dispatcher.getBlockModelRenderer().renderModelBrightnessColor(ms.getLast(), buffer, null, model, 1, 1, 1,
VertexConsumer buffer = buffers.getBuffer(TexturedRenderLayers.getEntityTranslucentCull());
dispatcher.getModelRenderer().renderModelBrightnessColor(ms.peek(), buffer, null, model, 1, 1, 1,
combinedLightIn, combinedOverlayIn);
ms.pop();
@@ -107,7 +107,7 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
float x = LED_QUADS[i];
float y = LED_QUADS[i + 1];
float z = LED_QUADS[i + 2];
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
buffer.pos(ms.peek().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
.endVertex();
}
@@ -7,12 +7,12 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.util.math.Quaternion;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.inventory.container.PlayerContainer;
@@ -35,7 +35,7 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
private static final SpriteIdentifier TEXTURE_INSIDE = new SpriteIdentifier(PlayerContainer.LOCATION_BLOCKS_TEXTURE,
new Identifier(AppEng.MOD_ID, "block/inscriber_inside"));
public InscriberTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
@@ -173,12 +173,12 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
private static void addVertex(VertexConsumer vb, MatrixStack ms, Sprite sprite, float x, float y,
float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
vb.pos(ms.getLast().getMatrix(), x, y, z);
vb.pos(ms.peek().getMatrix(), x, y, z);
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV));
vb.overlay(overlayUV);
vb.lightmap(lightmapUV);
vb.normal(ms.getLast().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
vb.normal(ms.peek().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
vb.endVertex();
}
@@ -1,126 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.tesr;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.render.model.ModelRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.event.TextureStitchEvent;
import appeng.block.storage.SkyChestBlock;
import appeng.block.storage.SkyChestBlock.SkyChestType;
import appeng.core.AppEng;
import appeng.tile.storage.SkyChestBlockEntity;
// This is mostly a copy&paste job of the vanilla chest TESR
@Environment(EnvType.CLIENT)
public class SkyChestTESR extends BlockEntityRenderer<SkyChestBlockEntity> {
public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS,
new Identifier(AppEng.MOD_ID, "models/skychest"));
public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS,
new Identifier(AppEng.MOD_ID, "models/skyblockchest"));
private final ModelRenderer singleLid;
private final ModelRenderer singleBottom;
private final ModelRenderer singleLatch;
public SkyChestTESR(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
this.singleBottom = new ModelRenderer(64, 64, 0, 19);
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
this.singleLid = new ModelRenderer(64, 64, 0, 0);
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
this.singleLid.rotationPointY = 9.0F;
this.singleLid.rotationPointZ = 1.0F;
this.singleLatch = new ModelRenderer(64, 64, 0, 0);
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
this.singleLatch.rotationPointY = 8.0F;
}
@Override
public void render(SkyChestBlockEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn,
VertexConsumerProvider bufferIn, int combinedLightIn, int combinedOverlayIn) {
matrixStackIn.push();
float f = tileEntityIn.getForward().getHorizontalAngle();
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.getLidAngle(partialTicks);
f1 = 1.0F - f1;
f1 = 1.0F - f1 * f1 * f1;
Material material = this.getMaterial(tileEntityIn);
VertexConsumer ivertexbuilder = material.getBuffer(bufferIn, RenderLayer::getEntityCutout);
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1,
combinedLightIn, combinedOverlayIn);
matrixStackIn.pop();
}
private void renderModels(MatrixStack matrixStackIn, VertexConsumer bufferIn, ModelRenderer chestLid,
ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn,
int combinedOverlayIn) {
chestLid.rotateAngleX = -(lidAngle * 1.5707964F);
chestLatch.rotateAngleX = chestLid.rotateAngleX;
chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
chestLatch.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
chestBottom.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
}
protected Material 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;
}
}
public static void registerTextures(TextureStitchEvent.Pre evt) {
if (evt.getMap().getTextureLocation().equals(Atlases.CHEST_ATLAS)) {
evt.addSprite(TEXTURE_STONE.getTextureLocation());
evt.addSprite(TEXTURE_BLOCK.getTextureLocation());
}
}
}
@@ -1,110 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.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.renderer.Atlases;
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 net.minecraftforge.client.model.data.ModelDataMap;
import appeng.client.render.FacingToRotation;
import appeng.client.render.model.SkyCompassBakedModel;
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(Atlases.getTranslucentBlockType());
BlockState blockState = te.getCachedState();
BakedModel model = blockRenderer.getBlockModelShapes().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);
ModelDataMap modelData = new ModelDataMap.Builder().withInitial(SkyCompassBakedModel.ROTATION, getRotation(te))
.build();
blockRenderer.getBlockModelRenderer().renderModel(ms.getLast(), buffer, null, model, 1, 1, 1, combinedLightIn,
combinedOverlayIn, modelData);
ms.pop();
}
private static float getRotation(SkyCompassBlockEntity skyCompass) {
float rotation;
if (skyCompass.getForward() == Direction.UP || skyCompass.getForward() == Direction.DOWN) {
rotation = SkyCompassBakedModel.getAnimatedRotation(skyCompass.getPos(), false);
} else {
rotation = SkyCompassBakedModel.getAnimatedRotation(null, false);
}
if (skyCompass.getForward() == Direction.DOWN) {
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);
}
}
-87
View File
@@ -1,87 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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 final Api INSTANCE = new Api();
private final ApiPart partHelper;
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
private final IRegistryContainer registryContainer;
private final IStorageHelper storageHelper;
private final IGridHelper networkHelper;
private final ApiDefinitions definitions;
private final IClientHelper client;
private 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;
}
}
@@ -1,73 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -115,34 +115,10 @@ import java.util.Map;
final class Registration {
public Registration() {
AeStats.register();
advancementTriggers = new AdvancementTriggers(Criteria::register);
}
AdvancementTriggers advancementTriggers;
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();
gcr.registerGridCache(ITickManager.class, TickManagerCache.class);
gcr.registerGridCache(IEnergyGrid.class, EnergyGridCache.class);
gcr.registerGridCache(IPathingGrid.class, PathGridCache.class);
gcr.registerGridCache(IStorageGrid.class, GridStorageCache.class);
gcr.registerGridCache(P2PCache.class, P2PCache.class);
gcr.registerGridCache(ISpatialCache.class, SpatialPylonCache.class);
gcr.registerGridCache(ISecurityGrid.class, SecurityCache.class);
gcr.registerGridCache(ICraftingGrid.class, CraftingGridCache.class);
registries.cell().addCellHandler(new BasicCellHandler());
registries.cell().addCellHandler(new CreativeCellHandler());
registries.cell().addCellGuiHandler(new BasicItemCellGuiHandler());
registries.cell().addCellGuiHandler(new BasicFluidCellGuiHandler());
registries.matterCannon().registerAmmoItem(api.definitions().materials().matterBall().item(), 32);
}
@Environment(EnvType.CLIENT)
public void modelRegistryEvent(ModelRegistryEvent event) {
@@ -166,14 +142,6 @@ final class Registration {
partModels.setInitialized(true);
}
public void registerTileEntities(RegistryEvent.Register<BlockEntityType<?>> event) {
final IForgeRegistry<BlockEntityType<?>> registry = event.getRegistry();
// TODO: Do not use the internal API
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(ITileEntityRegistrationComponent.class)
.forEachRemaining(b -> b.register(registry));
}
public void registerContainerTypes(RegistryEvent.Register<ScreenHandlerType<?>> event) {
final IForgeRegistry<ScreenHandlerType<?>> registry = event.getRegistry();
@@ -321,29 +289,6 @@ final class Registration {
DisassembleRecipe.SERIALIZER);
}
public void registerParticleTypes(RegistryEvent.Register<ParticleType<?>> event) {
final IForgeRegistry<ParticleType<?>> registry = event.getRegistry();
registry.register(ParticleTypes.CHARGED_ORE);
registry.register(ParticleTypes.CRAFTING);
registry.register(ParticleTypes.ENERGY);
registry.register(ParticleTypes.LIGHTNING_ARC);
registry.register(ParticleTypes.LIGHTNING);
registry.register(ParticleTypes.MATTER_CANNON);
registry.register(ParticleTypes.VIBRANT);
}
@Environment(EnvType.CLIENT)
public void registerParticleFactories(ParticleFactoryRegisterEvent event) {
ParticleManager particles = MinecraftClient.getInstance().particles;
particles.registerFactory(ParticleTypes.CHARGED_ORE, ChargedOreFX.Factory::new);
particles.registerFactory(ParticleTypes.CRAFTING, CraftingFx.Factory::new);
particles.registerFactory(ParticleTypes.ENERGY, EnergyFx.Factory::new);
particles.registerFactory(ParticleTypes.LIGHTNING_ARC, LightningArcFX.Factory::new);
particles.registerFactory(ParticleTypes.LIGHTNING, LightningFX.Factory::new);
particles.registerFactory(ParticleTypes.MATTER_CANNON, MatterCannonFX.Factory::new);
particles.registerFactory(ParticleTypes.VIBRANT, VibrantFX.Factory::new);
}
// FIXME LATER
public static void postInit() {
final IRegistryContainer registries = AEApi.instance().registries();
@@ -575,32 +520,10 @@ final class Registration {
evt.getRegistry().register(StorageCellModDimension.INSTANCE);
}
@Environment(EnvType.CLIENT)
public void registerTextures(TextureStitchEvent.Pre event) {
SkyChestTESR.registerTextures(event);
InscriberTESR.registerTexture(event);
}
public void registerCommands(final FMLServerStartingEvent evt) {
new AECommand().register(evt.getCommandDispatcher());
}
@Environment(EnvType.CLIENT)
public void registerItemColors(ColorHandlerEvent.Item event) {
// TODO: Do not use the internal API
final ApiDefinitions definitions = Api.INSTANCE.definitions();
definitions.getRegistry().getBootstrapComponents(IItemColorRegistrationComponent.class)
.forEachRemaining(c -> c.register(event.getItemColors(), event.getBlockColors()));
}
@Environment(EnvType.CLIENT)
public 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));
}
@Environment(EnvType.CLIENT)
public void registerClientEvents() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
@@ -1,68 +0,0 @@
/*
* 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().append(" - " + list + " ")
.append(GuiText.Fuzzy.textComponent()));
} else {
lines.add(GuiText.Partitioned.textComponent().append(" - " + list + " ")
.append(GuiText.Precise.textComponent()));
}
}
}
}
@@ -1,59 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.api.util.AEPartLocation;
import appeng.me.GridConnection;
import appeng.me.GridNode;
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.");
}
return new GridNode(blk);
}
@Override
public IGridConnection createGridConnection(final IGridNode a, final IGridNode b) throws FailedConnectionException {
Preconditions.checkNotNull(a);
Preconditions.checkNotNull(b);
return GridConnection.create(a, b, AEPartLocation.INTERNAL);
}
}
@@ -1,46 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
import appeng.parts.PartPlacement;
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) {
return PartPlacement.place(is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0);
}
@Override
public CableRenderMode getCableRenderMode() {
return AppEng.proxy.getRenderMode();
}
}
@@ -1,205 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api;
import java.util.Collection;
import java.util.Collections;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
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 net.minecraftforge.fluids.FluidUtil;
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.crafting.CraftingLink;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.FluidList;
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);
return new CraftingLink(data, req);
}
@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 {
return AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is).orElse(null));
}
}
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);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,559 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import java.util.function.Consumer;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.features.AEFeature;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc;
import appeng.debug.DebugCardItem;
import appeng.debug.DebugPartPlacerItem;
import appeng.debug.EraserItem;
import appeng.debug.MeteoritePlacerItem;
import appeng.debug.ReplicatorCardItem;
import appeng.entity.GrowingCrystalEntity;
import appeng.fluids.items.BasicFluidStorageCell;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.items.FluidDummyItemRendering;
import appeng.hooks.BlockToolDispenseItemBehavior;
import appeng.hooks.MatterCannonDispenseItemBehavior;
import appeng.items.materials.MaterialType;
import appeng.items.misc.CrystalSeedItem;
import appeng.items.misc.EncodedPatternItem;
import appeng.items.misc.PaintBallItem;
import appeng.items.misc.PaintBallItemRendering;
import appeng.items.parts.FacadeItem;
import appeng.items.storage.BasicStorageCellItem;
import appeng.items.storage.CreativeStorageCellItem;
import appeng.items.storage.SpatialStorageCellItem;
import appeng.items.storage.ViewCellItem;
import appeng.items.tools.BiometricCardItem;
import appeng.items.tools.MemoryCardItem;
import appeng.items.tools.NetworkToolItem;
import appeng.items.tools.powered.ChargedStaffItem;
import appeng.items.tools.powered.ColorApplicatorItem;
import appeng.items.tools.powered.ColorApplicatorItemRendering;
import appeng.items.tools.powered.EntropyManipulatorItem;
import appeng.items.tools.powered.MatterCannonItem;
import appeng.items.tools.powered.PortableCellItem;
import appeng.items.tools.powered.WirelessTerminalItem;
import appeng.items.tools.quartz.QuartzAxeItem;
import appeng.items.tools.quartz.QuartzCuttingKnifeItem;
import appeng.items.tools.quartz.QuartzHoeItem;
import appeng.items.tools.quartz.QuartzPickaxeItem;
import appeng.items.tools.quartz.QuartzSpadeItem;
import appeng.items.tools.quartz.QuartzSwordItem;
import appeng.items.tools.quartz.QuartzWrenchItem;
/**
* Internal implementation for the API items
*/
public final class ApiItems implements IItems {
private final IItemDefinition certusQuartzAxe;
private final IItemDefinition certusQuartzHoe;
private final IItemDefinition certusQuartzShovel;
private final IItemDefinition certusQuartzPick;
private final IItemDefinition certusQuartzSword;
private final IItemDefinition certusQuartzWrench;
private final IItemDefinition certusQuartzKnife;
private final IItemDefinition netherQuartzAxe;
private final IItemDefinition netherQuartzHoe;
private final IItemDefinition netherQuartzShovel;
private final IItemDefinition netherQuartzPick;
private final IItemDefinition netherQuartzSword;
private final IItemDefinition netherQuartzWrench;
private final IItemDefinition netherQuartzKnife;
private final IItemDefinition entropyManipulator;
private final IItemDefinition wirelessTerminal;
private final IItemDefinition biometricCard;
private final IItemDefinition chargedStaff;
private final IItemDefinition massCannon;
private final IItemDefinition memoryCard;
private final IItemDefinition networkTool;
private final IItemDefinition portableCell;
private final IItemDefinition cellCreative;
private final IItemDefinition viewCell;
private final IItemDefinition cell1k;
private final IItemDefinition cell4k;
private final IItemDefinition cell16k;
private final IItemDefinition cell64k;
private final IItemDefinition fluidCell1k;
private final IItemDefinition fluidCell4k;
private final IItemDefinition fluidCell16k;
private final IItemDefinition fluidCell64k;
private final IItemDefinition spatialCell2;
private final IItemDefinition spatialCell16;
private final IItemDefinition spatialCell128;
private final IItemDefinition facade;
private final IItemDefinition certusCrystalSeed;
private final IItemDefinition fluixCrystalSeed;
private final IItemDefinition netherQuartzSeed;
// rv1
private final IItemDefinition encodedPattern;
private final IItemDefinition colorApplicator;
private final AEColoredItemDefinition coloredPaintBall;
private final AEColoredItemDefinition coloredLumenPaintBall;
// unsupported dev tools
private final IItemDefinition toolEraser;
private final IItemDefinition toolMeteoritePlacer;
private final IItemDefinition toolDebugCard;
private final IItemDefinition toolReplicatorCard;
private final 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;
}
}
@@ -1,491 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,441 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.api.definitions;
import java.util.function.Function;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
import appeng.api.parts.IPart;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc;
import appeng.core.features.registries.PartModels;
import appeng.fluids.parts.FluidAnnihilationPlanePart;
import appeng.fluids.parts.FluidExportBusPart;
import appeng.fluids.parts.FluidFormationPlanePart;
import appeng.fluids.parts.FluidImportBusPart;
import appeng.fluids.parts.FluidInterfacePart;
import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.parts.FluidTerminalPart;
import appeng.items.parts.ColoredPartItem;
import appeng.items.parts.PartItem;
import appeng.items.parts.PartItemRendering;
import appeng.items.parts.PartType;
import appeng.parts.automation.AnnihilationPlanePart;
import appeng.parts.automation.ExportBusPart;
import appeng.parts.automation.FormationPlanePart;
import appeng.parts.automation.IdentityAnnihilationPlanePart;
import appeng.parts.automation.ImportBusPart;
import appeng.parts.automation.LevelEmitterPart;
import appeng.parts.misc.CableAnchorPart;
import appeng.parts.misc.InterfacePart;
import appeng.parts.misc.InvertedToggleBusPart;
import appeng.parts.misc.StorageBusPart;
import appeng.parts.misc.ToggleBusPart;
import appeng.parts.networking.CoveredCablePart;
import appeng.parts.networking.CoveredDenseCablePart;
import appeng.parts.networking.GlassCablePart;
import appeng.parts.networking.QuartzFiberPart;
import appeng.parts.networking.SmartCablePart;
import appeng.parts.networking.SmartDenseCablePart;
import appeng.parts.p2p.FEP2PTunnelPart;
import appeng.parts.p2p.FluidP2PTunnelPart;
import appeng.parts.p2p.ItemP2PTunnelPart;
import appeng.parts.p2p.LightP2PTunnelPart;
import appeng.parts.p2p.MEP2PTunnelPart;
import appeng.parts.p2p.RedstoneP2PTunnelPart;
import appeng.parts.reporting.ConversionMonitorPart;
import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.DarkPanelPart;
import appeng.parts.reporting.InterfaceTerminalPart;
import appeng.parts.reporting.PanelPart;
import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.SemiDarkPanelPart;
import appeng.parts.reporting.StorageMonitorPart;
import appeng.parts.reporting.TerminalPart;
/**
* Internal implementation for the API parts
*/
public final class ApiParts implements IParts {
private final AEColoredItemDefinition cableSmart;
private final AEColoredItemDefinition cableCovered;
private final AEColoredItemDefinition cableGlass;
private final AEColoredItemDefinition cableDenseCovered;
private final AEColoredItemDefinition cableDenseSmart;
private final IItemDefinition quartzFiber;
private final IItemDefinition toggleBus;
private final IItemDefinition invertedToggleBus;
private final IItemDefinition storageBus;
private final IItemDefinition importBus;
private final IItemDefinition exportBus;
private final IItemDefinition iface;
private final IItemDefinition fluidIface;
private final IItemDefinition levelEmitter;
private final IItemDefinition fluidLevelEmitter;
private final IItemDefinition annihilationPlane;
private final IItemDefinition identityAnnihilationPlane;
private final IItemDefinition fluidAnnihilationPlane;
private final IItemDefinition formationPlane;
private final IItemDefinition fluidFormationPlane;
private final IItemDefinition p2PTunnelME;
private final IItemDefinition p2PTunnelRedstone;
private final IItemDefinition p2PTunnelItems;
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
private final IItemDefinition p2PTunnelFE;
private final IItemDefinition p2PTunnelLight;
private final IItemDefinition cableAnchor;
private final IItemDefinition monitor;
private final IItemDefinition semiDarkMonitor;
private final IItemDefinition darkMonitor;
private final IItemDefinition interfaceTerminal;
private final IItemDefinition patternTerminal;
private final IItemDefinition craftingTerminal;
private final IItemDefinition terminal;
private final IItemDefinition storageMonitor;
private final IItemDefinition conversionMonitor;
private final IItemDefinition fluidImportBus;
private final IItemDefinition fluidExportBus;
private final IItemDefinition fluidTerminal;
private final IItemDefinition fluidStorageBus;
public ApiParts(FeatureFactory registry, PartModels partModels) {
registerPartModels(partModels);
this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART,
SmartCablePart::new);
this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED,
CoveredCablePart::new);
this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS,
GlassCablePart::new);
this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable",
PartType.CABLE_DENSE_COVERED, CoveredDenseCablePart::new);
this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART,
SmartDenseCablePart::new);
this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, QuartzFiberPart::new);
this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, ToggleBusPart::new);
this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS,
InvertedToggleBusPart::new);
this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, CableAnchorPart::new);
this.monitor = createPart(registry, "monitor", PartType.MONITOR, PanelPart::new);
this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR,
SemiDarkPanelPart::new);
this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, DarkPanelPart::new);
this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, StorageBusPart::new);
this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS,
FluidStorageBusPart::new);
this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, ImportBusPart::new);
this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS,
FluidImportBusPart::new);
this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, ExportBusPart::new);
this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS,
FluidExportBusPart::new);
this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, LevelEmitterPart::new);
this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER,
FluidLevelEmitterPart::new);
this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE,
AnnihilationPlanePart::new);
this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane",
PartType.IDENTITY_ANNIHILATION_PLANE, IdentityAnnihilationPlanePart::new);
this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane",
PartType.FLUID_ANNIHILATION_PLANE, FluidAnnihilationPlanePart::new);
this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE,
FormationPlanePart::new);
this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE,
FluidFormationPlanePart::new);
this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL,
PatternTerminalPart::new);
this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL,
CraftingTerminalPart::new);
this.terminal = createPart(registry, "terminal", PartType.TERMINAL, TerminalPart::new);
this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR,
StorageMonitorPart::new);
this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR,
ConversionMonitorPart::new);
this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, InterfacePart::new);
this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE,
FluidInterfacePart::new);
this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, MEP2PTunnelPart::new);
this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE,
RedstoneP2PTunnelPart::new);
this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, ItemP2PTunnelPart::new);
this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID,
FluidP2PTunnelPart::new);
this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2,
// PartP2PIC2Power::new);
this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, FEP2PTunnelPart::new);
this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT,
LightP2PTunnelPart::new);
this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL,
InterfaceTerminalPart::new);
this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, FluidTerminalPart::new);
}
private void registerPartModels(PartModels partModels) {
// Register the built-in models for annihilation planes
Identifier fluidFormationPlaneTexture = new Identifier(AppEng.MOD_ID,
"item/part/fluid_formation_plane");
Identifier fluidFormationPlaneOnTexture = new Identifier(AppEng.MOD_ID,
"parts/fluid_formation_plane_on");
// Register all part models
for (PartType partType : PartType.values()) {
partModels.registerModels(partType.getModels());
}
}
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id, PartType type,
Function<ItemStack, T> factory) {
return registry.item(id, props -> new PartItem<>(props, type, factory)).itemGroup(CreativeTab.INSTANCE)
.rendering(new PartItemRendering()).build();
}
private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry,
String idSuffix, PartType type, Function<ItemStack, T> factory) {
final ColoredItemDefinition definition = new ColoredItemDefinition();
for (final AEColor color : AEColor.values()) {
String id = color.registryPrefix + '_' + idSuffix;
IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color))
.itemGroup(CreativeTab.INSTANCE).rendering(new PartItemRendering(color)).build();
definition.add(color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled));
}
return definition;
}
@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;
}
}
@@ -1,71 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,58 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.features.ILocatable;
import appeng.api.features.ILocatableRegistry;
import appeng.util.Platform;
public final class LocatableRegistry implements ILocatableRegistry {
private final Map<Long, ILocatable> set;
public LocatableRegistry() {
this.set = new HashMap<>();
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void updateLocatable(final LocatableEventAnnounce e) {
if (Platform.isClient()) {
return; // IGNORE!
}
if (e.change == LocatableEvent.REGISTER) {
this.set.put(e.target.getLocatableSerial(), e.target);
} else if (e.change == LocatableEvent.UNREGISTER) {
this.set.remove(e.target.getLocatableSerial());
}
}
@Override
public ILocatable getLocatableBy(final long serial) {
return this.set.get(serial);
}
}
@@ -1,147 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.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 (Identifier tag : item.getTags()) {
weight = tagDamageModifiers.get(tag);
if (weight != null) {
return weight.floatValue();
}
}
return 0;
}
private void addTagWeight(String name, final double weight) {
this.registerAmmoTag(new Identifier(name), weight);
}
}
@@ -1,146 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.remove();
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);
}
}
@@ -1,259 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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 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 net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.registries.ForgeRegistries;
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 appeng.capabilities.Capabilities;
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<Capability<?>, TunnelType> capTunnels = 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
*/
this.addNewAttunement(Capabilities.FORGE_ENERGY, TunnelType.FE_POWER);
this.addNewAttunement(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, 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 Capability<?> cap, @Nullable final TunnelType type) {
if (type == null || cap == null) {
return;
}
this.capTunnels.put(cap, 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 (Direction face : Direction.values()) {
for (Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet()) {
if (trigger.getCapability(entry.getKey(), face).isPresent()) {
return entry.getValue();
}
}
}
// Use the mod id as last option.
for (final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet()) {
if (trigger.getItem().getRegistryName() != null
&& trigger.getItem().getRegistryName().getNamespace().equals(entry.getKey())) {
return entry.getValue();
}
}
}
return null;
}
@Nonnull
private ItemStack getModItem(final String modID, final String name) {
final Item item = ForgeRegistries.ITEMS.getValue(new Identifier(modID + ":" + name));
if (item == null) {
return ItemStack.EMPTY;
}
final ItemStack myItemStack = new ItemStack(item, 1);
return myItemStack;
}
private void addNewAttunement(final IItemDefinition definition, final TunnelType type) {
definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type));
}
}
@@ -1,51 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,65 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.proxy.getPlayers()) {
if (player.getUniqueID().equals(profileId)) {
return player;
}
}
return null;
}
}
@@ -1,112 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,105 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.WirelessTermContainer;
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)) {
ContainerOpener.openContainer(WirelessTermContainer.TYPE, player, ContainerLocator.forHand(player, hand));
} else {
player.sendSystemMessage(PlayerMessages.DeviceNotPowered.get(), Util.NIL_UUID);
}
}
}
@@ -1,106 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.features.registries;
import java.util.HashSet;
import net.minecraft.util.Identifier;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.dimension.DimensionType;
import appeng.api.features.IWorldGen;
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 disableWorldGenForProviderID(WorldGenType type, Class<? extends Dimension> provider) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
if (provider == null) {
throw new IllegalArgumentException("Bad Provider Passed");
}
this.types[type.ordinal()].badProviders.add(provider);
}
@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 WorldAccess w) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
if (w == null) {
throw new IllegalArgumentException("Bad Provider Passed");
}
Identifier id = w.getDimension().getType().getRegistryName();
final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains(w.getDimension().getClass());
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains(id);
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains(id);
if (isBadProvider || isBadDimension) {
return false;
}
if (!isGoodDimension && type == WorldGenType.METEORITES) {
return false;
}
return true;
}
private static class TypeSet {
final HashSet<Class<? extends Dimension>> badProviders = new HashSet<>();
final HashSet<Identifier> badDimensions = new HashSet<>();
final HashSet<Identifier> enabledDimensions = new HashSet<>();
}
}
@@ -1,49 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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);
}
}
@@ -1,32 +0,0 @@
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;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.MEMonitorableContainer;
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) {
ContainerOpener.openContainer(MEMonitorableContainer.TYPE, player,
ContainerLocator.forTileEntitySide((BlockEntity) chest, chest.getUp()));
}
}
@@ -1,121 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,60 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,68 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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);
}
}
@@ -66,7 +66,7 @@ public class DebugPartPlacerItem extends AEBaseItem {
}
Direction face = context.getSide();
Vec3i offset = face.getDirectionVec();
Vec3i offset = face.getVector();
Direction[] perpendicularFaces = Arrays.stream(Direction.values()).filter(d -> d.getAxis() != face.getAxis())
.toArray(Direction[]::new);
@@ -1,174 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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);
}
}
@@ -1,63 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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();
}
}
@@ -19,8 +19,8 @@
package appeng.hooks;
import net.minecraft.block.DispenserBlock;
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.item.DirectionalPlaceContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -29,10 +29,10 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.server.world.ServerWorld;
public final class BlockToolDispenseItemBehavior extends DefaultDispenseItemBehavior {
public final class BlockToolDispenseItemBehavior extends ItemDispenserBehavior {
@Override
protected ItemStack dispenseStack(final IBlockSource dispenser, final ItemStack dispensedItem) {
protected ItemStack dispenseSilently(final BlockPointer dispenser, final ItemStack dispensedItem) {
final Item i = dispensedItem.getItem();
if (i instanceof IBlockTool) {
final Direction direction = dispenser.getBlockState().get(DispenserBlock.FACING);
@@ -20,8 +20,8 @@ package appeng.hooks;
import appeng.util.FakePlayer;
import net.minecraft.block.DispenserBlock;
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -33,10 +33,10 @@ import appeng.api.util.AEPartLocation;
import appeng.items.tools.powered.MatterCannonItem;
import appeng.util.Platform;
public final class MatterCannonDispenseItemBehavior extends DefaultDispenseItemBehavior {
public final class MatterCannonDispenseItemBehavior extends ItemDispenserBehavior {
@Override
protected ItemStack dispenseStack(final IBlockSource dispenser, ItemStack dispensedItem) {
protected ItemStack dispenseSilently(final BlockPointer dispenser, ItemStack dispensedItem) {
final Item i = dispensedItem.getItem();
if (i instanceof MatterCannonItem) {
final Direction Direction = dispenser.getBlockState().get(DispenserBlock.FACING);
@@ -1,45 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.hooks;
import net.minecraft.block.DispenserBlock;
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.IBlockSource;
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 DefaultDispenseItemBehavior {
@Override
protected ItemStack dispenseStack(final IBlockSource 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;
}
}
@@ -35,7 +35,7 @@ public final class PartAccessor {
public Optional<IPart> getMaybePart(final BlockEntity te, final IProbeHitData data) {
if (te instanceof IPartHost) {
BlockPos pos = data.getPos();
final Vec3d position = data.getHitVec().add(-pos.getX(), -pos.getY(), -pos.getZ());
final Vec3d position = data.getHitPos().add(-pos.getX(), -pos.getY(), -pos.getZ());
final IPartHost host = (IPartHost) te;
final SelectedPart sp = host.selectPart(position);
@@ -1,39 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.contents;
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(int slot) {
this.writeToNBT(this.is.getOrCreateTag(), "list");
}
}
@@ -18,6 +18,7 @@
package appeng.items.contents;
import alexiil.mc.lib.attributes.item.FixedItemInvView;
import net.minecraft.item.ItemStack;
import appeng.parts.automation.StackUpgradeInventory;
@@ -32,7 +33,7 @@ public final class CellUpgrades extends StackUpgradeInventory {
}
@Override
protected void onContentsChanged(int slot) {
protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) {
this.writeToNBT(this.is.getOrCreateTag(), "upgrades");
}
}
@@ -1,255 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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 net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
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.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 {
/**
* 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().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 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.getHitVec());
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.setHeldItem(hand, ad.addItems(player.getStackInHand(hand)));
return ActionResult.SUCCESS;
}
}
}
return super.onItemUseFirst(stack, context);
}
@Override
public boolean hasCustomEntity(final ItemStack is) {
return materialType.hasCustomEntity();
}
@Override
public Entity createEntity(final World w, final Entity location, final ItemStack itemstack) {
final Class<? extends Entity> droppedEntity = materialType.getCustomEntityClass();
final Entity eqi;
try {
eqi = droppedEntity.getConstructor(World.class, double.class, double.class, double.class, ItemStack.class)
.newInstance(w, location.getX(), location.getY(), location.getZ(), itemstack);
} catch (final Throwable t) {
throw new IllegalStateException(t);
}
eqi.setVelocity(location.getVelocity());
if (location instanceof ItemEntity && eqi instanceof ItemEntity) {
((ItemEntity) eqi).setDefaultPickupDelay();
}
return eqi;
}
@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());
}
}
}
@@ -1,88 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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());
}
}
}
}
}
@@ -86,7 +86,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
@Override
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
final BlockHitResult mop = new BlockHitResult(context.getHitVec(), context.getSide(),
final BlockHitResult mop = new BlockHitResult(context.getHitPos(), context.getSide(),
context.getBlockPos(), context.isInside());
final BlockEntity te = context.getWorld().getBlockEntity(context.getBlockPos());
@@ -155,7 +155,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
return true;
} else {
BlockHitResult rtr = new BlockHitResult(useContext.getHitVec(), side, pos, false);
BlockHitResult rtr = new BlockHitResult(useContext.getHitPos(), side, pos, false);
bs.onUse(w, p, hand, rtr);
}
@@ -1,306 +0,0 @@
/*
* 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;
}
}
@@ -1,238 +0,0 @@
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;
}
}
@@ -1,128 +0,0 @@
/*
* 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();
}
}
@@ -1,119 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,167 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -1,101 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.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;
}
}
@@ -313,7 +313,7 @@ public class PartPlacement {
if (!player.isCreative()) {
held.increment(-1);
if (held.getCount() == 0) {
player.setHeldItem(hand, ItemStack.EMPTY);
player.setStackInHand(hand, ItemStack.EMPTY);
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held, hand));
}
}
@@ -228,7 +228,7 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
final PlayerEntity player = FakePlayer.getOrCreate((ServerWorld) w);
Platform.configurePlayer(player, side, this.getTile());
Hand hand = player.getActiveHand();
player.setHeldItem(hand, is);
player.setStackInHand(hand, is);
maxStorage = is.getCount();
worked = true;
@@ -276,7 +276,7 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
}
// Safe keeping
player.setHeldItem(hand, ItemStack.EMPTY);
player.setStackInHand(hand, ItemStack.EMPTY);
} else {
worked = true;
@@ -29,7 +29,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.Sprite;
@@ -42,19 +42,19 @@ import net.minecraftforge.client.model.geometry.IModelGeometry;
*/
public class PlaneModel implements IModelGeometry<PlaneModel> {
private final Material frontTexture;
private final Material sidesTexture;
private final Material backTexture;
private final SpriteIdentifier frontTexture;
private final SpriteIdentifier sidesTexture;
private final SpriteIdentifier backTexture;
public PlaneModel(Identifier frontTexture, Identifier sidesTexture, Identifier backTexture) {
this.frontTexture = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, frontTexture);
this.sidesTexture = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, sidesTexture);
this.backTexture = new Material(SpriteAtlasTexture.BLOCK_ATLAS_TEX, backTexture);
this.frontTexture = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, frontTexture);
this.sidesTexture = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, sidesTexture);
this.backTexture = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, backTexture);
}
@Override
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, Sprite> spriteGetter, IModelTransform modelTransform,
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
ModelOverrideList overrides, Identifier modelLocation) {
Sprite frontSprite = spriteGetter.apply(this.frontTexture);
Sprite sidesSprite = spriteGetter.apply(this.sidesTexture);
@@ -64,8 +64,8 @@ public class PlaneModel implements IModelGeometry<PlaneModel> {
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Arrays.asList(frontTexture, sidesTexture, backTexture);
}
@@ -177,7 +177,7 @@ public class ConversionMonitorPart extends AbstractMonitorPart {
final IAEItemStack input = AEItemStack.fromItemStack(player.getStackInHand(hand));
final IAEItemStack failedToInsert = Platform.poweredInsert(energy, cell, input,
new PlayerSource(player, this));
player.setHeldItem(hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack());
player.setStackInHand(hand, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack());
}
} catch (final GridAccessException e) {
// :P
@@ -33,6 +33,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.ClickEvent;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
@@ -190,8 +191,9 @@ public class TestMeteoritesCommand implements ISubCommand {
String displayText = String.format(Locale.ROOT, "pos=%d,%d,%d", tpPos.getX(), tpPos.getY(), tpPos.getZ());
String tpCommand = String.format(Locale.ROOT, "/tp @s %d %d %d", tpPos.getX(), tpPos.getY(), tpPos.getZ());
return new LiteralText(displayText).formatted(Formatting.UNDERLINE)
.formatted(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, tpCommand)));
return new LiteralText(displayText)
.formatted(Formatting.UNDERLINE)
.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, tpCommand)));
}
private static MeteoriteStructurePiece getMeteoritePieceFromChunk(Chunk chunk) {
@@ -284,7 +284,7 @@ public class CachedPlane {
final BlockPos pos = new BlockPos(x, y, z);
// attempt recovery...
c.c.addTileEntity(te);
c.c.addBlockEntity(te);
this.world.updateListeners(pos, this.world.getBlockState(pos), this.world.getBlockState(pos), z);
}
@@ -1,56 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.spatial;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
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.setWorldAndPos(w, newPosition);
final Chunk c = w.getChunkAt(newPosition);
c.addTileEntity(newPosition, te);
if (w.getChunkManager().isChunkLoaded(c.getPos())) {
final BlockState state = w.getBlockState(newPosition);
w.addTileEntity(te);
w.updateListeners(newPosition, state, state, 1);
}
}
}
@@ -201,7 +201,7 @@ public class Quad implements IVertexProducer, ISmartVertexConsumer {
vertex.normal[3] = 0;
}
}
this.orientation = Direction.getFacingFromVector(this.normal.getX(), this.normal.getY(), this.normal.getZ());
this.orientation = Direction.getFacing(this.normal.getX(), this.normal.getY(), this.normal.getZ());
}
/**
@@ -121,7 +121,7 @@ public class QuadCornerKicker extends QuadTransformer {
float z = vertex.vec[2];
if (epsComp(x, corner.pX(this.box)) && epsComp(y, corner.pY(this.box))
&& epsComp(z, corner.pZ(this.box))) {
Vec3i vec = Direction.values()[hoz].getDirectionVec();
Vec3i vec = Direction.values()[hoz].getVector();
x -= vec.getX() * this.thickness;
y -= vec.getY() * this.thickness;
z -= vec.getZ() * this.thickness;
@@ -18,8 +18,8 @@
package appeng.thirdparty.codechicken.lib.model.pipeline.transformers;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.client.renderer.Vector4f;
import net.minecraft.util.math.Direction;
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
@@ -36,7 +36,7 @@ public class QuadMatrixTransformer extends QuadTransformer {
static {
identity = new Matrix4f();
identity.setIdentity();
identity.loadIdentity();
}
private final Vector4f storage = new Vector4f();
@@ -78,7 +78,7 @@ public class QuadMatrixTransformer extends QuadTransformer {
vertex.normal[2] = storage.getZ();
}
Quad.Vertex v0 = quad.vertices[0];
quad.orientation = Direction.getFacingFromVector(v0.normal[0], v0.normal[1], v0.normal[2]);
quad.orientation = Direction.getFacing(v0.normal[0], v0.normal[1], v0.normal[2]);
return true;
}
}
@@ -35,8 +35,6 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraftforge.common.util.Constants;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.IPowerChannelState;
@@ -101,7 +101,7 @@ public class MolecularAssemblerRenderer extends BlockEntityRenderer<MolecularAss
BakedModel lightsModel = minecraft.getModelManager().getModel(LIGHTS_MODEL);
VertexConsumer buffer = bufferIn.getBuffer(MC_161917_RENDERTYPE_FIX);
minecraft.getBlockRenderManager().getBlockModelRenderer().renderModel(ms.getLast(), buffer, null,
minecraft.getBlockRenderManager().getModelRenderer().render(ms.peek(), buffer, null,
lightsModel, 1, 1, 1, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE);
}