Moving
This commit is contained in:
@@ -1,134 +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.minecraft.block.*;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
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.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 appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.LightDetectorBlockEntity;
|
||||
|
||||
public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity> implements IOrientableBlock {
|
||||
|
||||
// Used to alternate between two variants of the fixture on adjacent blocks
|
||||
public static final BooleanProperty ODD = BooleanProperty.of("odd");
|
||||
|
||||
public LightDetectorBlock() {
|
||||
super(defaultProps(Material.SUPPORTED));
|
||||
this.setDefaultState(this.getDefaultState().with(Properties.FACING, Direction.UP).with(ODD, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(Properties.FACING);
|
||||
builder.add(ODD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeakRedstonePower(final BlockState state, final BlockView w, final BlockPos pos, final Direction side) {
|
||||
if (w instanceof World && this.getBlockEntity(w, pos).isReady()) {
|
||||
// FIXME: This is ... uhm... fishy
|
||||
return ((World) w).getLightLevel(pos) - 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsRedstonePower(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
final Direction up = this.getOrientable(world, pos).getUp();
|
||||
if (!this.canPlaceAt(world, pos, up.getOpposite())) {
|
||||
// FIXME: Double check that this actually updates neighbors
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
final LightDetectorBlockEntity tld = this.getBlockEntity(world, pos);
|
||||
if (tld != null) {
|
||||
tld.updateLight();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
return this.canPlaceAt(w, pos, up.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canPlaceAt(final BlockView 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 w, BlockPos pos, ShapeContext context) {
|
||||
|
||||
// FIXME: We should / rather MUST use state here because at startup, this gets
|
||||
// called without a world
|
||||
|
||||
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();
|
||||
return VoxelShapes
|
||||
.cuboid(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView worldIn, BlockPos pos,
|
||||
ShapeContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@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, Properties.FACING);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,158 +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.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Box;
|
||||
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 appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.misc.SkyCompassBlockEntity;
|
||||
|
||||
public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
|
||||
|
||||
public SkyCompassBlock(Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
final SkyCompassBlockEntity sc = this.getBlockEntity(w, pos);
|
||||
if (sc != null) {
|
||||
return false;
|
||||
}
|
||||
return this.canPlaceAt(w, pos, forward.getOpposite());
|
||||
}
|
||||
|
||||
private boolean canPlaceAt(final BlockView 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 void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final SkyCompassBlockEntity sc = this.getBlockEntity(world, pos);
|
||||
final Direction forward = sc.getForward();
|
||||
if (!this.canPlaceAt(world, pos, forward.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 VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
|
||||
// TODO: This definitely needs to be memoized
|
||||
|
||||
final SkyCompassBlockEntity tile = this.getBlockEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final Direction forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 14.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 2.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 14.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 2.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 2.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 14.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VoxelShapes.cuboid(new Box(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView worldIn, BlockPos pos,
|
||||
ShapeContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,10 +21,10 @@ package appeng.block.networking;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -34,11 +34,11 @@ import appeng.tile.networking.ControllerBlockEntity;
|
||||
|
||||
public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
|
||||
|
||||
public enum ControllerBlockState implements IStringSerializable {
|
||||
public enum ControllerBlockState implements StringIdentifiable {
|
||||
offline, online, conflicted;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
|
||||
* enclosed by other controllers, and since they are always offline, they do not
|
||||
* have the usual sub-states.
|
||||
*/
|
||||
public enum ControllerRenderType implements IStringSerializable {
|
||||
public enum ControllerRenderType implements StringIdentifiable {
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ package appeng.block.networking;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
@@ -46,11 +46,11 @@ import appeng.util.Platform;
|
||||
|
||||
public class WirelessBlock extends AEBaseTileBlock<WirelessBlockEntity> {
|
||||
|
||||
enum State implements IStringSerializable {
|
||||
enum State implements StringIdentifiable {
|
||||
OFF, ON, HAS_CHANNEL;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
/**
|
||||
* Describes the type of cell present in a slot.
|
||||
*/
|
||||
public enum DriveSlotCellType implements IStringSerializable {
|
||||
public enum DriveSlotCellType implements StringIdentifiable {
|
||||
|
||||
EMPTY("empty"),
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum DriveSlotCellType implements IStringSerializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
import appeng.api.storage.cells.CellState;
|
||||
|
||||
@@ -26,7 +26,7 @@ import appeng.api.storage.cells.CellState;
|
||||
* Describes the different states a single slot of a BlockDrive can be in in
|
||||
* terms of rendering.
|
||||
*/
|
||||
public enum DriveSlotState implements IStringSerializable {
|
||||
public enum DriveSlotState implements StringIdentifiable {
|
||||
|
||||
// No cell in slot
|
||||
EMPTY("empty"),
|
||||
@@ -50,7 +50,7 @@ public enum DriveSlotState implements IStringSerializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ import net.minecraft.client.renderer.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.IStringSerializable;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
/**
|
||||
* TODO: Removed useless stuff.
|
||||
*/
|
||||
public enum FacingToRotation implements IStringSerializable {
|
||||
public enum FacingToRotation implements StringIdentifiable {
|
||||
|
||||
// DUNSWE
|
||||
// @formatter:off
|
||||
@@ -110,7 +110,7 @@ public enum FacingToRotation implements IStringSerializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String asString() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +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.effects;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.RedstoneParticle;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ChargedOreFX extends RedstoneParticle {
|
||||
|
||||
private static final RedstoneParticleData PARTICLE_DATA = new RedstoneParticleData(0.21f, 0.61f, 1.0f, 1.0f);
|
||||
|
||||
private ChargedOreFX(World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed,
|
||||
IAnimatedSprite spriteSet) {
|
||||
super(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, PARTICLE_DATA, spriteSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(final float par1) {
|
||||
int j1 = super.getBrightnessForRender(par1);
|
||||
j1 = Math.max(j1 >> 20, j1 >> 4);
|
||||
j1 += 3;
|
||||
if (j1 > 15) {
|
||||
j1 = 15;
|
||||
}
|
||||
return j1 << 20 | j1 << 4;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<DefaultParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite p_i50477_1_) {
|
||||
this.spriteSet = p_i50477_1_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new ChargedOreFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,143 +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.effects;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class CraftingFx extends SpriteBillboardParticle {
|
||||
|
||||
// Offset relative to center of block, is the starting point of the particle
|
||||
// movement
|
||||
private final float offsetX;
|
||||
private final float offsetY;
|
||||
private final float offsetZ;
|
||||
|
||||
public CraftingFx(final World par1World, final double x, final double y, final double z,
|
||||
final IAnimatedSprite sprite) {
|
||||
super(par1World, x, y, z);
|
||||
|
||||
// Pick a random normal, offset it by 0.35 and use that as the particle origin
|
||||
Vector3f off = new Vector3f(rand.nextFloat() - 0.5f, rand.nextFloat() - 0.5f, rand.nextFloat() - 0.5f);
|
||||
off.normalize();
|
||||
off.mul(0.35f);
|
||||
offsetX = off.getX();
|
||||
offsetY = off.getY();
|
||||
offsetZ = off.getZ();
|
||||
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 0.9f;
|
||||
this.particleRed = 1;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
this.maxAge /= 1.2;
|
||||
this.canCollide = false; // we're INSIDE the block anyway
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
|
||||
float f = (this.age + partialTicks) / this.maxAge;
|
||||
|
||||
float offX = (float) posX + MathHelper.lerp(f, offsetX, 0);
|
||||
float offY = (float) posY + MathHelper.lerp(f, offsetY, 0);
|
||||
float offZ = (float) posZ + MathHelper.lerp(f, offsetZ, 0);
|
||||
float alpha = MathHelper.lerp(easeOutCirc(f), 1.3f, 0.1f);
|
||||
float scale = MathHelper.lerp(easeOutCirc(f), 0.13f, 0.0f);
|
||||
|
||||
// I believe this particle is same as breaking particle, but should not exit the
|
||||
// original block it was
|
||||
// spawned in (which is encased in glass)
|
||||
Vec3d vec3d = renderInfo.getProjectedView();
|
||||
offX -= vec3d.x;
|
||||
offY -= vec3d.y;
|
||||
offZ -= vec3d.z;
|
||||
|
||||
Vector3f[] avector3f = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F),
|
||||
new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F) };
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
Vector3f vector3f = avector3f[i];
|
||||
vector3f.transform(renderInfo.getRotation());
|
||||
vector3f.mul(scale);
|
||||
vector3f.add(offX, offY, offZ);
|
||||
}
|
||||
|
||||
float minU = this.getMinU();
|
||||
float maxU = this.getMaxU();
|
||||
float minV = this.getMinV();
|
||||
float maxV = this.getMaxV();
|
||||
int j = 15728880; // full brightness
|
||||
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV)
|
||||
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV)
|
||||
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV)
|
||||
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
|
||||
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV)
|
||||
.color(this.particleRed, this.particleGreen, this.particleBlue, alpha).lightmap(j).endVertex();
|
||||
}
|
||||
|
||||
// https://easings.net/#easeOutCirc
|
||||
private static float easeOutCirc(float x) {
|
||||
return (float) Math.sqrt(1 - Math.pow(x - 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.age++ >= this.maxAge) {
|
||||
this.setExpired();
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<DefaultParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite p_i50477_1_) {
|
||||
this.spriteSet = p_i50477_1_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(DefaultParticleType data, World worldIn, double x, double y, double z, double xSpeed,
|
||||
double ySpeed, double zSpeed) {
|
||||
return new CraftingFx(worldIn, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,124 +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.effects;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EnergyFx extends SpriteBillboardParticle {
|
||||
|
||||
private final int startBlkX;
|
||||
private final int startBlkY;
|
||||
private final int startBlkZ;
|
||||
|
||||
public EnergyFx(final World par1World, final double par2, final double par4, final double par6,
|
||||
final IAnimatedSprite sprite) {
|
||||
super(par1World, par2, par4, par6);
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 1;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.4f;
|
||||
this.particleScale = 3.5f;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
|
||||
this.startBlkX = MathHelper.floor(this.posX);
|
||||
this.startBlkY = MathHelper.floor(this.posY);
|
||||
this.startBlkZ = MathHelper.floor(this.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScale(float scaleFactor) {
|
||||
return 0.1f * this.particleScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
float x = (float) (this.prevX + (this.posX - this.prevX) * partialTicks);
|
||||
float y = (float) (this.prevY + (this.posY - this.prevY) * partialTicks);
|
||||
float z = (float) (this.prevZ + (this.posZ - this.prevZ) * partialTicks);
|
||||
|
||||
final int blkX = MathHelper.floor(x);
|
||||
final int blkY = MathHelper.floor(y);
|
||||
final int blkZ = MathHelper.floor(z);
|
||||
|
||||
if (blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ) {
|
||||
super.renderParticle(buffer, renderInfo, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
this.onGround = false;
|
||||
|
||||
this.particleScale *= 0.89f;
|
||||
this.particleAlpha *= 0.89f;
|
||||
}
|
||||
|
||||
public void setMotionX(float motionX) {
|
||||
this.motionX = motionX;
|
||||
}
|
||||
|
||||
public void setMotionY(float motionY) {
|
||||
this.motionY = motionY;
|
||||
}
|
||||
|
||||
public void setMotionZ(float motionZ) {
|
||||
this.motionZ = motionZ;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<EnergyParticleData> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(EnergyParticleData data, World worldIn, double x, double y, double z,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet);
|
||||
result.setMotionX((float) xSpeed);
|
||||
result.setMotionY((float) ySpeed);
|
||||
result.setMotionZ((float) zSpeed);
|
||||
if (data.forItem) {
|
||||
result.posX += -0.2 * data.direction.xOffset;
|
||||
result.posY += -0.2 * data.direction.yOffset;
|
||||
result.posZ += -0.2 * data.direction.zOffset;
|
||||
result.particleScale *= 0.8f;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +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.effects;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
public class EnergyParticleData implements ParticleEffect {
|
||||
|
||||
public static final EnergyParticleData FOR_BLOCK = new EnergyParticleData(false, AEPartLocation.INTERNAL);
|
||||
|
||||
public final boolean forItem;
|
||||
|
||||
public final AEPartLocation direction;
|
||||
|
||||
public EnergyParticleData(boolean forItem, AEPartLocation direction) {
|
||||
this.forItem = forItem;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public static final Factory<EnergyParticleData> DESERIALIZER = new Factory<EnergyParticleData>() {
|
||||
@Override
|
||||
public EnergyParticleData read(ParticleType<EnergyParticleData> particleTypeIn, StringReader reader)
|
||||
throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
boolean forItem = reader.readBoolean();
|
||||
reader.expect(' ');
|
||||
AEPartLocation direction = AEPartLocation.valueOf(reader.readString().toUpperCase());
|
||||
return new EnergyParticleData(forItem, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyParticleData read(ParticleType<EnergyParticleData> particleTypeIn, PacketByteBuf buffer) {
|
||||
boolean forItem = buffer.readBoolean();
|
||||
AEPartLocation direction = AEPartLocation.values()[buffer.readByte()];
|
||||
return new EnergyParticleData(forItem, direction);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return ParticleTypes.ENERGY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buffer) {
|
||||
buffer.writeBoolean(forItem);
|
||||
buffer.writeByte((byte) direction.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return String.format(Locale.ROOT, "%s %s", forItem ? "true" : "false", direction.name().toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.client.render.effects;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class LightningArcFX extends LightningFX {
|
||||
|
||||
private static final Random RANDOM_GENERATOR = new Random();
|
||||
|
||||
private final double rx;
|
||||
private final double ry;
|
||||
private final double rz;
|
||||
|
||||
public LightningArcFX(final World w, final double x, final double y, final double z, final double ex,
|
||||
final double ey, final double ez, final double r, final double g, final double b) {
|
||||
super(w, x, y, z, r, g, b, 6);
|
||||
|
||||
this.rx = ex - x;
|
||||
this.ry = ey - y;
|
||||
this.rz = ez - z;
|
||||
|
||||
this.regen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void regen() {
|
||||
final double i = 1.0 / (this.getSteps() - 1);
|
||||
final double lastDirectionX = this.rx * i;
|
||||
final double lastDirectionY = this.ry * i;
|
||||
final double lastDirectionZ = this.rz * i;
|
||||
|
||||
final double len = Math.sqrt(
|
||||
lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ);
|
||||
for (int s = 0; s < this.getSteps(); s++) {
|
||||
final double[][] localSteps = this.getPrecomputedSteps();
|
||||
|
||||
localSteps[s][0] = (lastDirectionX + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
localSteps[s][1] = (lastDirectionY + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
localSteps[s][2] = (lastDirectionZ + (RANDOM_GENERATOR.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<LightningArcParticleData> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
SpriteBillboardParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y,
|
||||
data.target.z, 0, 0, 0);
|
||||
lightningFX.selectSpriteRandomly(this.spriteSet);
|
||||
return lightningFX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
* Contains the target point of the lightning arc (the source point is infered
|
||||
* from the particle starting position).
|
||||
*/
|
||||
public class LightningArcParticleData implements ParticleEffect {
|
||||
|
||||
public final Vec3d target;
|
||||
|
||||
public LightningArcParticleData(Vec3d target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public static final Factory<LightningArcParticleData> DESERIALIZER = new Factory<LightningArcParticleData>() {
|
||||
@Override
|
||||
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn,
|
||||
StringReader reader) throws CommandSyntaxException {
|
||||
reader.expect(' ');
|
||||
float x = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float y = reader.readFloat();
|
||||
reader.expect(' ');
|
||||
float z = reader.readFloat();
|
||||
return new LightningArcParticleData(new Vec3d(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn,
|
||||
PacketByteBuf buffer) {
|
||||
float x = buffer.readFloat();
|
||||
float y = buffer.readFloat();
|
||||
float z = buffer.readFloat();
|
||||
return new LightningArcParticleData(new Vec3d(x, y, z));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return ParticleTypes.LIGHTNING_ARC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buffer) {
|
||||
buffer.writeFloat((float) target.x);
|
||||
buffer.writeFloat((float) target.y);
|
||||
buffer.writeFloat((float) target.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return String.format(Locale.ROOT, "%.2f %.2f %.2f", target.x, target.y, target.z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,264 +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.effects;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class LightningFX extends SpriteBillboardParticle {
|
||||
|
||||
private static final Random RANDOM_GENERATOR = new Random();
|
||||
private static final int STEPS = 5;
|
||||
private static final int BRIGHTNESS = 13 << 4;
|
||||
|
||||
private final double[][] precomputedSteps;
|
||||
private final double[] vertices = new double[3];
|
||||
private final double[] verticesWithUV = new double[3];
|
||||
private boolean hasData = false;
|
||||
|
||||
private LightningFX(final World w, final double x, final double y, final double z, final double r, final double g,
|
||||
final double b) {
|
||||
this(w, x, y, z, r, g, b, 6);
|
||||
this.regen();
|
||||
}
|
||||
|
||||
protected LightningFX(final World w, final double x, final double y, final double z, final double r, final double g,
|
||||
final double b, final int maxAge) {
|
||||
super(w, x, y, z, r, g, b);
|
||||
this.precomputedSteps = new double[LightningFX.STEPS][3];
|
||||
this.motionX = 0;
|
||||
this.motionY = 0;
|
||||
this.motionZ = 0;
|
||||
this.maxAge = maxAge;
|
||||
}
|
||||
|
||||
protected void regen() {
|
||||
double lastDirectionX = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
|
||||
double lastDirectionY = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
|
||||
double lastDirectionZ = (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9;
|
||||
for (int s = 0; s < LightningFX.STEPS; s++) {
|
||||
this.precomputedSteps[s][0] = lastDirectionX = (lastDirectionX
|
||||
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
this.precomputedSteps[s][1] = lastDirectionY = (lastDirectionY
|
||||
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
this.precomputedSteps[s][2] = lastDirectionZ = (lastDirectionZ
|
||||
+ (RANDOM_GENERATOR.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getSteps() {
|
||||
return LightningFX.STEPS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// TODO: FIXME
|
||||
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
|
||||
if (this.age++ >= this.maxAge) {
|
||||
this.setExpired();
|
||||
}
|
||||
|
||||
this.motionY -= 0.04D * this.particleGravity;
|
||||
this.move(this.motionX, this.motionY, this.motionZ);
|
||||
this.motionX *= 0.9800000190734863D;
|
||||
this.motionY *= 0.9800000190734863D;
|
||||
this.motionZ *= 0.9800000190734863D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
|
||||
Vec3d vec3d = renderInfo.getProjectedView();
|
||||
float centerX = (float) (MathHelper.lerp(partialTicks, this.prevX, this.posX) - vec3d.getX());
|
||||
float centerY = (float) (MathHelper.lerp(partialTicks, this.prevY, this.posY) - vec3d.getY());
|
||||
float centerZ = (float) (MathHelper.lerp(partialTicks, this.prevZ, this.posZ) - vec3d.getZ());
|
||||
|
||||
final float j = 1.0f;
|
||||
float red = this.particleRed * j * 0.9f;
|
||||
float green = this.particleGreen * j * 0.95f;
|
||||
float blue = this.particleBlue * j;
|
||||
final float alpha = this.particleAlpha;
|
||||
|
||||
if (this.age == 3) {
|
||||
this.regen();
|
||||
}
|
||||
|
||||
float u = this.getMinU() + (this.getMaxU() - this.getMinU()) / 2;
|
||||
float v = this.getMinV() + (this.getMaxV() - this.getMinV()) / 2;
|
||||
|
||||
double scale = 0.02;// 0.02F * this.particleScale;
|
||||
|
||||
final double[] a = new double[3];
|
||||
final double[] b = new double[3];
|
||||
|
||||
double ox = 0;
|
||||
double oy = 0;
|
||||
double oz = 0;
|
||||
|
||||
final PlayerEntity p = MinecraftClient.getInstance().player;
|
||||
|
||||
// FIXME: Billboard rotation is not applied to the particle yet,
|
||||
// FIXME The old version apparently did this by hand using rX,rZ -> replicate
|
||||
// using the quaternion
|
||||
|
||||
for (int layer = 0; layer < 2; layer++) {
|
||||
if (layer == 0) {
|
||||
scale = 0.04;
|
||||
// FIXME offX *= 0.001;
|
||||
// FIXME offY *= 0.001;
|
||||
// FIXME offZ *= 0.001;
|
||||
red = this.particleRed * j * 0.4f;
|
||||
green = this.particleGreen * j * 0.25f;
|
||||
blue = this.particleBlue * j * 0.45f;
|
||||
} else {
|
||||
// FIXME offX = 0;
|
||||
// FIXME offY = 0;
|
||||
// FIXME offZ = 0;
|
||||
scale = 0.02;
|
||||
red = this.particleRed * j * 0.9f;
|
||||
green = this.particleGreen * j * 0.65f;
|
||||
blue = this.particleBlue * j * 0.85f;
|
||||
}
|
||||
|
||||
for (int cycle = 0; cycle < 3; cycle++) {
|
||||
this.clear();
|
||||
|
||||
// FIXME removed interpPos here, check if this is correct
|
||||
double x = centerX; // FIXME - offX;
|
||||
double y = centerY; // FIXME - offY;
|
||||
double z = centerZ; // FIXME - offZ;
|
||||
|
||||
for (int s = 0; s < LightningFX.STEPS; s++) {
|
||||
final double xN = x + this.precomputedSteps[s][0];
|
||||
final double yN = y + this.precomputedSteps[s][1];
|
||||
final double zN = z + this.precomputedSteps[s][2];
|
||||
|
||||
final double xD = xN - x;
|
||||
final double yD = yN - y;
|
||||
final double zD = zN - z;
|
||||
|
||||
if (cycle == 0) {
|
||||
ox = (yD * 0) - (1 * zD);
|
||||
oy = (zD * 0) - (0 * xD);
|
||||
oz = (xD * 1) - (0 * yD);
|
||||
}
|
||||
if (cycle == 1) {
|
||||
ox = (yD * 1) - (0 * zD);
|
||||
oy = (zD * 0) - (1 * xD);
|
||||
oz = (xD * 0) - (0 * yD);
|
||||
}
|
||||
if (cycle == 2) {
|
||||
ox = (yD * 0) - (0 * zD);
|
||||
oy = (zD * 1) - (0 * xD);
|
||||
oz = (xD * 0) - (1 * yD);
|
||||
}
|
||||
|
||||
final double ss = Math.sqrt(ox * ox + oy * oy + oz * oz)
|
||||
/ ((((double) LightningFX.STEPS - (double) s) / LightningFX.STEPS) * scale);
|
||||
ox /= ss;
|
||||
oy /= ss;
|
||||
oz /= ss;
|
||||
|
||||
a[0] = x + ox;
|
||||
a[1] = y + oy;
|
||||
a[2] = z + oz;
|
||||
|
||||
b[0] = x;
|
||||
b[1] = y;
|
||||
b[2] = z;
|
||||
|
||||
this.draw(red, green, blue, buffer, a, b, u, v);
|
||||
|
||||
x = xN;
|
||||
y = yN;
|
||||
z = zN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
this.hasData = false;
|
||||
}
|
||||
|
||||
private void draw(float red, float green, float blue, final IVertexBuilder tess, final double[] a, final double[] b,
|
||||
final float u, final float v) {
|
||||
if (this.hasData) {
|
||||
tess.pos(a[0], a[1], a[2]).tex(u, v).color(red, green, blue, this.particleAlpha)
|
||||
.lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
|
||||
tess.pos(this.vertices[0], this.vertices[1], this.vertices[2]).tex(u, v)
|
||||
.color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
|
||||
tess.pos(this.verticesWithUV[0], this.verticesWithUV[1], this.verticesWithUV[2]).tex(u, v)
|
||||
.color(red, green, blue, this.particleAlpha).lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
|
||||
tess.pos(b[0], b[1], b[2]).tex(u, v).color(red, green, blue, this.particleAlpha)
|
||||
.lightmap(BRIGHTNESS, BRIGHTNESS).endVertex();
|
||||
}
|
||||
this.hasData = true;
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.vertices[x] = a[x];
|
||||
this.verticesWithUV[x] = b[x];
|
||||
}
|
||||
}
|
||||
|
||||
protected double[][] getPrecomputedSteps() {
|
||||
return this.precomputedSteps;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<DefaultParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
LightningFX lightningFX = new LightningFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed);
|
||||
lightningFX.selectSpriteRandomly(this.spriteSet);
|
||||
return lightningFX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +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.effects;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
public class MatterCannonFX extends SpriteBillboardParticle {
|
||||
|
||||
public MatterCannonFX(final World par1World, final double x, final double y, final double z,
|
||||
IAnimatedSprite sprite) {
|
||||
super(par1World, x, y, z);
|
||||
this.particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 1;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.4f;
|
||||
this.particleScale = 1.1f;
|
||||
this.motionX = 0.0f;
|
||||
this.motionY = 0.0f;
|
||||
this.motionZ = 0.0f;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
}
|
||||
|
||||
public void fromItem(final AEPartLocation d) {
|
||||
this.particleScale *= 1.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
|
||||
if (this.age++ >= this.maxAge) {
|
||||
this.setExpired();
|
||||
}
|
||||
|
||||
this.motionY -= 0.04D * this.particleGravity;
|
||||
this.move(this.motionX, this.motionY, this.motionZ);
|
||||
this.motionX *= 0.9800000190734863D;
|
||||
this.motionY *= 0.9800000190734863D;
|
||||
this.motionZ *= 0.9800000190734863D;
|
||||
|
||||
this.particleScale *= 1.19f;
|
||||
this.particleAlpha *= 0.59f;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<DefaultParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(DefaultParticleType data, World world, double x, double y, double z, double xSpeed,
|
||||
double ySpeed, double zSpeed) {
|
||||
return new MatterCannonFX(world, x, y, z, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public final class ParticleTypes {
|
||||
|
||||
private ParticleTypes() {
|
||||
}
|
||||
|
||||
public static final DefaultParticleType CHARGED_ORE = FabricParticleTypes.simple(false);
|
||||
public static final DefaultParticleType CRAFTING = FabricParticleTypes.simple(false);
|
||||
public static final ParticleType<EnergyParticleData> ENERGY = FabricParticleTypes.complex(false,
|
||||
EnergyParticleData.DESERIALIZER);
|
||||
public static final ParticleType<LightningArcParticleData> LIGHTNING_ARC = FabricParticleTypes.complex(false,
|
||||
LightningArcParticleData.DESERIALIZER);
|
||||
public static final DefaultParticleType LIGHTNING = FabricParticleTypes.simple(false);
|
||||
public static final DefaultParticleType MATTER_CANNON = FabricParticleTypes.simple(false);
|
||||
public static final DefaultParticleType VIBRANT = FabricParticleTypes.simple(false);
|
||||
|
||||
static {
|
||||
CHARGED_ORE.setRegistryName(AppEng.MOD_ID, "charged_ore_fx");
|
||||
CRAFTING.setRegistryName(AppEng.MOD_ID, "crafting_fx");
|
||||
ENERGY.setRegistryName(AppEng.MOD_ID, "energy_fx");
|
||||
LIGHTNING_ARC.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
|
||||
LIGHTNING.setRegistryName(AppEng.MOD_ID, "lightning_fx");
|
||||
MATTER_CANNON.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
|
||||
VIBRANT.setRegistryName(AppEng.MOD_ID, "vibrant_fx");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +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.effects;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class VibrantFX extends SpriteBillboardParticle {
|
||||
|
||||
public VibrantFX(final World par1World, final double x, final double y, final double z, final double par8,
|
||||
final double par10, final double par12, IAnimatedSprite sprite) {
|
||||
super(par1World, x, y, z, par8, par10, par12);
|
||||
final float f = this.rand.nextFloat() * 0.1F + 0.8F;
|
||||
this.particleRed = f * 0.7f;
|
||||
this.particleGreen = f * 0.89f;
|
||||
this.particleBlue = f * 0.9f;
|
||||
this.selectSpriteRandomly(sprite);
|
||||
this.setSize(0.04F, 0.04F);
|
||||
this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F;
|
||||
this.motionX = 0.0D;
|
||||
this.motionY = 0.0D;
|
||||
this.motionZ = 0.0D;
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
this.maxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
// FIXME Might be PARTICLE_SHEET_LIT
|
||||
return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(final float par1) {
|
||||
// This just means full brightness
|
||||
return 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void tick() {
|
||||
this.prevX = this.posX;
|
||||
this.prevY = this.posY;
|
||||
this.prevZ = this.posZ;
|
||||
// this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
this.particleScale *= 0.95;
|
||||
|
||||
if (this.maxAge <= 0 || this.particleScale < 0.1) {
|
||||
this.setExpired();
|
||||
}
|
||||
this.maxAge--;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements IParticleFactory<DefaultParticleType> {
|
||||
private final IAnimatedSprite spriteSet;
|
||||
|
||||
public Factory(IAnimatedSprite spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle makeParticle(DefaultParticleType typeIn, World worldIn, double x, double y, double z,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new VibrantFX(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,594 +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 java.util.*;
|
||||
import java.util.function.DoubleSupplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.EnumValue;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.util.EnumCycler;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = AppEng.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class AEConfig {
|
||||
|
||||
public static final ClientConfig CLIENT;
|
||||
public static final ForgeConfigSpec CLIENT_SPEC;
|
||||
public static final CommonConfig COMMON;
|
||||
public static final ForgeConfigSpec COMMON_SPEC;
|
||||
|
||||
// Default Energy Conversion Rates
|
||||
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
|
||||
private static final double DEFAULT_RF_EXCHANGE = 0.5;
|
||||
|
||||
static {
|
||||
final Pair<ClientConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
|
||||
CLIENT_SPEC = specPair.getRight();
|
||||
CLIENT = specPair.getLeft();
|
||||
|
||||
final Pair<CommonConfig, ForgeConfigSpec> commonPair = new ForgeConfigSpec.Builder()
|
||||
.configure(CommonConfig::new);
|
||||
COMMON_SPEC = commonPair.getRight();
|
||||
COMMON = commonPair.getLeft();
|
||||
}
|
||||
|
||||
public static final String VERSION = "@version@";
|
||||
public static final String CHANNEL = "@aechannel@";
|
||||
|
||||
// Config instance
|
||||
private static final AEConfig instance = new AEConfig();
|
||||
|
||||
private final EnumSet<AEFeature> featureFlags = EnumSet.noneOf(AEFeature.class);
|
||||
|
||||
// Misc
|
||||
private boolean removeCrashingItemsOnLoad;
|
||||
private int formationPlaneEntityLimit;
|
||||
private boolean enableEffects;
|
||||
private boolean useLargeFonts;
|
||||
private boolean useColoredCraftingStatus;
|
||||
private boolean disableColoredCableRecipesInJEI;
|
||||
private int craftingCalculationTimePerTick;
|
||||
private PowerUnits selectedPowerUnit;
|
||||
|
||||
// GUI Buttons
|
||||
private final int[] craftByStacks = new int[4];
|
||||
private final int[] priorityByStacks = new int[4];
|
||||
private final int[] levelByStacks = new int[4];
|
||||
private final int[] levelByMillibuckets = { 10, 100, 1000, 10000 };
|
||||
|
||||
// Spatial IO/Dimension
|
||||
private double spatialPowerExponent;
|
||||
private double spatialPowerMultiplier;
|
||||
|
||||
// Grindstone
|
||||
private float oreDoublePercentage;
|
||||
|
||||
// Batteries
|
||||
private int wirelessTerminalBattery;
|
||||
private int entropyManipulatorBattery;
|
||||
private int matterCannonBattery;
|
||||
private int portableCellBattery;
|
||||
private int colorApplicatorBattery;
|
||||
private int chargedStaffBattery;
|
||||
|
||||
// Meteors
|
||||
private int meteoriteMaximumSpawnHeight;
|
||||
private Set<String> meteoriteDimensionWhitelist;
|
||||
|
||||
// Wireless
|
||||
private double wirelessBaseCost;
|
||||
private double wirelessCostMultiplier;
|
||||
private double wirelessTerminalDrainMultiplier;
|
||||
private double wirelessBaseRange;
|
||||
private double wirelessBoosterRangeMultiplier;
|
||||
private double wirelessBoosterExp;
|
||||
private double wirelessHighWirelessCount;
|
||||
|
||||
// Tunnels
|
||||
public static final double TUNNEL_POWER_LOSS = 0.05;
|
||||
|
||||
// FIXME: this is shit, move this concern out of the config class
|
||||
@SubscribeEvent
|
||||
public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) {
|
||||
if (configEvent.getConfig().getSpec() == CLIENT_SPEC) {
|
||||
instance.syncClientConfig();
|
||||
} else if (configEvent.getConfig().getSpec() == COMMON_SPEC) {
|
||||
instance.syncCommonConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void syncClientConfig() {
|
||||
this.disableColoredCableRecipesInJEI = CLIENT.disableColoredCableRecipesInJEI.get();
|
||||
this.enableEffects = CLIENT.enableEffects.get();
|
||||
this.useLargeFonts = CLIENT.useLargeFonts.get();
|
||||
this.useColoredCraftingStatus = CLIENT.useColoredCraftingStatus.get();
|
||||
this.selectedPowerUnit = CLIENT.selectedPowerUnit.get();
|
||||
|
||||
// load buttons..
|
||||
for (int btnNum = 0; btnNum < 4; btnNum++) {
|
||||
this.craftByStacks[btnNum] = CLIENT.craftByStacks.get(btnNum).get();
|
||||
this.priorityByStacks[btnNum] = CLIENT.priorityByStacks.get(btnNum).get();
|
||||
this.levelByStacks[btnNum] = CLIENT.levelByStacks.get(btnNum).get();
|
||||
}
|
||||
}
|
||||
|
||||
private void syncCommonConfig() {
|
||||
PowerUnits.EU.conversionRatio = COMMON.powerRatioIc2.get();
|
||||
PowerUnits.RF.conversionRatio = COMMON.powerRatioForgeEnergy.get();
|
||||
PowerMultiplier.CONFIG.multiplier = COMMON.powerUsageMultiplier.get();
|
||||
|
||||
CondenserOutput.MATTER_BALLS.requiredPower = COMMON.condenserMatterBallsPower.get();
|
||||
CondenserOutput.SINGULARITY.requiredPower = COMMON.condenserSingularityPower.get();
|
||||
|
||||
this.oreDoublePercentage = COMMON.oreDoublePercentage.get().floatValue();
|
||||
|
||||
this.meteoriteMaximumSpawnHeight = COMMON.meteoriteMaximumSpawnHeight.get();
|
||||
this.meteoriteDimensionWhitelist = new HashSet<>(COMMON.meteoriteDimensionWhitelist.get());
|
||||
|
||||
this.wirelessBaseCost = COMMON.wirelessBaseCost.get();
|
||||
this.wirelessCostMultiplier = COMMON.wirelessCostMultiplier.get();
|
||||
this.wirelessBaseRange = COMMON.wirelessBaseRange.get();
|
||||
this.wirelessBoosterRangeMultiplier = COMMON.wirelessBoosterRangeMultiplier.get();
|
||||
this.wirelessBoosterExp = COMMON.wirelessBoosterExp.get();
|
||||
this.wirelessHighWirelessCount = COMMON.wirelessHighWirelessCount.get();
|
||||
this.wirelessTerminalDrainMultiplier = COMMON.wirelessTerminalDrainMultiplier.get();
|
||||
|
||||
this.formationPlaneEntityLimit = COMMON.formationPlaneEntityLimit.get();
|
||||
|
||||
this.wirelessTerminalBattery = COMMON.wirelessTerminalBattery.get();
|
||||
this.chargedStaffBattery = COMMON.chargedStaffBattery.get();
|
||||
this.entropyManipulatorBattery = COMMON.entropyManipulatorBattery.get();
|
||||
this.portableCellBattery = COMMON.portableCellBattery.get();
|
||||
this.colorApplicatorBattery = COMMON.colorApplicatorBattery.get();
|
||||
this.matterCannonBattery = COMMON.matterCannonBattery.get();
|
||||
|
||||
this.featureFlags.clear();
|
||||
for (final AEFeature feature : AEFeature.values()) {
|
||||
if (feature.isVisible()) {
|
||||
if (COMMON.enabledFeatures.containsKey(feature)) {
|
||||
this.featureFlags.add(feature);
|
||||
}
|
||||
} else {
|
||||
this.featureFlags.add(feature);
|
||||
}
|
||||
}
|
||||
|
||||
for (final TickRates tr : TickRates.values()) {
|
||||
tr.setMin(COMMON.tickRateMin.get(tr).get());
|
||||
tr.setMax(COMMON.tickRateMin.get(tr).get());
|
||||
}
|
||||
|
||||
this.spatialPowerMultiplier = COMMON.spatialPowerMultiplier.get();
|
||||
this.spatialPowerExponent = COMMON.spatialPowerExponent.get();
|
||||
|
||||
this.craftingCalculationTimePerTick = COMMON.craftingCalculationTimePerTick.get();
|
||||
|
||||
this.removeCrashingItemsOnLoad = COMMON.removeCrashingItemsOnLoad.get();
|
||||
}
|
||||
|
||||
public static AEConfig instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isFeatureEnabled(final AEFeature f) {
|
||||
return this.featureFlags.contains(f);
|
||||
}
|
||||
|
||||
public boolean areFeaturesEnabled(Collection<AEFeature> features) {
|
||||
return this.featureFlags.containsAll(features);
|
||||
}
|
||||
|
||||
public double wireless_getDrainRate(final double range) {
|
||||
return this.wirelessTerminalDrainMultiplier * range;
|
||||
}
|
||||
|
||||
public double wireless_getMaxRange(final int boosters) {
|
||||
return this.wirelessBaseRange
|
||||
+ this.wirelessBoosterRangeMultiplier * Math.pow(boosters, this.wirelessBoosterExp);
|
||||
}
|
||||
|
||||
public double wireless_getPowerDrain(final int boosters) {
|
||||
return this.wirelessBaseCost
|
||||
+ this.wirelessCostMultiplier * Math.pow(boosters, 1 + boosters / this.wirelessHighWirelessCount);
|
||||
}
|
||||
|
||||
public YesNo getSearchTooltips() {
|
||||
return CLIENT.searchTooltips.get();
|
||||
}
|
||||
|
||||
public TerminalStyle getTerminalStyle() {
|
||||
return CLIENT.terminalStyle.get();
|
||||
}
|
||||
|
||||
public void setTerminalStyle(TerminalStyle setting) {
|
||||
CLIENT.terminalStyle.set(setting);
|
||||
}
|
||||
|
||||
public SearchBoxMode getTerminalSearchMode() {
|
||||
return CLIENT.terminalSearchMode.get();
|
||||
}
|
||||
|
||||
public void setTerminalSearchMode(SearchBoxMode setting) {
|
||||
CLIENT.terminalSearchMode.set(setting);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (CLIENT_SPEC.isLoaded()) {
|
||||
CLIENT.selectedPowerUnit.set(this.selectedPowerUnit);
|
||||
CLIENT_SPEC.save();
|
||||
}
|
||||
|
||||
if (COMMON_SPEC.isLoaded()) {
|
||||
COMMON_SPEC.save();
|
||||
}
|
||||
}
|
||||
|
||||
public int craftItemsByStackAmounts(final int i) {
|
||||
return this.craftByStacks[i];
|
||||
}
|
||||
|
||||
public int priorityByStacksAmounts(final int i) {
|
||||
return this.priorityByStacks[i];
|
||||
}
|
||||
|
||||
public int levelByStackAmounts(final int i) {
|
||||
return this.levelByStacks[i];
|
||||
}
|
||||
|
||||
public int levelByMillyBuckets(final int i) {
|
||||
return this.levelByMillibuckets[i];
|
||||
}
|
||||
|
||||
public PowerUnits getSelectedPowerUnit() {
|
||||
return this.selectedPowerUnit;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void nextPowerUnit(final boolean backwards) {
|
||||
this.selectedPowerUnit = EnumCycler.rotateEnum(this.selectedPowerUnit, backwards,
|
||||
(EnumSet<PowerUnits>) Settings.POWER_UNITS.getPossibleValues());
|
||||
this.save();
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean isRemoveCrashingItemsOnLoad() {
|
||||
return this.removeCrashingItemsOnLoad;
|
||||
}
|
||||
|
||||
public int getFormationPlaneEntityLimit() {
|
||||
return this.formationPlaneEntityLimit;
|
||||
}
|
||||
|
||||
public boolean isEnableEffects() {
|
||||
return this.enableEffects;
|
||||
}
|
||||
|
||||
public boolean isUseLargeFonts() {
|
||||
return this.useLargeFonts;
|
||||
}
|
||||
|
||||
public boolean isUseColoredCraftingStatus() {
|
||||
return this.useColoredCraftingStatus;
|
||||
}
|
||||
|
||||
public boolean isDisableColoredCableRecipesInJEI() {
|
||||
return this.disableColoredCableRecipesInJEI;
|
||||
}
|
||||
|
||||
public int getCraftingCalculationTimePerTick() {
|
||||
return this.craftingCalculationTimePerTick;
|
||||
}
|
||||
|
||||
public double getSpatialPowerExponent() {
|
||||
return this.spatialPowerExponent;
|
||||
}
|
||||
|
||||
public double getSpatialPowerMultiplier() {
|
||||
return this.spatialPowerMultiplier;
|
||||
}
|
||||
|
||||
public float getOreDoublePercentage() {
|
||||
return this.oreDoublePercentage;
|
||||
}
|
||||
|
||||
public DoubleSupplier getWirelessTerminalBattery() {
|
||||
return () -> this.wirelessTerminalBattery;
|
||||
}
|
||||
|
||||
public DoubleSupplier getEntropyManipulatorBattery() {
|
||||
return () -> this.entropyManipulatorBattery;
|
||||
}
|
||||
|
||||
public DoubleSupplier getMatterCannonBattery() {
|
||||
return () -> this.matterCannonBattery;
|
||||
}
|
||||
|
||||
public DoubleSupplier getPortableCellBattery() {
|
||||
return () -> this.portableCellBattery;
|
||||
}
|
||||
|
||||
public DoubleSupplier getColorApplicatorBattery() {
|
||||
return () -> this.colorApplicatorBattery;
|
||||
}
|
||||
|
||||
public DoubleSupplier getChargedStaffBattery() {
|
||||
return () -> this.chargedStaffBattery;
|
||||
}
|
||||
|
||||
public float getSpawnChargedChance() {
|
||||
return COMMON.spawnChargedChance.get().floatValue();
|
||||
}
|
||||
|
||||
public int getQuartzOresPerCluster() {
|
||||
return COMMON.quartzOresPerCluster.get();
|
||||
}
|
||||
|
||||
public int getQuartzOresClusterAmount() {
|
||||
return COMMON.quartzOresClusterAmount.get();
|
||||
}
|
||||
|
||||
public int getMeteoriteMaximumSpawnHeight() {
|
||||
return this.meteoriteMaximumSpawnHeight;
|
||||
}
|
||||
|
||||
public Set<String> getMeteoriteDimensionWhitelist() {
|
||||
return this.meteoriteDimensionWhitelist;
|
||||
}
|
||||
|
||||
// Setters keep visibility as low as possible.
|
||||
|
||||
private static class ClientConfig {
|
||||
|
||||
// Misc
|
||||
public final BooleanValue enableEffects;
|
||||
public final BooleanValue useLargeFonts;
|
||||
public final BooleanValue useColoredCraftingStatus;
|
||||
public final BooleanValue disableColoredCableRecipesInJEI;
|
||||
public final EnumValue<PowerUnits> selectedPowerUnit;
|
||||
|
||||
// GUI Buttons
|
||||
private static final int[] BTN_BY_STACK_DEFAULTS = { 1, 10, 100, 1000 };
|
||||
public final List<ConfigValue<Integer>> craftByStacks;
|
||||
public final List<ConfigValue<Integer>> priorityByStacks;
|
||||
public final List<ConfigValue<Integer>> levelByStacks;
|
||||
|
||||
// Terminal Settings
|
||||
public final EnumValue<YesNo> searchTooltips;
|
||||
public final EnumValue<TerminalStyle> terminalStyle;
|
||||
public final EnumValue<SearchBoxMode> terminalSearchMode;
|
||||
|
||||
public ClientConfig(ForgeConfigSpec.Builder builder) {
|
||||
builder.push("client");
|
||||
this.disableColoredCableRecipesInJEI = builder.comment("TODO").define("disableColoredCableRecipesInJEI",
|
||||
true);
|
||||
this.enableEffects = builder.comment("TODO").define("enableEffects", true);
|
||||
this.useLargeFonts = builder.comment("TODO").define("useTerminalUseLargeFont", false);
|
||||
this.useColoredCraftingStatus = builder.comment("TODO").define("useColoredCraftingStatus", true);
|
||||
this.selectedPowerUnit = builder.comment("Power unit shown in AE UIs").defineEnum("PowerUnit",
|
||||
PowerUnits.AE, PowerUnits.values());
|
||||
|
||||
this.craftByStacks = new ArrayList<>(4);
|
||||
this.priorityByStacks = new ArrayList<>(4);
|
||||
this.levelByStacks = new ArrayList<>(4);
|
||||
// load buttons..
|
||||
for (int btnNum = 0; btnNum < 4; btnNum++) {
|
||||
int defaultValue = BTN_BY_STACK_DEFAULTS[btnNum];
|
||||
final int buttonCap = (int) (Math.pow(10, btnNum + 1) - 1);
|
||||
|
||||
this.craftByStacks.add(builder.comment("Controls buttons on Crafting Screen")
|
||||
.defineInRange("craftByStacks" + btnNum, defaultValue, 1, buttonCap));
|
||||
this.priorityByStacks.add(builder.comment("Controls buttons on Priority Screen")
|
||||
.defineInRange("priorityByStacks" + btnNum, defaultValue, 1, buttonCap));
|
||||
this.levelByStacks.add(builder.comment("Controls buttons on Level Emitter Screen")
|
||||
.defineInRange("levelByStacks" + btnNum, defaultValue, 1, buttonCap));
|
||||
}
|
||||
|
||||
builder.pop();
|
||||
|
||||
builder.push("terminals");
|
||||
this.searchTooltips = builder.comment("Should tooltips be searched. Performance impact")
|
||||
.defineEnum("searchTooltips", YesNo.YES, YesNo.values());
|
||||
this.terminalStyle = builder.defineEnum("terminalStyle", TerminalStyle.TALL, TerminalStyle.values());
|
||||
this.terminalSearchMode = builder.defineEnum("terminalSearchMode", SearchBoxMode.AUTOSEARCH,
|
||||
SearchBoxMode.values());
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class CommonConfig {
|
||||
|
||||
// Feature toggles
|
||||
public final Map<AEFeature, BooleanValue> enabledFeatures = new EnumMap<>(AEFeature.class);
|
||||
|
||||
// Misc
|
||||
public final BooleanValue removeCrashingItemsOnLoad;
|
||||
public final ConfigValue<Integer> formationPlaneEntityLimit;
|
||||
public final ConfigValue<Integer> craftingCalculationTimePerTick;
|
||||
|
||||
// Spatial IO/Dimension
|
||||
public final ConfigValue<Double> spatialPowerExponent;
|
||||
public final ConfigValue<Double> spatialPowerMultiplier;
|
||||
|
||||
// Grindstone
|
||||
public final DoubleValue oreDoublePercentage;
|
||||
|
||||
// Batteries
|
||||
public final ConfigValue<Integer> wirelessTerminalBattery;
|
||||
public final ConfigValue<Integer> entropyManipulatorBattery;
|
||||
public final ConfigValue<Integer> matterCannonBattery;
|
||||
public final ConfigValue<Integer> portableCellBattery;
|
||||
public final ConfigValue<Integer> colorApplicatorBattery;
|
||||
public final ConfigValue<Integer> chargedStaffBattery;
|
||||
|
||||
// Certus quartz
|
||||
public final DoubleValue spawnChargedChance;
|
||||
public final ConfigValue<Integer> quartzOresPerCluster;
|
||||
public final ConfigValue<Integer> quartzOresClusterAmount;
|
||||
|
||||
// Meteors
|
||||
public final ConfigValue<Integer> meteoriteMaximumSpawnHeight;
|
||||
public final ConfigValue<List<? extends String>> meteoriteDimensionWhitelist;
|
||||
|
||||
// Wireless
|
||||
public final ConfigValue<Double> wirelessBaseCost;
|
||||
public final ConfigValue<Double> wirelessCostMultiplier;
|
||||
public final ConfigValue<Double> wirelessTerminalDrainMultiplier;
|
||||
public final ConfigValue<Double> wirelessBaseRange;
|
||||
public final ConfigValue<Double> wirelessBoosterRangeMultiplier;
|
||||
public final ConfigValue<Double> wirelessBoosterExp;
|
||||
public final ConfigValue<Double> wirelessHighWirelessCount;
|
||||
|
||||
// Power Ratios
|
||||
public final ConfigValue<Double> powerRatioIc2;
|
||||
public final ConfigValue<Double> powerRatioForgeEnergy;
|
||||
public final DoubleValue powerUsageMultiplier;
|
||||
|
||||
// Condenser Power Requirement
|
||||
public final ConfigValue<Integer> condenserMatterBallsPower;
|
||||
public final ConfigValue<Integer> condenserSingularityPower;
|
||||
|
||||
public final Map<TickRates, ConfigValue<Integer>> tickRateMin = new HashMap<>();
|
||||
public final Map<TickRates, ConfigValue<Integer>> tickRateMax = new HashMap<>();
|
||||
|
||||
public CommonConfig(ForgeConfigSpec.Builder builder) {
|
||||
|
||||
// Feature switches
|
||||
builder.comment("Warning: Disabling a feature may disable other features depending on it.")
|
||||
.push("features");
|
||||
|
||||
// We need to group by feature category
|
||||
Map<String, List<AEFeature>> groupedFeatures = Arrays.stream(AEFeature.values())
|
||||
.filter(AEFeature::isVisible) // Only provide config settings for visible features
|
||||
.collect(Collectors.groupingBy(AEFeature::category));
|
||||
|
||||
for (final String category : groupedFeatures.keySet()) {
|
||||
List<AEFeature> featuresInGroup = groupedFeatures.get(category);
|
||||
|
||||
builder.push(category);
|
||||
for (AEFeature feature : featuresInGroup) {
|
||||
if (feature.isConfig()) {
|
||||
enabledFeatures.put(feature, builder.comment(Strings.nullToEmpty(feature.comment()))
|
||||
.define(feature.key(), feature.isEnabled()));
|
||||
}
|
||||
}
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
builder.pop();
|
||||
|
||||
builder.push("general");
|
||||
removeCrashingItemsOnLoad = builder.comment(
|
||||
"Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!")
|
||||
.define("removeCrashingItemsOnLoad", false);
|
||||
builder.pop();
|
||||
|
||||
builder.push("automation");
|
||||
formationPlaneEntityLimit = builder.comment("TODO").define("formationPlaneEntityLimit", 128);
|
||||
builder.pop();
|
||||
|
||||
builder.push("craftingCPU");
|
||||
|
||||
this.craftingCalculationTimePerTick = builder.define("craftingCalculationTimePerTick", 5);
|
||||
|
||||
builder.pop();
|
||||
|
||||
builder.push("spatialio");
|
||||
this.spatialPowerMultiplier = builder.define("spatialPowerMultiplier", 1250.0);
|
||||
this.spatialPowerExponent = builder.define("spatialPowerExponent", 1.35);
|
||||
builder.pop();
|
||||
|
||||
builder.push("GrindStone");
|
||||
this.oreDoublePercentage = builder.comment("Chance to actually get an output with stacksize > 1.")
|
||||
.defineInRange("oreDoublePercentage", 90.0, 0.0, 100.0);
|
||||
builder.pop();
|
||||
|
||||
builder.push("battery");
|
||||
this.wirelessTerminalBattery = builder.define("wirelessTerminal", 1600000);
|
||||
this.chargedStaffBattery = builder.define("chargedStaff", 8000);
|
||||
this.entropyManipulatorBattery = builder.define("entropyManipulator", 200000);
|
||||
this.portableCellBattery = builder.define("portableCell", 20000);
|
||||
this.colorApplicatorBattery = builder.define("colorApplicator", 20000);
|
||||
this.matterCannonBattery = builder.define("matterCannon", 200000);
|
||||
builder.pop();
|
||||
|
||||
builder.push("worldGen");
|
||||
|
||||
this.spawnChargedChance = builder.defineInRange("spawnChargedChance", 0.08, 0.0, 1.0);
|
||||
this.meteoriteMaximumSpawnHeight = builder.define("meteoriteMaximumSpawnHeight", 180);
|
||||
List<String> defaultDimensionWhitelist = new ArrayList<>();
|
||||
defaultDimensionWhitelist.add(DimensionType.getKey(DimensionType.OVERWORLD).toString());
|
||||
this.meteoriteDimensionWhitelist = builder.defineList("meteoriteDimensionWhitelist",
|
||||
defaultDimensionWhitelist, obj -> true);
|
||||
|
||||
this.quartzOresPerCluster = builder.define("quartzOresPerCluster", 4);
|
||||
this.quartzOresClusterAmount = builder.define("quartzOresClusterAmount", 20);
|
||||
|
||||
builder.pop();
|
||||
|
||||
builder.push("wireless");
|
||||
this.wirelessBaseCost = builder.define("wirelessBaseCost", 8.0);
|
||||
this.wirelessCostMultiplier = builder.define("wirelessCostMultiplier", 1.0);
|
||||
this.wirelessBaseRange = builder.define("wirelessBaseRange", 16.0);
|
||||
this.wirelessBoosterRangeMultiplier = builder.define("wirelessBoosterRangeMultiplier", 1.0);
|
||||
this.wirelessBoosterExp = builder.define("wirelessBoosterExp", 1.5);
|
||||
this.wirelessHighWirelessCount = builder.define("wirelessHighWirelessCount", 64.0);
|
||||
this.wirelessTerminalDrainMultiplier = builder.define("wirelessTerminalDrainMultiplier", 1.0);
|
||||
builder.pop();
|
||||
|
||||
builder.push("PowerRatios");
|
||||
powerRatioIc2 = builder.define("IC2", DEFAULT_IC2_EXCHANGE);
|
||||
powerRatioForgeEnergy = builder.define("ForgeEnergy", DEFAULT_RF_EXCHANGE);
|
||||
powerUsageMultiplier = builder.defineInRange("UsageMultiplier", 1.0, 0.01, Double.MAX_VALUE);
|
||||
builder.pop();
|
||||
|
||||
builder.push("Condenser");
|
||||
condenserMatterBallsPower = builder.define("MatterBalls", 256);
|
||||
condenserSingularityPower = builder.define("Singularity", 256000);
|
||||
builder.pop();
|
||||
|
||||
builder.comment(
|
||||
" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested.")
|
||||
.push("tickRates");
|
||||
for (TickRates tickRate : TickRates.values()) {
|
||||
tickRateMin.put(tickRate, builder.define(tickRate.name() + "Min", tickRate.getDefaultMin()));
|
||||
tickRateMax.put(tickRate, builder.define(tickRate.name() + "Max", tickRate.getDefaultMax()));
|
||||
}
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,362 +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 javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class AELog {
|
||||
private static final String LOGGER_PREFIX = "AE2:";
|
||||
private static final String SERVER_SUFFIX = "S";
|
||||
private static final String CLIENT_SUFFIX = "C";
|
||||
|
||||
private static final Logger SERVER = LogManager.getFormatterLogger(LOGGER_PREFIX + SERVER_SUFFIX);
|
||||
private static final Logger CLIENT = LogManager.getFormatterLogger(LOGGER_PREFIX + CLIENT_SUFFIX);
|
||||
|
||||
private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s ). State %s -> %s";
|
||||
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: ";
|
||||
|
||||
private AELog() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Logger} logger suitable for the effective side
|
||||
* (client/server).
|
||||
*
|
||||
* @return a suitable logger instance
|
||||
*/
|
||||
private static Logger getLogger() {
|
||||
return Platform.isServer() ? SERVER : CLIENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates of the global log is enabled or disabled.
|
||||
*
|
||||
* By default it is enabled.
|
||||
*
|
||||
* @return true when the log is enabled.
|
||||
*/
|
||||
public static boolean isLogEnabled() {
|
||||
return AEConfig.instance() == null || AEConfig.instance().isFeatureEnabled(AEFeature.LOGGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a formatted message with a specific log level.
|
||||
*
|
||||
* This uses {@link String#format(String, Object...)} as opposed to the
|
||||
* {@link ParameterizedMessage} to allow a more flexible formatting.
|
||||
*
|
||||
* The output can be globally disabled via the configuration file.
|
||||
*
|
||||
* @param level the intended level.
|
||||
* @param message the message to be formatted.
|
||||
* @param params the parameters used for
|
||||
* {@link String#format(String, Object...)}.
|
||||
*/
|
||||
public static void log(@Nonnull final Level level, @Nonnull final String message, final Object... params) {
|
||||
if (AELog.isLogEnabled()) {
|
||||
final String formattedMessage = String.format(message, params);
|
||||
final Logger logger = getLogger();
|
||||
|
||||
logger.log(level, formattedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an exception with a custom message formated via
|
||||
* {@link String#format(String, Object...)}
|
||||
*
|
||||
* Similar to {@link AELog#log(Level, String, Object...)}.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
*
|
||||
* @param level the intended level.
|
||||
* @param exception
|
||||
* @param message the message to be formatted.
|
||||
* @param params the parameters used for
|
||||
* {@link String#format(String, Object...)}.
|
||||
*/
|
||||
public static void log(@Nonnull final Level level, @Nonnull final Throwable exception, @Nonnull String message,
|
||||
final Object... params) {
|
||||
if (AELog.isLogEnabled()) {
|
||||
final String formattedMessage = String.format(message, params);
|
||||
final Logger logger = getLogger();
|
||||
|
||||
logger.log(level, formattedMessage, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void info(@Nonnull final String format, final Object... params) {
|
||||
log(Level.INFO, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void info(@Nonnull final Throwable exception) {
|
||||
log(Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void info(@Nonnull final Throwable exception, @Nonnull final String message) {
|
||||
log(Level.INFO, exception, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void warn(@Nonnull final String format, final Object... params) {
|
||||
log(Level.WARN, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#WARN}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void warn(@Nonnull final Throwable exception) {
|
||||
log(Level.WARN, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#WARN}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void warn(@Nonnull final Throwable exception, @Nonnull final String message) {
|
||||
log(Level.WARN, exception, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void error(@Nonnull final String format, final Object... params) {
|
||||
log(Level.ERROR, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#ERROR}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void error(@Nonnull final Throwable exception) {
|
||||
log(Level.ERROR, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#ERROR}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void error(@Nonnull final Throwable exception, @Nonnull final String message) {
|
||||
log(Level.ERROR, exception, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void debug(@Nonnull final String format, final Object... data) {
|
||||
if (AELog.isDebugLogEnabled()) {
|
||||
log(Level.DEBUG, format, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void debug(@Nonnull final Throwable exception) {
|
||||
if (AELog.isDebugLogEnabled()) {
|
||||
log(Level.DEBUG, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void debug(@Nonnull final Throwable exception, @Nonnull final String message) {
|
||||
if (AELog.isDebugLogEnabled()) {
|
||||
log(Level.DEBUG, exception, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled debug log.
|
||||
*
|
||||
* Can be used to prevent the execution of debug logic.
|
||||
*
|
||||
* @return true when the debug log is enabled.
|
||||
*/
|
||||
public static boolean isDebugLogEnabled() {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.DEBUG_LOGGING);
|
||||
}
|
||||
|
||||
//
|
||||
// Specialized handlers
|
||||
//
|
||||
|
||||
/**
|
||||
* A specialized logging for grinder recipes, can be disabled inside
|
||||
* configuration file.
|
||||
*
|
||||
* @param message String to be logged
|
||||
*/
|
||||
public static void grinder(@Nonnull final String message, final Object... params) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.GRINDER_LOGGING)) {
|
||||
log(Level.DEBUG, "grinder: " + message, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized logging for mod integration errors, can be disabled inside
|
||||
* configuration file.
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void integration(@Nonnull final Throwable exception) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.INTEGRATION_LOGGING)) {
|
||||
debug(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging of block updates.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param pos
|
||||
* @param currentState
|
||||
* @param newState
|
||||
* @param aeBaseTile
|
||||
*/
|
||||
public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState,
|
||||
@Nonnull BlockState newState, @Nonnull final AEBaseBlockEntity aeBaseTile) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.UPDATE_LOGGING)) {
|
||||
info(BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled crafting log.
|
||||
*
|
||||
* Can be used to prevent the execution of unneeded logic.
|
||||
*
|
||||
* @return true when the crafting log is enabled.
|
||||
*/
|
||||
public static boolean isCraftingLogEnabled() {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging for autocrafting.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param message
|
||||
* @param params
|
||||
*/
|
||||
public static void crafting(@Nonnull final String message, final Object... params) {
|
||||
if (AELog.isCraftingLogEnabled()) {
|
||||
log(Level.INFO, message, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled crafting debug log.
|
||||
*
|
||||
* Can be used to prevent the execution of unneeded logic.
|
||||
*
|
||||
* @return true when the crafting debug log is enabled.
|
||||
*/
|
||||
public static boolean isCraftingDebugLogEnabled() {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_LOG)
|
||||
&& AEConfig.instance().isFeatureEnabled(AEFeature.DEBUG_LOGGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug logging for autocrafting.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param message
|
||||
* @param params
|
||||
*/
|
||||
public static void craftingDebug(@Nonnull final String message, final Object... params) {
|
||||
if (AELog.isCraftingDebugLogEnabled()) {
|
||||
log(Level.DEBUG, message, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,303 +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 java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.CrashReportExtender;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.FacadeItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||
import appeng.client.render.model.*;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.core.crash.ModCrashEnhancement;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.entity.*;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.parts.automation.PlaneModelLoader;
|
||||
import appeng.server.ServerHelper;
|
||||
|
||||
@Mod(AppEng.MOD_ID)
|
||||
public final class AppEng {
|
||||
public static CommonHelper proxy;
|
||||
|
||||
public static final String MOD_ID = "appliedenergistics2";
|
||||
public static final String MOD_NAME = "Applied Energistics 2";
|
||||
|
||||
private static AppEng INSTANCE;
|
||||
|
||||
private final Registration registration;
|
||||
|
||||
public AppEng() {
|
||||
if (INSTANCE != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
INSTANCE = this;
|
||||
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AEConfig.COMMON_SPEC);
|
||||
|
||||
proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||
|
||||
CrashReportExtender.registerCrashCallable(new ModCrashEnhancement());
|
||||
|
||||
CreativeTab.init();
|
||||
new FacadeItemGroup(); // This call has a side-effect (adding it to the creative screen)
|
||||
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
registration = new Registration();
|
||||
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
||||
modEventBus.addGenericListener(BlockEntityType.class, registration::registerTileEntities);
|
||||
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
|
||||
modEventBus.addGenericListener(RecipeSerializer.class, registration::registerRecipeSerializers);
|
||||
modEventBus.addGenericListener(Feature.class, registration::registerWorldGen);
|
||||
modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
|
||||
modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension);
|
||||
|
||||
modEventBus.addListener(Integrations::enqueueIMC);
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
// Register client-only events
|
||||
DistExecutor.runWhenOn(EnvType.CLIENT, () -> registration::registerClientEvents);
|
||||
DistExecutor.runWhenOn(EnvType.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup));
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::unloadWorld);
|
||||
MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::onTick);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onServerAboutToStart);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
MinecraftForge.EVENT_BUS.addListener(registration::registerCommands);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new PartPlacement());
|
||||
}
|
||||
|
||||
private void commonSetup(FMLCommonSetupEvent event) {
|
||||
|
||||
ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IInitComponent.class)
|
||||
.forEachRemaining(IInitComponent::initialize);
|
||||
definitions.getRegistry().getBootstrapComponents(IPostInitComponent.class)
|
||||
.forEachRemaining(IPostInitComponent::postInitialize);
|
||||
|
||||
Capabilities.register();
|
||||
Registration.setupInternalRegistries();
|
||||
Registration.postInit();
|
||||
|
||||
registerNetworkHandler();
|
||||
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
|
||||
((ClientHelper) proxy).clientInit();
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(TinyTNTPrimedEntity.TYPE, TinyTNTPrimedRenderer::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(SingularityEntity.TYPE,
|
||||
m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(GrowingCrystalEntity.TYPE,
|
||||
m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(ChargedQuartzEntity.TYPE,
|
||||
m -> new ItemRenderer(m, MinecraftClient.getInstance().getItemRenderer()));
|
||||
|
||||
// TODO: Do not use the internal API
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
||||
.forEachRemaining(IClientSetupComponent::setup);
|
||||
|
||||
addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
addBuiltInModel("facade", FacadeItemModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, "encoded_pattern"),
|
||||
EncodedPatternModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, "part_plane"),
|
||||
PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, "crafting_cube"),
|
||||
CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, "cable_bus"),
|
||||
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
ModelLoaderRegistry.registerLoader(new Identifier(AppEng.MOD_ID, id),
|
||||
new SimpleModelLoader<>(modelFactory));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static AppEng instance() {
|
||||
if (INSTANCE == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public AdvancementTriggers getAdvancementTriggers() {
|
||||
return this.registration.advancementTriggers;
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// private void preInit( final FMLPreInitializationEvent event )
|
||||
// {
|
||||
// final Stopwatch watch = Stopwatch.createStarted();
|
||||
// this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
|
||||
//
|
||||
// final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg" );
|
||||
// final File facadeFile = new File( this.configDirectory, "Facades.cfg" );
|
||||
// final File versionFile = new File( this.configDirectory, "VersionChecker.cfg" );
|
||||
// final File recipeFile = new File( this.configDirectory, "CustomRecipes.cfg" );
|
||||
// final Configuration recipeConfiguration = new Configuration( recipeFile );
|
||||
//
|
||||
// AEConfig.init( configFile );
|
||||
// FacadeConfig.init( facadeFile );
|
||||
//
|
||||
// AELog.info( "Pre Initialization ( started )" );
|
||||
//
|
||||
//
|
||||
// for( final IntegrationType type : IntegrationType.values() )
|
||||
// {
|
||||
// IntegrationRegistry.INSTANCE.add( type );
|
||||
// }
|
||||
//
|
||||
// this.registration.preInitialize( event );
|
||||
//
|
||||
// if( Platform.isClient() )
|
||||
// {
|
||||
// AppEng.proxy.preinit();
|
||||
// }
|
||||
//
|
||||
// IntegrationRegistry.INSTANCE.preInit();
|
||||
//
|
||||
// AELog.info( "Pre Initialization ( ended after " + watch.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
//
|
||||
// // Instantiate all Plugins
|
||||
// List<Object> injectables = Lists.newArrayList(
|
||||
// AEApi.instance() );
|
||||
// new PluginLoader().loadPlugins( injectables, event.getAsmData() );
|
||||
// }
|
||||
|
||||
private void startService(final String serviceName, final Thread thread) {
|
||||
thread.setName(serviceName);
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
|
||||
AELog.info("Starting " + serviceName);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void registerNetworkHandler() {
|
||||
final Stopwatch start = Stopwatch.createStarted();
|
||||
AELog.info("Post Initialization ( started )");
|
||||
|
||||
// FIXME IntegrationRegistry.INSTANCE.postInit();
|
||||
// FIXME CrashReportExtender.registerCrashCallable( new
|
||||
// IntegrationCrashEnhancement() );
|
||||
|
||||
AppEng.proxy.postInit();
|
||||
AEConfig.instance().save();
|
||||
|
||||
NetworkHandler.init(new Identifier(MOD_ID, "main"));
|
||||
|
||||
AELog.info("Post Initialization ( ended after " + start.elapsed(TimeUnit.MILLISECONDS) + "ms )");
|
||||
}
|
||||
|
||||
private void onServerAboutToStart(final FMLServerAboutToStartEvent evt) {
|
||||
WorldData.onServerStarting(evt.getServer());
|
||||
}
|
||||
|
||||
private void serverStopping(final FMLServerStoppingEvent event) {
|
||||
WorldData.instance().onServerStopping();
|
||||
}
|
||||
|
||||
private void serverStopped(final FMLServerStoppedEvent event) {
|
||||
WorldData.instance().onServerStoppped();
|
||||
TickHandler.INSTANCE.shutdown();
|
||||
}
|
||||
|
||||
public static Identifier makeId(String id) {
|
||||
return new Identifier(MOD_ID, id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +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;
|
||||
|
||||
public enum ActivityState {
|
||||
Enabled, Disabled;
|
||||
|
||||
public static ActivityState from(final boolean enabled) {
|
||||
if (enabled) {
|
||||
return ActivityState.Enabled;
|
||||
} else {
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
|
||||
public class BlockDefinition extends ItemDefinition implements IBlockDefinition {
|
||||
private final Block block;
|
||||
|
||||
private final BlockItem blockItem;
|
||||
|
||||
public BlockDefinition(String registryName, Block block, BlockItem item, Set<AEFeature> features) {
|
||||
super(registryName, item, features);
|
||||
this.block = block;
|
||||
this.blockItem = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Block block() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem blockItem() {
|
||||
return blockItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ItemStack stack(int stackSize) {
|
||||
Preconditions.checkArgument(stackSize > 0);
|
||||
|
||||
return new ItemStack(block, stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSameAs(final BlockView world, final BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == this.block;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +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;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockStackSrc implements IStackSrc {
|
||||
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
|
||||
public BlockStackSrc(final Block block, final ActivityState state) {
|
||||
Preconditions.checkNotNull(block);
|
||||
Preconditions.checkNotNull(state);
|
||||
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
|
||||
|
||||
this.block = block;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack(final int i) {
|
||||
return new ItemStack(this.block, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +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;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
public final class ColoredItemDefinition implements AEColoredItemDefinition {
|
||||
|
||||
private final ItemStackSrc[] colors = new ItemStackSrc[17];
|
||||
|
||||
public void add(final AEColor v, final ItemStackSrc is) {
|
||||
this.colors[v.ordinal()] = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block(final AEColor color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item(final AEColor color) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends BlockEntity> entity(final AEColor color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(final AEColor color, final int stackSize) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if (is == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return is.stack(stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] allStacks(final int stackSize) {
|
||||
final ItemStack[] is = new ItemStack[this.colors.length];
|
||||
for (int x = 0; x < is.length; x++) {
|
||||
is[x] = this.colors[x].stack(1);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(final AEColor color, final ItemStack comparableItem) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if (comparableItem.isEmpty() || is == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return comparableItem.getItem() == is.getItem();
|
||||
}
|
||||
}
|
||||
@@ -1,84 +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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
|
||||
public final class DamagedItemDefinition implements IItemDefinition {
|
||||
private final String identifier;
|
||||
private final IStackSrc source;
|
||||
|
||||
public DamagedItemDefinition(@Nonnull final String identifier, @Nonnull final IStackSrc source) {
|
||||
this.identifier = Preconditions.checkNotNull(identifier);
|
||||
this.source = Preconditions.checkNotNull(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item() {
|
||||
return source.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize) {
|
||||
return source.stack(stackSize);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Item> maybeItem() {
|
||||
return Optional.of(this.source.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> maybeStack(final int stackSize) {
|
||||
return Optional.of(this.source.stack(stackSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AEFeature> features() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameAs(final ItemStack comparableStack) {
|
||||
if (comparableStack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return comparableStack.getItem() == this.source.getItem();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +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;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStackSrc {
|
||||
|
||||
ItemStack stack(int i);
|
||||
|
||||
Item getItem();
|
||||
|
||||
boolean isEnabled();
|
||||
}
|
||||
@@ -1,74 +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;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ItemDefinition implements IItemDefinition {
|
||||
private final String identifier;
|
||||
private final Item item;
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
public ItemDefinition(String registryName, Item item, Set<AEFeature> features) {
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(registryName), "registryName");
|
||||
this.identifier = registryName;
|
||||
this.item = item;
|
||||
this.features = ImmutableSet.copyOf(features);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Item item() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(final int stackSize) {
|
||||
return new ItemStack(item, stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AEFeature> features() {
|
||||
return features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSameAs(final ItemStack comparableStack) {
|
||||
return Platform.itemComparisons().isEqualItemType(comparableStack, this.stack(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +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;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackSrc implements IStackSrc {
|
||||
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
|
||||
public ItemStackSrc(final Item item, final ActivityState state) {
|
||||
Preconditions.checkNotNull(item);
|
||||
Preconditions.checkNotNull(state);
|
||||
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
|
||||
|
||||
this.item = item;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack(final int i) {
|
||||
return new ItemStack(this.item, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +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;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc {
|
||||
private final MaterialType src;
|
||||
private final boolean enabled;
|
||||
|
||||
public MaterialStackSrc(final MaterialType src, boolean enabled) {
|
||||
Preconditions.checkNotNull(src);
|
||||
|
||||
this.src = src;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(final int stackSize) {
|
||||
return this.src.stack(stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return this.src.getItemInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public final class TileDefinition extends BlockDefinition implements ITileDefinition {
|
||||
private final AEBaseTileBlock<?> block;
|
||||
|
||||
public TileDefinition(@Nonnull String registryName, AEBaseTileBlock<?> block, BlockItem item,
|
||||
Set<AEFeature> features) {
|
||||
super(registryName, block, item, features);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Class<? extends BlockEntity>> maybeEntity() {
|
||||
return Optional.of(this.block.getBlockEntityClass());
|
||||
}
|
||||
}
|
||||
@@ -1,92 +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.localization;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public enum ButtonToolTips {
|
||||
PowerUnits, IOMode, CondenserOutput, RedstoneMode, MatchingFuzzy,
|
||||
|
||||
MatchingMode, TransferDirection, SortOrder, SortBy, View,
|
||||
|
||||
PartitionStorage, Clear, FuzzyMode, OperationMode, TrashController,
|
||||
|
||||
InterfaceBlockingMode, InterfaceCraftingMode, Trash, MatterBalls,
|
||||
|
||||
Singularity, Read, Write, ReadWrite, AlwaysActive,
|
||||
|
||||
ActiveWithoutSignal, ActiveWithSignal, ActiveOnPulse,
|
||||
|
||||
EmitLevelsBelow, EmitLevelAbove, MatchingExact, TransferToNetwork,
|
||||
|
||||
TransferToStorageCell, ToggleSortDirection,
|
||||
|
||||
SearchMode_Auto, SearchMode_Standard, SearchMode_JEIAuto, SearchMode_JEIStandard, SearchMode_AutoKeep,
|
||||
SearchMode_StandardKeep, SearchMode_JEIAutoKeep, SearchMode_JEIStandardKeep,
|
||||
|
||||
SearchMode, ItemName, NumberOfItems, PartitionStorageHint,
|
||||
|
||||
ClearSettings, StoredItems, StoredCraftable, Craftable,
|
||||
|
||||
FZPercent_25, FZPercent_50, FZPercent_75, FZPercent_99, FZIgnoreAll,
|
||||
|
||||
MoveWhenEmpty, MoveWhenWorkIsDone, MoveWhenFull, Disabled, Enable,
|
||||
|
||||
Blocking, NonBlocking,
|
||||
|
||||
LevelType, LevelType_Energy, LevelType_Item, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall,
|
||||
TerminalStyle_Small,
|
||||
|
||||
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff,
|
||||
SubstitutionsDescEnabled, SubstitutionsDescDisabled, CraftOnly, CraftEither,
|
||||
|
||||
Craft, Mod, DoesntDespawn, EmitterMode, CraftViaRedstone, EmitWhenCrafting, ReportInaccessibleItems,
|
||||
ReportInaccessibleItemsYes, ReportInaccessibleItemsNo, ReportInaccessibleFluids, ReportInaccessibleFluidsYes,
|
||||
ReportInaccessibleFluidsNo,
|
||||
|
||||
BlockPlacement, BlockPlacementYes, BlockPlacementNo,
|
||||
|
||||
// Used in the tooltips of the items in the terminal, when moused over
|
||||
ItemsStored, ItemsRequestable,
|
||||
|
||||
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom,
|
||||
|
||||
FilterMode, FilterModeKeep, FilterModeClear;
|
||||
|
||||
private final String root;
|
||||
|
||||
ButtonToolTips() {
|
||||
this.root = "gui.tooltips.appliedenergistics2";
|
||||
}
|
||||
|
||||
ButtonToolTips(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLocal() {
|
||||
return getTranslationKey().getFormattedText();
|
||||
}
|
||||
|
||||
public Text getTranslationKey() {
|
||||
return new TranslatableText(this.root + '.' + this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +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.localization;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public enum GuiText {
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest,
|
||||
|
||||
VibrationChamber, SpatialIOPort, LevelEmitter, FluidLevelEmitter, Terminal,
|
||||
|
||||
Interface, FluidInterface, Config, StoredItems, StoredFluids, Patterns, ImportBus, ImportBusFluids, ExportBus,
|
||||
ExportBusFluids,
|
||||
|
||||
CellWorkbench, NetworkDetails, StorageCells, IOBuses, IOBusesFluids,
|
||||
|
||||
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
||||
|
||||
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain,
|
||||
|
||||
StorageBus, StorageBusFluids, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
||||
|
||||
SecurityCardEditor, NoPermissions, WirelessTerminal, Wireless,
|
||||
|
||||
CraftingTerminal, FormationPlane, FluidFormationPlane, Inscriber, QuartzCuttingKnife,
|
||||
|
||||
// spatial
|
||||
SpatialCapacity, StoredSize, Unformatted, SerialNumber,
|
||||
|
||||
CopyMode, CopyModeDesc, PatternTerminal,
|
||||
|
||||
// Pattern tooltips
|
||||
CraftingPattern, ProcessingPattern, Crafts, Creates, And, With, Substitute, Yes, No,
|
||||
|
||||
MolecularAssembler,
|
||||
|
||||
StoredPower, MaxPower, RequiredPower, Efficiency, SCSSize, SCSInvalid, InWorldCrafting,
|
||||
|
||||
inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether,
|
||||
|
||||
inWorldPurificationFluix, inWorldSingularity, ChargedQuartz,
|
||||
|
||||
NoSecondOutput, OfSecondOutput, MultipleOutputs,
|
||||
|
||||
Stores, Next, SelectAmount, Lumen, Empty,
|
||||
|
||||
ConfirmCrafting, Stored, Crafting, Scheduled, CraftingStatus, Cancel, ETA, ETAFormat,
|
||||
|
||||
FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes,
|
||||
|
||||
CraftingCPU, Automatic, CoProcessors, Simulation, Missing,
|
||||
|
||||
InterfaceTerminal, NoCraftingCPUs, Clean, InvalidPattern,
|
||||
|
||||
InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint,
|
||||
|
||||
NoCraftingJobs, CPUs, FacadeCrafting, inWorldCraftingPresses, ChargedQuartzFind,
|
||||
|
||||
Included, Excluded, Partitioned, Precise, Fuzzy,
|
||||
|
||||
// Used in a terminal to indicate that an item is craftable
|
||||
SmallFontCraft, LargeFontCraft,
|
||||
|
||||
// Used in a ME Interface when no appropriate TileEntity was detected near it
|
||||
Nothing;
|
||||
|
||||
private final String root;
|
||||
|
||||
private final Text text = new TranslatableText(getTranslationKey());
|
||||
|
||||
GuiText() {
|
||||
this.root = "gui.appliedenergistics2";
|
||||
}
|
||||
|
||||
GuiText(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getLocal() {
|
||||
return text.getString();
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
public Text textComponent() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Text textComponent(Object... args) {
|
||||
return new TranslatableText(getTranslationKey(), args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +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.localization;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public enum PlayerMessages {
|
||||
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, ResetSettings, MachineNotPowered,
|
||||
|
||||
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered,
|
||||
DeviceNotWirelessTerminal, DeviceNotLinked, StationCanNotBeLocated, SettingCleared,;
|
||||
|
||||
public Text get() {
|
||||
return new TranslatableText(this.getTranslationKey());
|
||||
}
|
||||
|
||||
String getTranslationKey() {
|
||||
return "chat.appliedenergistics2." + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +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.localization;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public enum WailaText {
|
||||
Crafting,
|
||||
|
||||
DeviceOnline, DeviceOffline, DeviceMissingChannel,
|
||||
|
||||
P2PUnlinked, P2PInputOneOutput, P2PInputManyOutputs, P2POutput,
|
||||
|
||||
Locked, Unlocked, Showing,
|
||||
|
||||
Contains, Channels;
|
||||
|
||||
private final String root;
|
||||
|
||||
WailaText() {
|
||||
this.root = "waila.appliedenergistics2";
|
||||
}
|
||||
|
||||
WailaText(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getLocal() {
|
||||
return I18n.format(this.getTranslationKey());
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
public Text textComponent() {
|
||||
return new TranslatableText(this.root + '.' + this.toString());
|
||||
}
|
||||
|
||||
public Text textComponent(Object... args) {
|
||||
return new TranslatableText(this.root + '.' + this.toString(), args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +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.settings;
|
||||
|
||||
public enum TickRates {
|
||||
|
||||
Interface(5, 120),
|
||||
|
||||
ImportBus(5, 40),
|
||||
|
||||
FluidImportBus(5, 40),
|
||||
|
||||
ExportBus(5, 60),
|
||||
|
||||
FluidExportBus(5, 60),
|
||||
|
||||
AnnihilationPlane(2, 120),
|
||||
|
||||
METunnel(5, 20),
|
||||
|
||||
Inscriber(1, 1),
|
||||
|
||||
Charger(10, 120),
|
||||
|
||||
IOPort(1, 5),
|
||||
|
||||
VibrationChamber(10, 40),
|
||||
|
||||
StorageBus(5, 60),
|
||||
|
||||
FluidStorageBus(5, 60),
|
||||
|
||||
ItemTunnel(5, 60),
|
||||
|
||||
LightTunnel(5, 60),
|
||||
|
||||
OpenComputersTunnel(1, 5),
|
||||
|
||||
PressureTunnel(1, 120);
|
||||
|
||||
private final int defaultMin;
|
||||
private final int defaultMax;
|
||||
private int min;
|
||||
private int max;
|
||||
|
||||
TickRates(final int min, final int max) {
|
||||
this.defaultMin = min;
|
||||
this.defaultMax = max;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public int getDefaultMin() {
|
||||
return defaultMin;
|
||||
}
|
||||
|
||||
public int getDefaultMax() {
|
||||
return defaultMax;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public void setMax(final int max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public void setMin(final int min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
import appeng.bootstrap.ICriterionTriggerRegistry;
|
||||
|
||||
public class AdvancementTriggers {
|
||||
private final AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger("network_apprentice");
|
||||
private final AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger("network_engineer");
|
||||
private final AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger("network_admin");
|
||||
private final AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger("spatial_explorer");
|
||||
|
||||
public AdvancementTriggers(ICriterionTriggerRegistry registry) {
|
||||
registry.register(this.networkApprentice);
|
||||
registry.register(this.networkEngineer);
|
||||
registry.register(this.networkAdmin);
|
||||
registry.register(this.spatialExplorer);
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkApprentice() {
|
||||
return this.networkApprentice;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkEngineer() {
|
||||
return this.networkEngineer;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkAdmin() {
|
||||
return this.networkAdmin;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getSpatialExplorer() {
|
||||
return this.spatialExplorer;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +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.stats;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.stat.StatFormatter;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public enum AeStats {
|
||||
|
||||
// done
|
||||
ItemsInserted("items_inserted"),
|
||||
|
||||
// done
|
||||
ItemsExtracted("items_extracted"),
|
||||
|
||||
// done
|
||||
TurnedCranks("turned_cranks");
|
||||
|
||||
private final Identifier registryName;
|
||||
|
||||
AeStats(String id) {
|
||||
this.registryName = new Identifier(AppEng.MOD_ID, id);
|
||||
}
|
||||
|
||||
public void addToPlayer(final PlayerEntity player, final int howMany) {
|
||||
player.increaseStat(this.registryName, howMany);
|
||||
}
|
||||
|
||||
public Identifier getRegistryName() {
|
||||
return registryName;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
for (AeStats stat : AeStats.values()) {
|
||||
// Compare with net.minecraft.stat.Stats#registerCustom
|
||||
Identifier registryName = stat.getRegistryName();
|
||||
Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName);
|
||||
Stats.CUSTOM.getOrCreateStat(registryName, StatFormatter.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,157 +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.stats;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancement.PlayerAdvancementTracker;
|
||||
import net.minecraft.advancement.criterion.Criterion;
|
||||
import net.minecraft.advancement.criterion.CriterionConditions;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AppEngAdvancementTrigger
|
||||
implements Criterion<AppEngAdvancementTrigger.Instance>, IAdvancementTrigger {
|
||||
private final Identifier ID;
|
||||
private final Map<PlayerAdvancementTracker, AppEngAdvancementTrigger.Listeners> listeners = new HashMap<>();
|
||||
|
||||
public AppEngAdvancementTrigger(String parString) {
|
||||
super();
|
||||
this.ID = new Identifier(AppEng.MOD_ID, parString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return this.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginTrackingCondition(PlayerAdvancementTracker playerAdvancementsIn,
|
||||
Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> listener) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
if (l == null) {
|
||||
l = new AppEngAdvancementTrigger.Listeners(playerAdvancementsIn);
|
||||
this.listeners.put(playerAdvancementsIn, l);
|
||||
}
|
||||
|
||||
l.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endTrackingCondition(PlayerAdvancementTracker playerAdvancementsIn,
|
||||
Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> listener) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
if (l != null) {
|
||||
l.remove(listener);
|
||||
|
||||
if (l.isEmpty()) {
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endTracking(PlayerAdvancementTracker playerAdvancementsIn) {
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngAdvancementTrigger.Instance conditionsFromJson(JsonObject json, AdvancementEntityPredicateDeserializer context) {
|
||||
return new AppEngAdvancementTrigger.Instance(this.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trigger(ServerPlayerEntity parPlayer) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(parPlayer.getAdvancementTracker());
|
||||
|
||||
if (l != null) {
|
||||
l.trigger(parPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Instance implements CriterionConditions {
|
||||
private final Identifier id;
|
||||
|
||||
public Instance(Identifier id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean test() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject toJson(AdvancementEntityPredicateSerializer predicateSerializer) {
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
static class Listeners {
|
||||
private final PlayerAdvancementTracker playerAdvancements;
|
||||
private final Set<Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance>> listeners = new HashSet<>();
|
||||
|
||||
Listeners(PlayerAdvancementTracker playerAdvancementsIn) {
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.listeners.isEmpty();
|
||||
}
|
||||
|
||||
public void add(Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
public void remove(Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> listener) {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void trigger(PlayerEntity player) {
|
||||
List<Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance>> list = null;
|
||||
|
||||
for (Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> listener : this.listeners) {
|
||||
if (listener.getConditions().test()) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
if (list != null) {
|
||||
for (Criterion.ConditionsContainer<AppEngAdvancementTrigger.Instance> l : list) {
|
||||
l.grant(this.playerAdvancements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +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.stats;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IAdvancementTrigger {
|
||||
void trigger(ServerPlayerEntity parPlayer);
|
||||
}
|
||||
@@ -1,27 +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.decorative;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
public class AEDecorativeBlock extends AEBaseBlock {
|
||||
public AEDecorativeBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +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.decorative.solid;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class ChargedQuartzOreBlock extends QuartzOreBlock {
|
||||
public ChargedQuartzOreBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double xOff = (r.nextFloat());
|
||||
double yOff = (r.nextFloat());
|
||||
double zOff = (r.nextFloat());
|
||||
|
||||
switch (r.nextInt(6)) {
|
||||
case 0:
|
||||
xOff = -0.01;
|
||||
break;
|
||||
case 1:
|
||||
yOff = -0.01;
|
||||
break;
|
||||
case 2:
|
||||
xOff = -0.01;
|
||||
break;
|
||||
case 3:
|
||||
zOff = -0.01;
|
||||
break;
|
||||
case 4:
|
||||
xOff = 1.01;
|
||||
break;
|
||||
case 5:
|
||||
yOff = 1.01;
|
||||
break;
|
||||
case 6:
|
||||
zOff = 1.01;
|
||||
break;
|
||||
}
|
||||
|
||||
if (AppEng.proxy.shouldAddParticles(r)) {
|
||||
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.CHARGED_ORE, pos.getX() + xOff,
|
||||
pos.getY() + yOff, pos.getZ() + zOff, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +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.decorative.solid;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
/**
|
||||
* Immutable (and thus thread-safe) class that encapsulates the rendering state
|
||||
* required for a connected texture glass block.
|
||||
*/
|
||||
public final class GlassState {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
private final EnumSet<Direction> flushWith = EnumSet.noneOf(Direction.class);
|
||||
|
||||
public GlassState(int x, int y, int z, EnumSet<Direction> flushWith) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.flushWith.addAll(flushWith);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public boolean isFlushWith(Direction side) {
|
||||
return this.flushWith.contains(side);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +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.decorative.solid;
|
||||
|
||||
import net.minecraft.block.AbstractGlassBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
|
||||
public class QuartzGlassBlock extends AbstractGlassBlock {
|
||||
|
||||
public QuartzGlassBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
|
||||
final Material mat = adjacentBlockState.getMaterial();
|
||||
if (mat == Material.GLASS || mat == AEGlassMaterial.INSTANCE) {
|
||||
if (adjacentBlockState.getRenderType() == state.getRenderType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.isSideInvisible(state, adjacentBlockState, side);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +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.decorative.solid;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class QuartzLampBlock extends QuartzGlassBlock {
|
||||
|
||||
public QuartzLampBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@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 (AppEng.proxy.shouldAddParticles(r)) {
|
||||
final double d0 = (r.nextFloat() - 0.5F) * 0.96D;
|
||||
final double d1 = (r.nextFloat() - 0.5F) * 0.96D;
|
||||
final double d2 = (r.nextFloat() - 0.5F) * 0.96D;
|
||||
|
||||
w.addParticle(ParticleTypes.VIBRANT, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +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.decorative.solid;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
public class QuartzOreBlock extends AEBaseBlock {
|
||||
public QuartzOreBlock(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExpDrop(BlockState state, net.minecraft.world.WorldView reader, BlockPos pos, int fortune,
|
||||
int silktouch) {
|
||||
return silktouch == 0 ? MathHelper.nextInt(RANDOM, 2, 5) : 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.decorative.solid;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.decorative.AEDecorativeBlock;
|
||||
import appeng.helpers.MetaRotation;
|
||||
|
||||
public class QuartzPillarBlock extends AEDecorativeBlock implements IOrientableBlock {
|
||||
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS;
|
||||
|
||||
public QuartzPillarBlock(Properties props) {
|
||||
super(props);
|
||||
|
||||
// The upwards facing pillar is the default (i.e. for the item model)
|
||||
this.setDefaultState(this.getDefaultState().with(AXIS, Direction.Axis.Y));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final BlockView w, final BlockPos pos) {
|
||||
return new MetaRotation(w, pos, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +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.decorative.solid;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
|
||||
public class SkyStoneBlock extends AEBaseBlock {
|
||||
private static final float BREAK_SPEAK_SCALAR = 0.1f;
|
||||
private static final double BREAK_SPEAK_THRESHOLD = 7.0;
|
||||
private final SkystoneType type;
|
||||
|
||||
public SkyStoneBlock(SkystoneType type, Properties props) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void breakFaster(final PlayerEvent.BreakSpeed event) {
|
||||
if (event.getState().getBlock() == this && event.getPlayer() != null) {
|
||||
final ItemStack is = event.getPlayer().getItemStackFromSlot(EquipmentSlotType.MAINHAND);
|
||||
int level = -1;
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
level = is.getItem().getHarvestLevel(is, FabricToolTags.PICKAXES, event.getPlayer(), event.getState());
|
||||
}
|
||||
|
||||
if (this.type != SkystoneType.STONE || level >= 3 || event.getOriginalSpeed() > BREAK_SPEAK_THRESHOLD) {
|
||||
event.setNewSpeed(event.getNewSpeed() / BREAK_SPEAK_SCALAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState stateIn, Direction facing, BlockState facingState, WorldAccess worldIn,
|
||||
BlockPos currentPos, BlockPos facingPos) {
|
||||
if (worldIn instanceof ServerWorld) {
|
||||
WorldData.instance().compassData().service().updateArea(worldIn, new ChunkPos(currentPos),
|
||||
currentPos.getY());
|
||||
}
|
||||
|
||||
return super.getStateForNeighborUpdate(stateIn, facing, facingState, worldIn, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
super.onReplaced(state, w, pos, newState, isMoving);
|
||||
|
||||
if (w instanceof ServerWorld) {
|
||||
WorldData.instance().compassData().service().updateArea(w, new ChunkPos(pos), pos.getY());
|
||||
}
|
||||
}
|
||||
|
||||
public enum SkystoneType {
|
||||
STONE, BLOCK, BRICK, SMALL_BRICK
|
||||
}
|
||||
}
|
||||
@@ -1,28 +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.helpers;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public interface ICustomNameObject {
|
||||
|
||||
Text getCustomInventoryName();
|
||||
|
||||
boolean hasCustomInventoryName();
|
||||
}
|
||||
@@ -1,96 +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.helpers;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.decorative.solid.QuartzPillarBlock;
|
||||
|
||||
public class MetaRotation implements IOrientable {
|
||||
|
||||
private final DirectionProperty facingProp;
|
||||
private final BlockView w;
|
||||
private final BlockPos pos;
|
||||
|
||||
public MetaRotation(final BlockView world, final BlockPos pos, final DirectionProperty facingProp) {
|
||||
this.w = world;
|
||||
this.pos = pos;
|
||||
this.facingProp = facingProp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getForward() {
|
||||
if (this.getUp().getOffsetY() == 0) {
|
||||
return Direction.UP;
|
||||
}
|
||||
return Direction.SOUTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getUp() {
|
||||
final BlockState state = this.w.getBlockState(this.pos);
|
||||
|
||||
if (this.facingProp != null && state.contains(this.facingProp)) {
|
||||
return state.get(this.facingProp);
|
||||
}
|
||||
|
||||
// TODO 1.10.2-R - Temp
|
||||
if (state.contains(QuartzPillarBlock.AXIS)) {
|
||||
Axis a = state.get(QuartzPillarBlock.AXIS);
|
||||
switch (a) {
|
||||
case X:
|
||||
return Direction.EAST;
|
||||
case Z:
|
||||
return Direction.SOUTH;
|
||||
default:
|
||||
case Y:
|
||||
return Direction.UP;
|
||||
}
|
||||
}
|
||||
|
||||
return Direction.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(final Direction forward, final Direction up) {
|
||||
if (this.w instanceof World) {
|
||||
if (this.facingProp != null) {
|
||||
((World) this.w).setBlockState(this.pos, this.w.getBlockState(this.pos).with(this.facingProp, up));
|
||||
} else {
|
||||
// TODO 1.10.2-R - Temp
|
||||
((World) this.w).setBlockState(this.pos,
|
||||
this.w.getBlockState(this.pos).with(QuartzPillarBlock.AXIS, up.getAxis()));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException(this.w.getClass().getName() + " received, expected World");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +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.tile.misc;
|
||||
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class LightDetectorBlockEntity extends AEBaseBlockEntity implements Tickable {
|
||||
|
||||
private int lastCheck = 30;
|
||||
private int lastLight = 0;
|
||||
|
||||
public LightDetectorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return this.lastLight > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.lastCheck++;
|
||||
if (this.lastCheck > 30) {
|
||||
this.lastCheck = 0;
|
||||
this.updateLight();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLight() {
|
||||
final int val = this.world.getLightLevel(this.pos);
|
||||
|
||||
if (this.lastLight != val) {
|
||||
this.lastLight = val;
|
||||
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +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.tile.misc;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class SkyCompassBlockEntity extends AEBaseBlockEntity {
|
||||
|
||||
public SkyCompassBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user