pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,24 +18,12 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusBreakingParticle;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
@@ -66,71 +54,83 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusBreakingParticle;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform;
public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implements IAEFacade */ {
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
public BlockCableBus() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops());
}
public BlockCableBus() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops());
}
@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
@Override
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
this.cb(worldIn, pos).animateTick(worldIn, pos, rand);
}
@Override
public void animateTick(final BlockState state, final World worldIn, final BlockPos pos, final Random rand) {
this.cb(worldIn, pos).animateTick(worldIn, pos, rand);
}
@Override
public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) {
this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
}
@Override
public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) {
this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
}
@Override
public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
// IS
// OPPOSITE!?
}
@Override
public int getWeakPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
// IS
// OPPOSITE!?
}
@Override
public boolean canProvidePower(final BlockState state) {
return true;
}
@Override
public boolean canProvidePower(final BlockState state) {
return true;
}
@Override
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) {
this.cb(w, pos).onEntityCollision(entityIn);
}
@Override
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) {
this.cb(w, pos).onEntityCollision(entityIn);
}
@Override
public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
// IS
// OPPOSITE!?
}
@Override
public int getStrongPower(final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side) {
return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
// IS
// OPPOSITE!?
}
@Override
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
if (state.getBlock() != this) {
return state.getBlock().getLightValue(state, world, pos);
}
return this.cb(world, pos).getLightValue();
}
@Override
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
if (state.getBlock() != this) {
return state.getBlock().getLightValue(state, world, pos);
}
return this.cb(world, pos).getLightValue();
}
@Override
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
return this.cb(world, pos).isLadder(entity);
}
@Override
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
return this.cb(world, pos).isLadder(entity);
}
// FIXME: This is now derived from the collision shape, and cannot be decided programatically anymore.
// FIXME: see Block.hasSolidSide. We need to remove isSolidOnSide
@@ -140,213 +140,222 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
// FIXME return this.cb( w, pos ).isSolidOnSide( side );
// FIXME }
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
// FIXME: Potentially check the fluid one too
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty();
}
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
// FIXME: Potentially check the fluid one too
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty();
}
@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
boolean willHarvest, IFluidState fluid) {
if (player.abilities.isCreativeMode) {
final AEBaseTile tile = this.getTileEntity(world, pos);
if (tile != null) {
tile.disableDrops();
}
// maybe ray trace?
}
return super.removedByPlayer(state, world, pos, player, willHarvest, fluid);
}
@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) {
if (player.abilities.isCreativeMode) {
final AEBaseTile tile = this.getTileEntity(world, pos);
if (tile != null) {
tile.disableDrops();
}
// maybe ray trace?
}
return super.removedByPlayer(state, world, pos, player, willHarvest, fluid);
}
@Override
public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos,
Direction side) {
if (side == null) {
side = Direction.UP;
}
@Override
public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos, Direction side) {
if (side == null) {
side = Direction.UP;
}
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
}
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
}
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
PlayerEntity player) {
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
if (sp.part != null) {
return sp.part.getItemStack(PartItemStack.PICK);
} else if (sp.facade != null) {
return sp.facade.getItemStack();
}
if (sp.part != null) {
return sp.part.getItemStack(PartItemStack.PICK);
} else if (sp.facade != null) {
return sp.facade.getItemStack();
}
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target,
final ParticleManager effectRenderer) {
@Override
@OnlyIn(Dist.CLIENT)
public boolean addHitEffects(final BlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer) {
// Half the particle rate. Since we're spawning concentrated on a specific spot,
// our particle effect otherwise looks too strong
if (Platform.getRandom().nextBoolean()) {
return true;
}
// Half the particle rate. Since we're spawning concentrated on a specific spot,
// our particle effect otherwise looks too strong
if (Platform.getRandom().nextBoolean()) {
return true;
}
if (target.getType() != Type.BLOCK) {
return false;
}
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z);
if (target.getType() != Type.BLOCK) {
return false;
}
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z);
ICableBusContainer cb = this.cb(world, blockPos);
ICableBusContainer cb = this.cb(world, blockPos);
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState());
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
// We cannot add the effect if we don't have the model
if (!(model instanceof CableBusBakedModel)) {
return true;
}
// We cannot add the effect if we don't have the model
if (!(model instanceof CableBusBakedModel)) {
return true;
}
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
CableBusRenderState renderState = cb.getRenderState();
CableBusRenderState renderState = cb.getRenderState();
// Spawn a particle for one of the particle textures
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
if (texture != null) {
double x = target.getHitVec().x;
double y = target.getHitVec().y;
double z = target.getHitVec().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the
// ability to supply particle textures???
effectRenderer
.addEffect(new CableBusBreakingParticle(world, x, y, z, texture).multiplyParticleScaleBy(0.8F));
}
// Spawn a particle for one of the particle textures
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
if (texture != null) {
double x = target.getHitVec().x;
double y = target.getHitVec().y;
double z = target.getHitVec().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture)
.multiplyParticleScaleBy(0.8F));
}
return true;
}
return true;
}
@Override
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) {
ICableBusContainer cb = this.cb(world, pos);
@Override
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) {
ICableBusContainer cb = this.cb(world, pos);
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState());
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
// We cannot add the effect if we dont have the model
if (!(model instanceof CableBusBakedModel)) {
return true;
}
// We cannot add the effect if we dont have the model
if (!(model instanceof CableBusBakedModel)) {
return true;
}
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
CableBusRenderState renderState = cb.getRenderState();
CableBusRenderState renderState = cb.getRenderState();
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
if (!textures.isEmpty()) {
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
for (int j = 0; j < 4; ++j) {
for (int k = 0; k < 4; ++k) {
for (int l = 0; l < 4; ++l) {
// Randomly select one of the textures if the cable bus has more than just one
// possibility here
final TextureAtlasSprite texture = Platform.pickRandom(textures);
if (!textures.isEmpty()) {
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
for (int j = 0; j < 4; ++j) {
for (int k = 0; k < 4; ++k) {
for (int l = 0; l < 4; ++l) {
// Randomly select one of the textures if the cable bus has more than just one possibility here
final TextureAtlasSprite texture = Platform.pickRandom(textures);
final double x = pos.getX() + (j + 0.5D) / 4.0D;
final double y = pos.getY() + (k + 0.5D) / 4.0D;
final double z = pos.getZ() + (l + 0.5D) / 4.0D;
final double x = pos.getX() + (j + 0.5D) / 4.0D;
final double y = pos.getY() + (k + 0.5D) / 4.0D;
final double z = pos.getZ() + (l + 0.5D) / 4.0D;
// FIXME: Check how this looks, probably like shit, maybe provide parts the
// ability to supply particle textures???
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
effectRenderer.addEffect(effect);
}
}
}
}
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
effectRenderer.addEffect(effect);
}
}
}
}
return true;
}
return true;
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
if (Platform.isServer()) {
this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
}
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (Platform.isServer()) {
this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
}
}
private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) {
final TileEntity te = w.getTileEntity(pos);
ICableBusContainer out = null;
private ICableBusContainer cb(final IBlockReader w, final BlockPos pos) {
final TileEntity te = w.getTileEntity(pos);
ICableBusContainer out = null;
if (te instanceof TileCableBus) {
out = ((TileCableBus) te).getCableBus();
}
if (te instanceof TileCableBus) {
out = ((TileCableBus) te).getCableBus();
}
return out == null ? NULL_CABLE_BUS : out;
}
return out == null ? NULL_CABLE_BUS : out;
}
@Nullable
private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) {
final TileEntity te = w.getTileEntity(pos);
IFacadeContainer out = null;
@Nullable
private IFacadeContainer fc(final IBlockReader w, final BlockPos pos) {
final TileEntity te = w.getTileEntity(pos);
IFacadeContainer out = null;
if (te instanceof TileCableBus) {
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
}
if (te instanceof TileCableBus) {
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
}
return out;
}
return out;
}
@Override
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if (worldIn.isRemote()) {
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
if (rtr instanceof BlockRayTraceResult) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
@Override
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if (worldIn.isRemote()) {
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
if (rtr instanceof BlockRayTraceResult) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance().sendToServer(new PacketClick(pos, brtr.getFace(), (float) hitVec.x,
(float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
}
}
}
}
}
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance()
.sendToServer(
new PacketClick(pos, brtr.getFace(), (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
}
}
}
}
}
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) {
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
}
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) {
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
}
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
// Transform from world into block space
Vec3d hitVec = hit.getHitVec();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS : ActionResultType.PASS;
}
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
// Transform from world into block space
Vec3d hitVec = hit.getHitVec();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS
: ActionResultType.PASS;
}
@Override
public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) {
return recolorBlock(world, pos, side, color, null);
}
@Override
public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) {
return recolorBlock(world, pos, side, color, null);
}
public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side,
final DyeColor color, final PlayerEntity who) {
try {
return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
} catch (final Throwable ignored) {
}
return false;
}
public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side, final DyeColor color, final PlayerEntity who) {
try {
return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
} catch (final Throwable ignored) {
}
return false;
}
@Override
@OnlyIn(Dist.CLIENT)
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
// do nothing
}
@Override
@OnlyIn(Dist.CLIENT)
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
// do nothing
}
// FIXME FACADES @Override
// FIXME FACADES public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side )
@@ -366,40 +375,38 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
// FIXME FACADES return world.getBlockState( pos );
// FIXME FACADES }
@Override
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
@Override
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
TileCableBus te = getTileEntity(w, pos);
VoxelShape result = VoxelShapes.empty();
if (te != null) {
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), true)) {
result = VoxelShapes.or(
result,
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))
);
}
}
return result;
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
TileCableBus te = getTileEntity(w, pos);
VoxelShape result = VoxelShapes.empty();
if (te != null) {
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true,
context.getEntity(), true)) {
result = VoxelShapes.or(result,
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)));
}
}
return result;
}
}
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
TileCableBus te = getTileEntity(w, pos);
VoxelShape result = VoxelShapes.empty();
if (te != null) {
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true, context.getEntity(), false)) {
result = VoxelShapes.or(
result,
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ))
);
}
}
return result;
// FIXME: this has to be cached, optimized, fixed in all kinds of ways
TileCableBus te = getTileEntity(w, pos);
VoxelShape result = VoxelShapes.empty();
if (te != null) {
for (final AxisAlignedBB bx : te.getCableBus().getSelectedBoundingBoxesFromPool(false, true,
context.getEntity(), false)) {
result = VoxelShapes.or(result,
VoxelShapes.create(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ)));
}
}
return result;
}
}
}
@@ -18,11 +18,9 @@
package appeng.block.networking;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Direction;
@@ -35,121 +33,109 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.TileController;
public class BlockController extends AEBaseTileBlock<TileController> {
public class BlockController extends AEBaseTileBlock<TileController>
{
public enum ControllerBlockState implements IStringSerializable {
offline, online, conflicted;
public enum ControllerBlockState implements IStringSerializable
{
offline, online, conflicted;
@Override
public String getName() {
return this.name();
}
@Override
public String getName()
{
return this.name();
}
}
}
/**
* Controls the rendering of the controller block (connected texture style).
* inside_a and inside_b are alternating patterns for a controller that is
* enclosed by other controllers, and since they are always offline, they do not
* have the usual sub-states.
*/
public enum ControllerRenderType implements IStringSerializable {
block, column_x, column_y, column_z, inside_a, inside_b;
/**
* Controls the rendering of the controller block (connected texture style).
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers,
* and since they are always offline, they do not have the usual sub-states.
*/
public enum ControllerRenderType implements IStringSerializable
{
block, column_x, column_y, column_z, inside_a, inside_b;
@Override
public String getName() {
return this.name();
}
@Override
public String getName()
{
return this.name();
}
}
}
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create("state",
ControllerBlockState.class);
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create( "state", ControllerBlockState.class );
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create("type",
ControllerRenderType.class);
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create( "type", ControllerRenderType.class );
public BlockController() {
super(defaultProps(Material.IRON).hardnessAndResistance(6));
this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline)
.with(CONTROLLER_TYPE, ControllerRenderType.block));
}
public BlockController()
{
super( defaultProps(Material.IRON).hardnessAndResistance(6) );
this.setDefaultState( this.getDefaultState()
.with( CONTROLLER_STATE, ControllerBlockState.offline )
.with( CONTROLLER_TYPE, ControllerRenderType.block ) );
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(CONTROLLER_STATE);
builder.add(CONTROLLER_TYPE);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(CONTROLLER_STATE);
builder.add(CONTROLLER_TYPE);
}
/**
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block
* states based on adjacent controllers and the network state of this controller
* (offline, online, conflicted). This is used to get a rudimentary connected
* texture feel for the controller based on how it is placed.
*/
@Override
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world,
BlockPos pos, BlockPos facingPos) {
/**
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent
* controllers and the network state of this controller (offline, online, conflicted). This is used to
* get a rudimentary connected texture feel for the controller based on how it is placed.
*/
@Override
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
// Only used for columns, really
ControllerRenderType type = ControllerRenderType.block;
// Only used for columns, really
ControllerRenderType type = ControllerRenderType.block;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
// Detect whether controllers are on both sides of the x, y, and z axes
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
&& this.getTileEntity(world, x + 1, y, z) != null;
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
&& this.getTileEntity(world, x, y + 1, z) != null;
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
&& this.getTileEntity(world, x, y, z + 1) != null;
// Detect whether controllers are on both sides of the x, y, and z axes
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
&& this.getTileEntity(world, x + 1, y, z) != null;
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
&& this.getTileEntity(world, x, y + 1, z) != null;
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
&& this.getTileEntity(world, x, y, z + 1) != null;
if (xx && !yy && !zz) {
type = ControllerRenderType.column_x;
} else if (!xx && yy && !zz) {
type = ControllerRenderType.column_y;
} else if (!xx && !yy && zz) {
type = ControllerRenderType.column_z;
} else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) {
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;
if( xx && !yy && !zz )
{
type = ControllerRenderType.column_x;
}
else if( !xx && yy && !zz )
{
type = ControllerRenderType.column_y;
}
else if( !xx && !yy && zz )
{
type = ControllerRenderType.column_z;
}
else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 )
{
final int v = ( Math.abs( x ) + Math.abs( y ) + Math.abs( z ) ) % 2;
// While i'd like this to be based on the blockstate randomization feature, this
// generates
// an alternating pattern based on world position, so this is not 100% doable
// with blockstates.
if (v == 0) {
type = ControllerRenderType.inside_a;
} else {
type = ControllerRenderType.inside_b;
}
}
// While i'd like this to be based on the blockstate randomization feature, this generates
// an alternating pattern based on world position, so this is not 100% doable with blockstates.
if( v == 0 )
{
type = ControllerRenderType.inside_a;
}
else
{
type = ControllerRenderType.inside_b;
}
}
return state.with(CONTROLLER_TYPE, type);
}
return state.with( CONTROLLER_TYPE, type );
}
@Override
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
{
final TileController tc = this.getTileEntity( world, pos );
if( tc != null )
{
tc.onNeighborChange( false );
}
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final TileController tc = this.getTileEntity(world, pos);
if (tc != null) {
tc.onNeighborChange(false);
}
}
}
@@ -18,17 +18,13 @@
package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileCreativeEnergyCell;
public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyCell> {
public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyCell>
{
public BlockCreativeEnergyCell()
{
super( defaultProps(AEGlassMaterial.INSTANCE) );
}
public BlockCreativeEnergyCell() {
super(defaultProps(AEGlassMaterial.INSTANCE));
}
}
@@ -18,18 +18,14 @@
package appeng.block.networking;
public class BlockDenseEnergyCell extends BlockEnergyCell {
public class BlockDenseEnergyCell extends BlockEnergyCell
{
public BlockDenseEnergyCell() {
public BlockDenseEnergyCell()
{
}
}
@Override
public double getMaxPower()
{
return 200000.0 * 8.0;
}
@Override
public double getMaxPower() {
return 200000.0 * 8.0;
}
}
@@ -18,19 +18,15 @@
package appeng.block.networking;
import appeng.tile.networking.TileEnergyAcceptor;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.TileEnergyAcceptor;
public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor> {
public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor>
{
public BlockEnergyAcceptor()
{
super(defaultProps(Material.IRON) );
}
public BlockEnergyAcceptor() {
super(defaultProps(Material.IRON));
}
}
@@ -18,8 +18,6 @@
package appeng.block.networking;
import appeng.tile.networking.TileEnergyCell;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemGroup;
@@ -33,40 +31,37 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileEnergyCell;
public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell>
{
public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell> {
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create( "fullness", 0, 7 );
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7);
public BlockEnergyCell()
{
super( defaultProps(AEGlassMaterial.INSTANCE) );
}
public BlockEnergyCell() {
super(defaultProps(AEGlassMaterial.INSTANCE));
}
@Override
@OnlyIn( Dist.CLIENT )
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
{
super.fillItemGroup( group, itemStacks );
@Override
@OnlyIn(Dist.CLIENT)
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks) {
super.fillItemGroup(group, itemStacks);
final ItemStack charged = new ItemStack(this, 1);
final CompoundNBT tag = charged.getOrCreateTag();
tag.putDouble("internalCurrentPower", this.getMaxPower());
tag.putDouble("internalMaxPower", this.getMaxPower());
final ItemStack charged = new ItemStack(this, 1);
final CompoundNBT tag = charged.getOrCreateTag();
tag.putDouble("internalCurrentPower", this.getMaxPower());
tag.putDouble("internalMaxPower", this.getMaxPower());
itemStacks.add(charged);
}
itemStacks.add(charged);
}
public double getMaxPower()
{
return 200000.0;
}
public double getMaxPower() {
return 200000.0;
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(ENERGY_STORAGE);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(ENERGY_STORAGE);
}
}
@@ -18,7 +18,6 @@
package appeng.block.networking;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -28,21 +27,17 @@ import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
// FIXME REMOVE
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
{
public class BlockEnergyCellRendering extends BlockRenderingCustomizer {
private final ResourceLocation baseModel;
private final ResourceLocation baseModel;
public BlockEnergyCellRendering( ResourceLocation baseModel )
{
this.baseModel = baseModel;
}
public BlockEnergyCellRendering(ResourceLocation baseModel) {
this.baseModel = baseModel;
}
@Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
// Note: Since we use the block models, we dont need to register custom variants
}
@Override
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// Note: Since we use the block models, we dont need to register custom variants
}
}
@@ -18,14 +18,6 @@
package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerWireless;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
@@ -46,200 +38,192 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerWireless;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseTileBlock<TileWireless>
{
public class BlockWireless extends AEBaseTileBlock<TileWireless> {
enum State implements IStringSerializable
{
OFF,
ON,
HAS_CHANNEL;
enum State implements IStringSerializable {
OFF, ON, HAS_CHANNEL;
@Override
public String getName()
{
return this.name().toLowerCase();
}
}
@Override
public String getName() {
return this.name().toLowerCase();
}
}
public static final EnumProperty<State> STATE = EnumProperty.create( "state", State.class );
public static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
public BlockWireless()
{
super( defaultProps(AEGlassMaterial.INSTANCE).notSolid() );
this.setFullSize( false );
this.setOpaque( false );
this.setDefaultState( this.getDefaultState().with( STATE, State.OFF ) );
}
public BlockWireless() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid());
this.setFullSize(false);
this.setOpaque(false);
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) {
State teState = State.OFF;
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileWireless te) {
State teState = State.OFF;
if( te.isActive() )
{
teState = State.HAS_CHANNEL;
}
else if( te.isPowered() )
{
teState = State.ON;
}
if (te.isActive()) {
teState = State.HAS_CHANNEL;
} else if (te.isPowered()) {
teState = State.ON;
}
return currentState.with(STATE, teState);
}
return currentState.with(STATE, teState);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(STATE);
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(STATE);
}
@Override
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
final TileWireless tg = this.getTileEntity( w, pos );
@Override
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand,
BlockRayTraceResult hit) {
final TileWireless tg = this.getTileEntity(w, pos);
if( tg != null && !player.isCrouching() )
{
if( Platform.isServer() )
{
ContainerOpener.openContainer(ContainerWireless.TYPE, player, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
}
return ActionResultType.SUCCESS;
}
if (tg != null && !player.isCrouching()) {
if (Platform.isServer()) {
ContainerOpener.openContainer(ContainerWireless.TYPE, player,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
}
return ActionResultType.SUCCESS;
}
return super.onBlockActivated( state, w, pos, player, hand, hit );
}
return super.onBlockActivated(state, w, pos, player, hand, hit);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
final TileWireless tile = this.getTileEntity( w, pos );
if( tile != null )
{
final Direction forward = tile.getForward();
@Override
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
final TileWireless tile = this.getTileEntity(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;
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch( forward )
{
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
switch (forward) {
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
}
return VoxelShapes.empty();
}
return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
}
return VoxelShapes.empty();
}
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
final TileWireless tile = this.getTileEntity( w, pos );
if( tile != null )
{
final Direction forward = tile.getForward();
final TileWireless tile = this.getTileEntity(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;
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 1;
double maxY = 1;
double maxZ = 1;
switch( forward )
{
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
switch (forward) {
case DOWN:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 1.0;
minY = 5.0 / 16.0;
break;
case EAST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 11.0 / 16.0;
minX = 0.0;
break;
case NORTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 1.0;
minZ = 5.0 / 16.0;
break;
case SOUTH:
minY = minX = 3.0 / 16.0;
maxY = maxX = 13.0 / 16.0;
maxZ = 11.0 / 16.0;
minZ = 0.0;
break;
case UP:
minZ = minX = 3.0 / 16.0;
maxZ = maxX = 13.0 / 16.0;
maxY = 11.0 / 16.0;
minY = 0.0;
break;
case WEST:
minZ = minY = 3.0 / 16.0;
maxZ = maxY = 13.0 / 16.0;
maxX = 1.0;
minX = 5.0 / 16.0;
break;
default:
break;
}
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
}
else
{
return VoxelShapes.empty();
}
}
return VoxelShapes.create(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
} else {
return VoxelShapes.empty();
}
}
@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
}
@@ -18,9 +18,8 @@
package appeng.block.networking;
import javax.annotation.Nullable;
import appeng.parts.CableBusContainer;
import appeng.tile.networking.TileCableBus;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.tileentity.TileEntity;
@@ -32,32 +31,31 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
import javax.annotation.Nullable;
import appeng.parts.CableBusContainer;
import appeng.tile.networking.TileCableBus;
/**
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant).
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium
* variant) and 2 (bright variant).
*/
@OnlyIn( Dist.CLIENT )
public class CableBusColor implements IBlockColor
{
@OnlyIn(Dist.CLIENT)
public class CableBusColor implements IBlockColor {
@Override
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
@Override
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
// FIXME: Once COLOR becomes part of the block state, change this
AEColor busColor = AEColor.TRANSPARENT;
// FIXME: Once COLOR becomes part of the block state, change this
AEColor busColor = AEColor.TRANSPARENT;
if (worldIn != null && pos != null) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileCableBus) {
CableBusContainer container = ((TileCableBus) tileEntity).getCableBus();
busColor = container.getColor();
}
}
if (worldIn != null && pos != null) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileCableBus) {
CableBusContainer container = ((TileCableBus) tileEntity).getCableBus();
busColor = container.getColor();
}
}
return busColor.getVariantByTintIndex( color );
return busColor.getVariantByTintIndex(color);
}
}
}
@@ -18,7 +18,6 @@
package appeng.block.networking;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -28,28 +27,24 @@ import appeng.bootstrap.IItemRendering;
import appeng.client.render.cablebus.CableBusModel;
import appeng.core.features.registries.PartModels;
/**
* Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2.
* Customizes the rendering behavior for cable busses, which are the biggest
* multipart of AE2.
*/
public class CableBusRendering extends BlockRenderingCustomizer
{
public class CableBusRendering extends BlockRenderingCustomizer {
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
/* FIXME this was previously
*
@Override
public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer )
{
return true;
}
*/
rendering.renderType(rt -> true);
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
/*
* FIXME this was previously
*
* @Override public boolean canRenderInLayer( BlockState state, BlockRenderLayer
* layer ) { return true; }
*/
rendering.renderType(rt -> true);
rendering.blockColor( new CableBusColor() );
rendering.modelCustomizer( ( loc, model ) -> model );
}
rendering.blockColor(new CableBusColor());
rendering.modelCustomizer((loc, model) -> model);
}
}
@@ -18,20 +18,17 @@
package appeng.block.networking;
import net.minecraft.client.renderer.RenderType;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import net.minecraft.client.renderer.RenderType;
public class ControllerRendering extends BlockRenderingCustomizer
{
@Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
// Disables the default model rotator
rendering.modelCustomizer( ( loc, model ) -> model );
rendering.renderType(RenderType.getCutout());
}
public class ControllerRendering extends BlockRenderingCustomizer {
@Override
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// Disables the default model rotator
rendering.modelCustomizer((loc, model) -> model);
rendering.renderType(RenderType.getCutout());
}
}
@@ -1,7 +1,6 @@
package appeng.block.networking;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -12,14 +11,11 @@ import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.client.render.StaticBlockColor;
public class WirelessRendering extends BlockRenderingCustomizer
{
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.renderType(RenderType.getCutout());
rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) );
}
public class WirelessRendering extends BlockRenderingCustomizer {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
}
}