Lots more moved
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.CraftingCPUContainer;
|
||||
import appeng.tile.crafting.CraftingBlockEntity;
|
||||
|
||||
public abstract class AbstractCraftingUnitBlock<T extends CraftingBlockEntity> extends AEBaseTileBlock<T> {
|
||||
public static final BooleanProperty FORMED = BooleanProperty.of("formed");
|
||||
public static final BooleanProperty POWERED = BooleanProperty.of("powered");
|
||||
|
||||
public final CraftingUnitType type;
|
||||
|
||||
public AbstractCraftingUnitBlock(Settings props, final CraftingUnitType type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(FORMED, false).with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
|
||||
final BlockPos fromPos, boolean isMoving) {
|
||||
final CraftingBlockEntity cp = this.getBlockEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final CraftingBlockEntity cp = this.getBlockEntity(w, pos);
|
||||
if (cp != null) {
|
||||
cp.breakCluster();
|
||||
}
|
||||
|
||||
super.onStateReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
|
||||
BlockHitResult hit) {
|
||||
final CraftingBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
|
||||
if (tg != null && !p.isInSneakingPose() && tg.isFormed() && tg.isActive()) {
|
||||
if (!w.isClient()) {
|
||||
ContainerOpener.openContainer(CraftingCPUContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onUse(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
public enum CraftingUnitType {
|
||||
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import appeng.tile.crafting.CraftingMonitorBlockEntity;
|
||||
|
||||
public class CraftingMonitorBlock extends AbstractCraftingUnitBlock<CraftingMonitorBlockEntity> {
|
||||
public CraftingMonitorBlock(Settings props) {
|
||||
super(props, CraftingUnitType.MONITOR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import appeng.tile.crafting.CraftingStorageBlockEntity;
|
||||
|
||||
public class CraftingStorageBlock extends AbstractCraftingUnitBlock<CraftingStorageBlockEntity> {
|
||||
|
||||
public CraftingStorageBlock(Settings props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlockItem;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class CraftingStorageItem extends AEBaseBlockItem {
|
||||
|
||||
public CraftingStorageItem(Block id, Settings props) {
|
||||
super(id, props);
|
||||
}
|
||||
|
||||
// FIXME FABRIC needs to move to disassembly crafting recipes
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public Item getRecipeRemainder() {
|
||||
// FIXME FABRIC return AEApi.instance().definitions().blocks().craftingUnit().item();
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public boolean hasRecipeRemainder() {
|
||||
// FIXME FABRIC return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
|
||||
// FIXME FABRIC }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import appeng.tile.crafting.CraftingBlockEntity;
|
||||
|
||||
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<CraftingBlockEntity> {
|
||||
|
||||
public CraftingUnitBlock(Settings props, CraftingUnitType type) {
|
||||
super(props, type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.MolecularAssemblerContainer;
|
||||
import appeng.tile.crafting.MolecularAssemblerBlockEntity;
|
||||
|
||||
public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerBlockEntity> {
|
||||
|
||||
public static final BooleanProperty POWERED = BooleanProperty.of("powered");
|
||||
|
||||
public MolecularAssemblerBlock(Settings props) {
|
||||
super(props);
|
||||
setDefaultState(getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, MolecularAssemblerBlockEntity te) {
|
||||
return currentState.with(POWERED, te.isPowered());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
|
||||
BlockHitResult hit) {
|
||||
final MolecularAssemblerBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null && !p.isInSneakingPose()) {
|
||||
if (!tg.isClient()) {
|
||||
ContainerOpener.openContainer(MolecularAssemblerContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onUse(state, w, pos, p, hand, hit);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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.grindstone;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.util.FakePlayer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.stats.AeStats;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.tile.grindstone.CrankBlockEntity;
|
||||
|
||||
public class CrankBlock extends AEBaseTileBlock<CrankBlockEntity> {
|
||||
|
||||
public CrankBlock(Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (FakePlayer.isFakePlayer(player) || player == null) {
|
||||
this.dropCrank(w, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
final CrankBlockEntity tile = this.getBlockEntity(w, pos);
|
||||
if (tile != null) {
|
||||
if (tile.power()) {
|
||||
AeStats.TurnedCranks.addToPlayer(player, 1);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
private void dropCrank(final World world, final BlockPos pos) {
|
||||
world.breakBlock(pos, true);
|
||||
world.updateListeners(pos, this.getDefaultState(), world.getBlockState(pos), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(final World world, final BlockPos pos, final BlockState state,
|
||||
final LivingEntity placer, final ItemStack stack) {
|
||||
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
|
||||
if (tile != null) {
|
||||
final Direction mnt = this.findCrankable(world, pos);
|
||||
Direction forward = Direction.UP;
|
||||
if (mnt == Direction.UP || mnt == Direction.DOWN) {
|
||||
forward = Direction.SOUTH;
|
||||
}
|
||||
tile.setOrientation(forward, mnt.getOpposite());
|
||||
} else {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
|
||||
final BlockEntity te = w.getBlockEntity(pos);
|
||||
return !(te instanceof CrankBlockEntity) || this.isCrankable(w, pos, up.getOpposite());
|
||||
}
|
||||
|
||||
private Direction findCrankable(final BlockView world, final BlockPos pos) {
|
||||
for (final Direction dir : Direction.values()) {
|
||||
if (this.isCrankable(world, pos, dir)) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isCrankable(final BlockView world, final BlockPos pos, final Direction offset) {
|
||||
final BlockPos o = pos.offset(offset);
|
||||
final BlockEntity te = world.getBlockEntity(o);
|
||||
|
||||
return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
|
||||
if (tile != null) {
|
||||
if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
} else {
|
||||
this.dropCrank(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView w, BlockPos pos) {
|
||||
return this.findCrankable(w, pos) != null;
|
||||
}
|
||||
|
||||
private Direction getUp(BlockView world, BlockPos pos) {
|
||||
CrankBlockEntity crank = getBlockEntity(world, pos);
|
||||
return crank != null ? crank.getUp() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
Direction up = getUp(world, pos);
|
||||
|
||||
if (up == null) {
|
||||
return VoxelShapes.empty();
|
||||
} else {
|
||||
// FIXME: Cache per direction, and build it 'precise', not just from AABB
|
||||
final double xOff = -0.15 * up.getOffsetX();
|
||||
final double yOff = -0.15 * up.getOffsetY();
|
||||
final double zOff = -0.15 * up.getOffsetZ();
|
||||
return VoxelShapes.cuboid(
|
||||
new Box(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.grindstone;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.GrinderContainer;
|
||||
import appeng.tile.grindstone.GrinderBlockEntity;
|
||||
|
||||
public class GrinderBlock extends AEBaseTileBlock<GrinderBlockEntity> {
|
||||
|
||||
public GrinderBlock(Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
final GrinderBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null && !p.isInSneakingPose()) {
|
||||
if (p instanceof ServerPlayerEntity) {
|
||||
ContainerOpener.openContainer(GrinderContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.CellWorkbenchContainer;
|
||||
import appeng.tile.misc.CellWorkbenchBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchBlockEntity> {
|
||||
|
||||
public CellWorkbenchBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final CellWorkbenchBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
CellWorkbenchContainer.open(p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.render.model.json.Transformation;
|
||||
import net.minecraft.client.util.math.AffineTransformation;
|
||||
import net.minecraft.util.math.Box;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
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.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.ChargerBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
|
||||
|
||||
public ChargerBlock() {
|
||||
super(defaultProps(Material.METAL).solidBlock((state, world, pos) -> false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, BlockView worldIn, BlockPos pos) {
|
||||
return 2; // FIXME Double check this (esp. value range)
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (player.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (Platform.isServer()) {
|
||||
final ChargerBlockEntity tc = this.getBlockEntity(w, pos);
|
||||
if (tc != null) {
|
||||
tc.activate(player);
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (r.nextFloat() < 0.98) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
|
||||
if (tile != null) {
|
||||
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
|
||||
.isSameAs(tile.getInternalInventory().getInvStack(0))) {
|
||||
final double xOff = 0.0;
|
||||
final double yOff = 0.0;
|
||||
final double zOff = 0.0;
|
||||
|
||||
for (int bolts = 0; bolts < 3; bolts++) {
|
||||
if (AppEng.instance().shouldAddParticles(r)) {
|
||||
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(),
|
||||
yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
|
||||
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
|
||||
if (tile != null) {
|
||||
final double twoPixels = 2.0 / 16.0;
|
||||
final Direction up = tile.getUp();
|
||||
final Direction forward = tile.getForward();
|
||||
final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels,
|
||||
1.0 - twoPixels, 1.0 - twoPixels);
|
||||
|
||||
if (up.getOffsetX() != 0) {
|
||||
bb.minX = 0;
|
||||
bb.maxX = 1;
|
||||
}
|
||||
if (up.getOffsetY() != 0) {
|
||||
bb.minY = 0;
|
||||
bb.maxY = 1;
|
||||
}
|
||||
if (up.getOffsetZ() != 0) {
|
||||
bb.minZ = 0;
|
||||
bb.maxZ = 1;
|
||||
}
|
||||
|
||||
switch (forward) {
|
||||
case DOWN:
|
||||
bb.maxY = 1;
|
||||
break;
|
||||
case UP:
|
||||
bb.minY = 0;
|
||||
break;
|
||||
case NORTH:
|
||||
bb.maxZ = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
bb.minZ = 0;
|
||||
break;
|
||||
case EAST:
|
||||
bb.minX = 0;
|
||||
break;
|
||||
case WEST:
|
||||
bb.maxX = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VoxelShapes.cuboid(bb.getBoundingBox());
|
||||
}
|
||||
return VoxelShapes.cuboid(new Box(0.0, 0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView worldIn, BlockPos pos,
|
||||
ShapeContext context) {
|
||||
return VoxelShapes.cuboid(new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static Function<BlockEntityRenderDispatcher, BlockEntityRenderer<ChargerBlockEntity>> createTesr() {
|
||||
return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(ChargerBlock::getRenderedItem));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private static Pair<ItemStack, Transformation> getRenderedItem(ChargerBlockEntity tile) {
|
||||
Transformation transform = new Transformation(new Vector3f(), new Vector3f(0.5f, 0.375f, 0.5f), new Vector3f(1f, 1f, 1f));
|
||||
return new ImmutablePair<>(tile.getInternalInventory().getInvStack(0), transform);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.CondenserContainer;
|
||||
import appeng.tile.misc.CondenserBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CondenserBlock extends AEBaseTileBlock<CondenserBlockEntity> {
|
||||
|
||||
public CondenserBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (player.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (Platform.isServer()) {
|
||||
final CondenserBlockEntity tc = this.getBlockEntity(w, pos);
|
||||
if (tc != null && !player.isInSneakingPose()) {
|
||||
ContainerOpener.openContainer(CondenserContainer.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tc, hit.getSide()));
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.InscriberContainer;
|
||||
import appeng.tile.misc.InscriberBlockEntity;
|
||||
|
||||
public class InscriberBlock extends AEBaseTileBlock<InscriberBlockEntity> {
|
||||
|
||||
public InscriberBlock(Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, BlockView worldIn, BlockPos pos) {
|
||||
return 2; // FIXME validate this. a) possibly not required because of getShape b) value
|
||||
// range. was 2 in 1.10
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (!p.isInSneakingPose()) {
|
||||
final InscriberBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (!tg.isClient()) {
|
||||
ContainerOpener.openContainer(InscriberContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.bootstrap.TileEntityRendering;
|
||||
import appeng.bootstrap.TileEntityRenderingCustomizer;
|
||||
import appeng.client.render.tesr.InscriberTESR;
|
||||
import appeng.tile.misc.InscriberBlockEntity;
|
||||
|
||||
public class InscriberRendering implements TileEntityRenderingCustomizer<InscriberBlockEntity> {
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void customize(TileEntityRendering<InscriberBlockEntity> rendering) {
|
||||
rendering.tileEntityRenderer(InscriberTESR::new);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.property.BooleanProperty;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.InterfaceContainer;
|
||||
import appeng.tile.misc.InterfaceBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class InterfaceBlock extends AEBaseTileBlock<InterfaceBlockEntity> {
|
||||
|
||||
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.of("omnidirectional");
|
||||
|
||||
public InterfaceBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(OMNIDIRECTIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, InterfaceBlockEntity te) {
|
||||
return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final InterfaceBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(InterfaceContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCustomRotation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRotateBlock(final IOrientable rotatable, final Direction axis) {
|
||||
if (rotatable instanceof InterfaceBlockEntity) {
|
||||
((InterfaceBlockEntity) rotatable).setSide(axis);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.QuartzGrowthAcceleratorBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorBlockEntity>
|
||||
implements IOrientableBlock {
|
||||
|
||||
private static final BooleanProperty POWERED = BooleanProperty.of("powered");
|
||||
|
||||
public QuartzGrowthAcceleratorBlock() {
|
||||
super(defaultProps(Material.STONE).sounds(BlockSoundGroup.METAL));
|
||||
this.setDefaultState(this.getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuartzGrowthAcceleratorBlockEntity te) {
|
||||
return currentState.with(POWERED, te.isPowered());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Override
|
||||
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final QuartzGrowthAcceleratorBlockEntity cga = this.getBlockEntity(w, pos);
|
||||
|
||||
if (cga != null && cga.isPowered() && AppEng.instance().shouldAddParticles(r)) {
|
||||
final double d0 = r.nextFloat() - 0.5F;
|
||||
final double d1 = r.nextFloat() - 0.5F;
|
||||
|
||||
final Direction up = cga.getUp();
|
||||
final Direction forward = cga.getForward();
|
||||
final Direction west = Platform.crossProduct(forward, up);
|
||||
|
||||
double rx = 0.5 + pos.getX();
|
||||
double ry = 0.5 + pos.getY();
|
||||
double rz = 0.5 + pos.getZ();
|
||||
|
||||
rx += up.getOffsetX() * d0;
|
||||
ry += up.getOffsetY() * d0;
|
||||
rz += up.getOffsetZ() * d0;
|
||||
|
||||
final int x = pos.getX();
|
||||
final int y = pos.getY();
|
||||
final int z = pos.getZ();
|
||||
|
||||
double dz = 0;
|
||||
double dx = 0;
|
||||
BlockPos pt = null;
|
||||
|
||||
switch (r.nextInt(4)) {
|
||||
case 0:
|
||||
dx = 0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos(x + west.getOffsetX(), y + west.getOffsetY(), z + west.getOffsetZ());
|
||||
|
||||
break;
|
||||
case 1:
|
||||
dx = d1;
|
||||
dz += 0.6;
|
||||
pt = new BlockPos(x + forward.getOffsetX(), y + forward.getOffsetY(), z + forward.getOffsetZ());
|
||||
|
||||
break;
|
||||
case 2:
|
||||
dx = d1;
|
||||
dz = -0.6;
|
||||
pt = new BlockPos(x - forward.getOffsetX(), y - forward.getOffsetY(), z - forward.getOffsetZ());
|
||||
|
||||
break;
|
||||
case 3:
|
||||
dx = -0.6;
|
||||
dz = d1;
|
||||
pt = new BlockPos(x - west.getOffsetX(), y - west.getOffsetY(), z - west.getOffsetZ());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!w.getBlockState(pt).isAir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rx += dx * west.getOffsetX();
|
||||
ry += dx * west.getOffsetY();
|
||||
rz += dx * west.getOffsetZ();
|
||||
|
||||
rx += dz * forward.getOffsetX();
|
||||
ry += dz * forward.getOffsetY();
|
||||
rz += dz * forward.getOffsetZ();
|
||||
|
||||
MinecraftClient.getInstance().particleManager.addParticle(ParticleTypes.LIGHTNING, rx, ry, rz, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.SecurityStationContainer;
|
||||
import appeng.tile.misc.SecurityStationBlockEntity;
|
||||
|
||||
public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationBlockEntity> {
|
||||
|
||||
private static final BooleanProperty POWERED = BooleanProperty.of("powered");
|
||||
|
||||
public SecurityStationBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
|
||||
this.setDefaultState(this.getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, SecurityStationBlockEntity te) {
|
||||
return currentState.with(POWERED, te.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final SecurityStationBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (w.isClient()) {
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
ContainerOpener.openContainer(SecurityStationContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.ColorableTileBlockColor;
|
||||
import appeng.client.render.StaticItemColor;
|
||||
|
||||
public class SecurityStationRendering extends BlockRenderingCustomizer {
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
rendering.blockColor(ColorableTileBlockColor.INSTANCE);
|
||||
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.VibrationChamberContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.misc.VibrationChamberBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChamberBlockEntity> {
|
||||
|
||||
// Indicates that the vibration chamber is currently working
|
||||
private static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||
|
||||
public VibrationChamberBlock() {
|
||||
super(defaultProps(Material.METAL).strength(4.2F));
|
||||
this.setDefaultState(this.getDefaultState().with(ACTIVE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, VibrationChamberBlockEntity te) {
|
||||
return currentState.with(ACTIVE, te.isOn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (player.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (Platform.isServer()) {
|
||||
final VibrationChamberBlockEntity tc = this.getBlockEntity(w, pos);
|
||||
if (tc != null && !player.isInSneakingPose()) {
|
||||
ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tc, hit.getSide()));
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random r) {
|
||||
if (!AEConfig.instance().isEnableEffects()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final VibrationChamberBlockEntity tile = this.getBlockEntity(w, pos);
|
||||
if (tile != null && tile.isOn) {
|
||||
double f1 = pos.getX() + 0.5F;
|
||||
double f2 = pos.getY() + 0.5F;
|
||||
double f3 = pos.getZ() + 0.5F;
|
||||
|
||||
final Direction forward = tile.getForward();
|
||||
final Direction up = tile.getUp();
|
||||
|
||||
final int west_x = forward.getOffsetY() * up.getOffsetZ() - forward.getOffsetZ() * up.getOffsetY();
|
||||
final int west_y = forward.getOffsetZ() * up.getOffsetX() - forward.getOffsetX() * up.getOffsetZ();
|
||||
final int west_z = forward.getOffsetX() * up.getOffsetY() - forward.getOffsetY() * up.getOffsetX();
|
||||
|
||||
f1 += forward.getOffsetX() * 0.6;
|
||||
f2 += forward.getOffsetY() * 0.6;
|
||||
f3 += forward.getOffsetZ() * 0.6;
|
||||
|
||||
final double ox = r.nextDouble();
|
||||
final double oy = r.nextDouble() * 0.2f;
|
||||
|
||||
f1 += up.getOffsetX() * (-0.3 + oy);
|
||||
f2 += up.getOffsetY() * (-0.3 + oy);
|
||||
f3 += up.getOffsetZ() * (-0.3 + oy);
|
||||
|
||||
f1 += west_x * (0.3 * ox - 0.15);
|
||||
f2 += west_y * (0.3 * ox - 0.15);
|
||||
f3 += west_z * (0.3 * ox - 0.15);
|
||||
|
||||
w.addParticle(ParticleTypes.SMOKE, f1, f2, f3, 0.0D, 0.0D, 0.0D);
|
||||
w.addParticle(ParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,8 +158,8 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implemen
|
||||
// FIXME FABRIC Hook does not exist
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||
// FIXME FABRIC boolean willHarvest, IFluidState fluid) {
|
||||
// FIXME FABRIC if (player.abilities.isCreativeMode) {
|
||||
// FIXME FABRIC boolean willHarvest, FluidState fluid) {
|
||||
// FIXME FABRIC if (player.isCreative()) {
|
||||
// FIXME FABRIC final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
|
||||
// FIXME FABRIC if (tile != null) {
|
||||
// FIXME FABRIC tile.disableDrops();
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import appeng.tile.networking.ControllerBlockEntity;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
|
||||
|
||||
public enum ControllerBlockState implements StringIdentifiable {
|
||||
offline, online, conflicted;
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
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 StringIdentifiable {
|
||||
block, column_x, column_y, column_z, inside_a, inside_b;
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.of("state",
|
||||
ControllerBlockState.class);
|
||||
|
||||
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.of("type",
|
||||
ControllerRenderType.class);
|
||||
|
||||
public ControllerBlock() {
|
||||
super(defaultProps(Material.METAL).strength(6));
|
||||
this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline)
|
||||
.with(CONTROLLER_TYPE, ControllerRenderType.block));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(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 getStateForNeighborUpdate(BlockState state, Direction facing, BlockState facingState, WorldAccess world,
|
||||
BlockPos pos, BlockPos facingPos) {
|
||||
|
||||
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
|
||||
|
||||
// Only used for columns, really
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
|
||||
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.getBlockEntity(world, x - 1, y, z) != null
|
||||
&& this.getBlockEntity(world, x + 1, y, z) != null;
|
||||
final boolean yy = this.getBlockEntity(world, x, y - 1, z) != null
|
||||
&& this.getBlockEntity(world, x, y + 1, z) != null;
|
||||
final boolean zz = this.getBlockEntity(world, x, y, z - 1) != null
|
||||
&& this.getBlockEntity(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;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final ControllerBlockEntity tc = this.getBlockEntity(world, pos);
|
||||
if (tc != null) {
|
||||
tc.onNeighborChange(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
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(RenderLayer.getCutout());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEMaterials;
|
||||
import appeng.tile.networking.CreativeEnergyCellBlockEntity;
|
||||
|
||||
public class CreativeEnergyCellBlock extends AEBaseTileBlock<CreativeEnergyCellBlockEntity> {
|
||||
|
||||
public CreativeEnergyCellBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
public class DenseEnergyCellBlock extends EnergyCellBlock {
|
||||
|
||||
public DenseEnergyCellBlock() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.networking.EnergyAcceptorBlockEntity;
|
||||
|
||||
public class EnergyAcceptorBlock extends AEBaseTileBlock<EnergyAcceptorBlockEntity> {
|
||||
|
||||
public EnergyAcceptorBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEMaterials;
|
||||
import appeng.tile.networking.EnergyCellBlockEntity;
|
||||
|
||||
public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellBlockEntity> {
|
||||
|
||||
public static final IntProperty ENERGY_STORAGE = IntProperty.of("fullness", 0, 7);
|
||||
|
||||
public EnergyCellBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> itemStacks) {
|
||||
super.addStacksForDisplay(group, itemStacks);
|
||||
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundTag tag = charged.getOrCreateTag();
|
||||
tag.putDouble("internalCurrentPower", this.getMaxPower());
|
||||
tag.putDouble("internalMaxPower", this.getMaxPower());
|
||||
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
|
||||
public double getMaxPower() {
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* 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.networking;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
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.StringIdentifiable;
|
||||
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.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.WirelessContainer;
|
||||
import appeng.helpers.AEMaterials;
|
||||
import appeng.tile.networking.WirelessBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessBlock extends AEBaseTileBlock<WirelessBlockEntity> {
|
||||
|
||||
enum State implements StringIdentifiable {
|
||||
OFF, ON, HAS_CHANNEL;
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static final EnumProperty<State> STATE = EnumProperty.of("state", State.class);
|
||||
|
||||
public WirelessBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS)
|
||||
.nonOpaque()
|
||||
.solidBlock((state, world, pos) -> false)
|
||||
);
|
||||
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, WirelessBlockEntity te) {
|
||||
State teState = State.OFF;
|
||||
|
||||
if (te.isActive()) {
|
||||
teState = State.HAS_CHANNEL;
|
||||
} else if (te.isPowered()) {
|
||||
teState = State.ON;
|
||||
}
|
||||
|
||||
return currentState.with(STATE, teState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand,
|
||||
BlockHitResult hit) {
|
||||
final WirelessBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
|
||||
if (tg != null && !player.isInSneakingPose()) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(WirelessContainer.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onUse(state, w, pos, player, hand, hit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
final WirelessBlockEntity 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 = 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.cuboid(new Box(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
}
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
|
||||
final WirelessBlockEntity 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 = 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.cuboid(new Box(minX, minY, minZ, maxX, maxY, maxZ));
|
||||
} else {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTranslucent(BlockState state, BlockView reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.StaticBlockColor;
|
||||
|
||||
public class WirelessRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.helpers.Splotch;
|
||||
|
||||
/**
|
||||
* Used to transfer the state about paint splotches from the game thread to the
|
||||
* render thread.
|
||||
*/
|
||||
public class PaintSplotches {
|
||||
|
||||
private final List<Splotch> splotches;
|
||||
|
||||
public PaintSplotches(Collection<Splotch> splotches) {
|
||||
this.splotches = ImmutableList.copyOf(splotches);
|
||||
}
|
||||
|
||||
List<Splotch> getSplotches() {
|
||||
return this.splotches;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.Splotch;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Renders paint blocks, which render multiple "splotches" that have been
|
||||
* applied to the sides of adjacent blocks using a matter cannon with paint
|
||||
* balls.
|
||||
*/
|
||||
class PaintSplotchesBakedModel implements BakedModel, FabricBakedModel {
|
||||
|
||||
private static final SpriteIdentifier TEXTURE_PAINT1 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "block/paint1"));
|
||||
private static final SpriteIdentifier TEXTURE_PAINT2 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "block/paint2"));
|
||||
private static final SpriteIdentifier TEXTURE_PAINT3 = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, "block/paint3"));
|
||||
|
||||
private final Sprite[] textures;
|
||||
|
||||
PaintSplotchesBakedModel(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.textures = new Sprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
|
||||
bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanillaAdapter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
|
||||
|
||||
Object renderAttachment = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
|
||||
if (!(renderAttachment instanceof PaintSplotches)) {
|
||||
return;
|
||||
}
|
||||
PaintSplotches splotchesState = (PaintSplotches) renderAttachment;
|
||||
|
||||
List<Splotch> splotches = splotchesState.getSplotches();
|
||||
|
||||
CubeBuilder builder = new CubeBuilder(context.getEmitter());
|
||||
|
||||
float offsetConstant = 0.001f;
|
||||
for (final Splotch s : splotches) {
|
||||
|
||||
if (s.isLumen()) {
|
||||
builder.setColorRGB(s.getColor().whiteVariant);
|
||||
builder.setRenderFullBright(true);
|
||||
} else {
|
||||
builder.setColorRGB(s.getColor().mediumVariant);
|
||||
builder.setRenderFullBright(false);
|
||||
}
|
||||
|
||||
float offset = offsetConstant;
|
||||
offsetConstant += 0.001f;
|
||||
|
||||
final float buffer = 0.1f;
|
||||
|
||||
float pos_x = s.x();
|
||||
float pos_y = s.y();
|
||||
|
||||
pos_x = Math.max(buffer, Math.min(1.0f - buffer, pos_x));
|
||||
pos_y = Math.max(buffer, Math.min(1.0f - buffer, pos_y));
|
||||
|
||||
Sprite ico = this.textures[s.getSeed() % this.textures.length];
|
||||
builder.setTexture(ico);
|
||||
builder.setCustomUv(s.getSide().getOpposite(), 0, 0, 16, 16);
|
||||
|
||||
switch (s.getSide()) {
|
||||
case UP:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.DOWN, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case DOWN:
|
||||
builder.addQuad(Direction.UP, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.WEST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
builder.addQuad(Direction.EAST, offset, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer);
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
offset = 1.0f - offset;
|
||||
builder.addQuad(Direction.NORTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer, offset);
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
builder.addQuad(Direction.SOUTH, pos_x - buffer, pos_y - buffer, offset, pos_x + buffer,
|
||||
pos_y + buffer, offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction face, Random random) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDepth() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprite getSprite() {
|
||||
return this.textures[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelTransformation getTransformation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelOverrideList getOverrides() {
|
||||
return ModelOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static List<SpriteIdentifier> getRequiredTextures() {
|
||||
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.paint;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
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.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.misc.PaintSplotchesBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesBlockEntity> {
|
||||
public PaintSplotchesBlock() {
|
||||
super(defaultProps(Material.WATER, MaterialColor.CLEAR).solidBlock((state, world, pos) -> false)
|
||||
.air());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> list) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final PaintSplotchesBlockEntity tp = this.getBlockEntity(world, pos);
|
||||
|
||||
if (tp != null) {
|
||||
tp.neighborUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rainTick(World world, BlockPos pos) {
|
||||
if (Platform.isServer()) {
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME FABRIC currently no equivalent
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
|
||||
// FIXME FABRIC final PaintSplotchesBlockEntity tp = this.getBlockEntity(w, pos);
|
||||
|
||||
// FIXME FABRIC if (tp != null) {
|
||||
// FIXME FABRIC return tp.getLightLevel();
|
||||
// FIXME FABRIC }
|
||||
|
||||
// FIXME FABRIC return 0;
|
||||
// FIXME FABRIC }
|
||||
|
||||
@Override
|
||||
public boolean canReplace(BlockState state, ItemPlacementContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.ModelBakeSettings;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.render.model.UnbakedModel;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PaintSplotchesModel implements UnbakedModel {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BakedModel bake(ModelLoader loader, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) {
|
||||
return new PaintSplotchesBakedModel(textureGetter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SpriteIdentifier> getTextureDependencies(Function<Identifier, UnbakedModel> unbakedModelGetter, Set<Pair<String, String>> unresolvedTextureReferences) {
|
||||
return PaintSplotchesBakedModel.getRequiredTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> getModelDependencies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package appeng.block.paint;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
public class PaintSplotchesRendering extends BlockRenderingCustomizer {
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer((location, model) -> model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
public class QnbFormedState {
|
||||
|
||||
private final Set<Direction> adjacentQuantumBridges;
|
||||
|
||||
private final boolean corner;
|
||||
|
||||
private final boolean powered;
|
||||
|
||||
public QnbFormedState(Set<Direction> adjacentQuantumBridges, boolean corner, boolean powered) {
|
||||
this.adjacentQuantumBridges = adjacentQuantumBridges;
|
||||
this.corner = corner;
|
||||
this.powered = powered;
|
||||
}
|
||||
|
||||
public Set<Direction> getAdjacentQuantumBridges() {
|
||||
return this.adjacentQuantumBridges;
|
||||
}
|
||||
|
||||
public boolean isCorner() {
|
||||
return this.corner;
|
||||
}
|
||||
|
||||
public boolean isPowered() {
|
||||
return this.powered;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.StateManager;
|
||||
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.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
|
||||
public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeBlockEntity> {
|
||||
|
||||
public static final BooleanProperty FORMED = BooleanProperty.of("formed");
|
||||
|
||||
private static final VoxelShape SHAPE;
|
||||
|
||||
static {
|
||||
final float shave = 2.0f / 16.0f;
|
||||
SHAPE = VoxelShapes.cuboid(new Box(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave));
|
||||
}
|
||||
|
||||
public QuantumBaseBlock(Settings props) {
|
||||
super(props);
|
||||
this.setDefaultState(this.getDefaultState().with(FORMED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeBlockEntity te) {
|
||||
return currentState.with(FORMED, te.isFormed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(world, pos);
|
||||
if (bridge != null) {
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() == state.getBlock()) {
|
||||
return; // Just a block state change
|
||||
}
|
||||
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
bridge.breakCluster();
|
||||
}
|
||||
|
||||
super.onStateReplaced(state, w, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package appeng.block.qnb;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
public class QuantumBridgeRendering extends BlockRenderingCustomizer {
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
// Disable auto rotation
|
||||
rendering.modelCustomizer((location, model) -> model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.qnb;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.client.EffectType;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.QNBContainer;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.helpers.AEMaterials;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuantumLinkChamberBlock extends QuantumBaseBlock {
|
||||
|
||||
private static final VoxelShape SHAPE;
|
||||
|
||||
static {
|
||||
final double onePixel = 2.0 / 16.0;
|
||||
SHAPE = VoxelShapes.cuboid(
|
||||
new Box(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
|
||||
}
|
||||
|
||||
public QuantumLinkChamberBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(final BlockState state, final World w, final BlockPos pos, final Random rand) {
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null) {
|
||||
if (bridge.hasQES()) {
|
||||
if (AppEng.instance().shouldAddParticles(rand)) {
|
||||
AppEng.instance().spawnEffect(EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final QuantumBridgeBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(QNBContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.qnb;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
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 appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
|
||||
public class QuantumRingBlock extends QuantumBaseBlock {
|
||||
|
||||
private static final VoxelShape SHAPE = createShape(2.0 / 16.0);
|
||||
private static final VoxelShape SHAPE_CORNER = createShape(4.0 / 16.0);
|
||||
private static final VoxelShape SHAPE_FORMED = createShape(1.0 / 16.0);
|
||||
|
||||
public QuantumRingBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
|
||||
if (bridge != null && bridge.isCorner()) {
|
||||
return SHAPE_CORNER;
|
||||
} else if (bridge != null && bridge.isFormed()) {
|
||||
return SHAPE_FORMED;
|
||||
}
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
private static VoxelShape createShape(double onePixel) {
|
||||
return VoxelShapes.cuboid(
|
||||
new Box(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.spatial;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
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.World;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
/**
|
||||
* This block is used to fill empty space in spatial dimensions and delinates
|
||||
* the border of a spatial dimensions's usable space.
|
||||
*/
|
||||
public class MatrixFrameBlock extends AEBaseBlock {
|
||||
|
||||
private static final Material MATERIAL = new Material(MaterialColor.CLEAR, false, true, true, false, false, false, PistonBehavior.PUSH_ONLY);
|
||||
|
||||
public MatrixFrameBlock() {
|
||||
super(Settings.of(MATERIAL).strength(-1.0F, 6000000.0F).solidBlock((state, world, pos) -> false).dropsNothing());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStacksForDisplay(ItemGroup group, DefaultedList<ItemStack> list) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView worldIn, BlockPos pos,
|
||||
ShapeContext context) {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) {
|
||||
// This also prevents any blocks from being placed on this block!
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
|
||||
world.setBlockState(pos, getDefaultState(), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTranslucent(BlockState state, BlockView reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.spatial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.SpatialIOPortContainer;
|
||||
import appeng.tile.spatial.SpatialIOPortBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortBlockEntity> {
|
||||
|
||||
public SpatialIOPortBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final SpatialIOPortBlockEntity te = this.getBlockEntity(world, pos);
|
||||
if (te != null) {
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final SpatialIOPortBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(SpatialIOPortContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.spatial;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.helpers.AEMaterials;
|
||||
import appeng.tile.spatial.SpatialPylonBlockEntity;
|
||||
|
||||
public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonBlockEntity> {
|
||||
|
||||
public SpatialPylonBlock() {
|
||||
super(defaultProps(AEMaterials.GLASS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final SpatialPylonBlockEntity tsp = this.getBlockEntity(world, pos);
|
||||
if (tsp != null) {
|
||||
tsp.neighborUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME FABRIC Must use block states for dynamic lighting
|
||||
// FIXME FABRIC @Override
|
||||
// FIXME FABRIC public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
|
||||
// FIXME FABRIC final SpatialPylonBlockEntity tsp = this.getBlockEntity(w, pos);
|
||||
// FIXME FABRIC if (tsp != null) {
|
||||
// FIXME FABRIC return tsp.getLightValue();
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC return super.getLightValue(state, w, pos);
|
||||
// FIXME FABRIC }
|
||||
|
||||
}
|
||||
@@ -20,6 +20,9 @@ package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ChestContainer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
@@ -83,8 +86,8 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
|
||||
p.sendSystemMessage(PlayerMessages.ChestCannotReadStorageCell.get(), Util.NIL_UUID);
|
||||
}
|
||||
} else {
|
||||
// FIXME FABRIC ContainerOpener.openContainer(ChestContainer.TYPE, p,
|
||||
// FIXME FABRIC ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
ContainerOpener.openContainer(ChestContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.DriveContainer;
|
||||
import appeng.tile.storage.DriveBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class DriveBlock extends AEBaseTileBlock<DriveBlockEntity> {
|
||||
|
||||
public DriveBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final DriveBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(DriveContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.storage;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
|
||||
public class DriveRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderLayer.getCutout());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
/**
|
||||
* Describes the type of cell present in a slot.
|
||||
*/
|
||||
public enum DriveSlotCellType implements StringIdentifiable {
|
||||
|
||||
EMPTY("empty"),
|
||||
|
||||
ITEM("item"),
|
||||
|
||||
FLUID("fluid");
|
||||
|
||||
private final String name;
|
||||
|
||||
DriveSlotCellType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.storage;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.cells.CellState;
|
||||
|
||||
/**
|
||||
* Contains the full information about what the state of the slots in a
|
||||
* BlockDrive is.
|
||||
*/
|
||||
public class DriveSlotsState {
|
||||
|
||||
private final Item[] cells;
|
||||
|
||||
private final DriveSlotState[] states;
|
||||
|
||||
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
|
||||
Preconditions.checkArgument(cells.length == states.length);
|
||||
this.cells = cells;
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
public DriveSlotState getState(int index) {
|
||||
if (index >= this.states.length) {
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return this.states[index];
|
||||
}
|
||||
|
||||
public Item getCell(int index) {
|
||||
if (index >= this.cells.length) {
|
||||
return null;
|
||||
}
|
||||
return this.cells[index];
|
||||
}
|
||||
|
||||
public int getSlotCount() {
|
||||
return this.cells.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or
|
||||
* chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive(IChestOrDrive chestOrDrive) {
|
||||
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
Item[] cells = new Item[chestOrDrive.getCellCount()];
|
||||
for (int i = 0; i < chestOrDrive.getCellCount(); i++) {
|
||||
cells[i] = chestOrDrive.getCellItem(i);
|
||||
|
||||
if (!chestOrDrive.isPowered()) {
|
||||
if (chestOrDrive.getCellStatus(i) != CellState.EMPTY) {
|
||||
states[i] = DriveSlotState.OFFLINE;
|
||||
} else {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
} else {
|
||||
states[i] = DriveSlotState.fromCellStatus(chestOrDrive.getCellStatus(i));
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
|
||||
public static DriveSlotsState createEmpty(int slotCount) {
|
||||
DriveSlotState[] states = new DriveSlotState[slotCount];
|
||||
Item[] cells = new Item[slotCount];
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.IOPortContainer;
|
||||
import appeng.tile.storage.IOPortBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class IOPortBlock extends AEBaseTileBlock<IOPortBlockEntity> {
|
||||
|
||||
public IOPortBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final IOPortBlockEntity te = this.getBlockEntity(world, pos);
|
||||
if (te != null) {
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
if (p.isInSneakingPose()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final IOPortBlockEntity tg = this.getBlockEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(IOPortContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user