Fabric port in progress

This commit is contained in:
Sebastian Hartte
2020-06-27 23:25:38 +02:00
parent 80fbb58d4f
commit b79cd732b2
368 changed files with 2498 additions and 2698 deletions
+19 -43
View File
@@ -20,7 +20,7 @@ package appeng.block;
import javax.annotation.Nullable;
import net.minecraft.block.AbstractBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.sound.BlockSoundGroup;
@@ -28,18 +28,17 @@ import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
@@ -48,8 +47,6 @@ import appeng.util.Platform;
public abstract class AEBaseBlock extends Block {
private boolean isOpaque = true;
private boolean isFullSize = true;
private boolean isInventory = false;
protected AEBaseBlock(final Settings props) {
@@ -60,7 +57,7 @@ public abstract class AEBaseBlock extends Block {
* Utility function to create block properties with some sensible defaults for
* AE blocks.
*/
public static Settings defaultProps(Material material) {
public static FabricBlockSettings defaultProps(Material material) {
return defaultProps(material, material.getColor());
}
@@ -68,17 +65,18 @@ public abstract class AEBaseBlock extends Block {
* Utility function to create block properties with some sensible defaults for
* AE blocks.
*/
public static Settings defaultProps(Material material, MaterialColor color) {
return Settings.create(material, color)
public static FabricBlockSettings defaultProps(Material material, MaterialColor color) {
return FabricBlockSettings.of(material, color)
// These values previousls were encoded in AEBaseBlock
.hardnessAndResistance(2.2f, 11.f).harvestTool(ToolType.PICKAXE).harvestLevel(0)
.sound(getDefaultSoundByMaterial(material));
.strength(2.2f, 11.f)
.breakByTool(FabricToolTags.PICKAXES, 0)
.sounds(getDefaultSoundByMaterial(material));
}
private static BlockSoundGroup getDefaultSoundByMaterial(Material mat) {
if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) {
return BlockSoundGroup.GLASS;
} else if (mat == Material.ROCK) {
} else if (mat == Material.STONE) {
return BlockSoundGroup.STONE;
} else if (mat == Material.WOOD) {
return BlockSoundGroup.WOOD;
@@ -87,11 +85,6 @@ public abstract class AEBaseBlock extends Block {
}
}
@Override
public boolean isNormalCube(BlockState state, BlockView worldIn, BlockPos pos) {
return this.isFullSize() && this.isOpaque();
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return this.isInventory();
@@ -132,7 +125,7 @@ public abstract class AEBaseBlock extends Block {
}
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
return ActionResult.PASS;
}
@@ -151,13 +144,13 @@ public abstract class AEBaseBlock extends Block {
return dir;
}
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset();
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();
Direction west = null;
for (final Direction dx : Direction.values()) {
if (dx.getXOffset() == west_x && dx.getYOffset() == west_y && dx.getZOffset() == west_z) {
if (dx.getOffsetX() == west_x && dx.getOffsetY() == west_y && dx.getOffsetZ() == west_z) {
west = dx;
}
}
@@ -192,7 +185,8 @@ public abstract class AEBaseBlock extends Block {
@Override
public String toString() {
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
Identifier id = Registry.BLOCK.getId(this);
String regName = id == Registry.BLOCK.getDefaultId() ? "unregistered" : id.getPath();
return this.getClass().getSimpleName() + "[" + regName + "]";
}
@@ -221,24 +215,6 @@ public abstract class AEBaseBlock extends Block {
return true;
}
protected boolean isOpaque() {
return this.isOpaque;
}
protected boolean setOpaque(final boolean isOpaque) {
this.isOpaque = isOpaque;
return isOpaque;
}
protected boolean isFullSize() {
return this.isFullSize;
}
protected boolean setFullSize(final boolean isFullSize) {
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean isInventory() {
return this.isInventory;
}
+19 -25
View File
@@ -22,11 +22,10 @@ import java.util.List;
import net.fabricmc.api.EnvType;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction;
@@ -40,33 +39,28 @@ import appeng.block.misc.LightDetectorBlock;
import appeng.block.misc.SkyCompassBlock;
import appeng.block.networking.WirelessBlock;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class AEBaseBlockItem extends BlockItem {
private final AEBaseBlock blockType;
public AEBaseBlockItem(final Block id, Item.Properties props) {
public AEBaseBlockItem(final Block id, Settings props) {
super(id, props);
this.blockType = (AEBaseBlock) id;
}
@Override
@Environment(EnvType.CLIENT)
public final void addInformation(final ItemStack itemStack, final World world, final List<Text> toolTip,
final ITooltipFlag advancedTooltips) {
public final void appendTooltip(final ItemStack itemStack, final World world, final List<Text> toolTip,
final TooltipContext advancedTooltips) {
this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips);
}
@Environment(EnvType.CLIENT)
public void addCheckedInformation(final ItemStack itemStack, final World world, final List<Text> toolTip,
final ITooltipFlag advancedTooltips) {
this.blockType.addInformation(itemStack, world, toolTip, advancedTooltips);
}
@Override
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
return false;
final TooltipContext advancedTooltips) {
this.blockType.buildTooltip(itemStack, world, toolTip, advancedTooltips);
}
@Override
@@ -75,12 +69,12 @@ public class AEBaseBlockItem extends BlockItem {
}
@Override
public ActionResult tryPlace(BlockItemUseContext context) {
public ActionResult place(ItemPlacementContext context) {
Direction up = null;
Direction forward = null;
Direction side = context.getFace();
Direction side = context.getSide();
PlayerEntity player = context.getPlayer();
if (this.blockType instanceof AEBaseTileBlock) {
@@ -100,13 +94,13 @@ public class AEBaseBlockItem extends BlockItem {
}
} else {
up = Direction.UP;
forward = context.getPlacementHorizontalFacing().getOpposite();
forward = context.getPlayerFacing().getOpposite();
if (player != null) {
if (player.rotationPitch > 65) {
if (player.pitch > 65) {
up = forward.getOpposite();
forward = Direction.UP;
} else if (player.rotationPitch < -65) {
} else if (player.pitch < -65) {
up = forward.getOpposite();
forward = Direction.DOWN;
}
@@ -116,26 +110,26 @@ public class AEBaseBlockItem extends BlockItem {
IOrientable ori = null;
if (this.blockType instanceof IOrientableBlock) {
ori = ((IOrientableBlock) this.blockType).getOrientable(context.getWorld(), context.getPos());
ori = ((IOrientableBlock) this.blockType).getOrientable(context.getWorld(), context.getBlockPos());
up = side;
forward = Direction.SOUTH;
if (up.getYOffset() == 0) {
if (up.getOffsetY() == 0) {
forward = Direction.UP;
}
}
if (!this.blockType.isValidOrientation(context.getWorld(), context.getPos(), forward, up)) {
if (!this.blockType.isValidOrientation(context.getWorld(), context.getBlockPos(), forward, up)) {
return ActionResult.FAIL;
}
ActionResult result = super.tryPlace(context);
ActionResult result = super.place(context);
if (result != ActionResult.SUCCESS) {
return result;
}
if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof LightDetectorBlock)) {
final AEBaseTileEntity tile = ((AEBaseTileBlock<?>) this.blockType).getTileEntity(context.getWorld(),
context.getPos());
final AEBaseBlockEntity tile = ((AEBaseTileBlock<?>) this.blockType).getBlockEntity(context.getWorld(),
context.getBlockPos());
ori = tile;
if (tile == null) {
@@ -18,45 +18,50 @@
package appeng.block;
import java.text.MessageFormat;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.World;
import net.fabricmc.api.Environment;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import java.text.MessageFormat;
import java.util.List;
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage {
public AEBaseBlockItemChargeable(Block id, Properties props) {
public AEBaseBlockItemChargeable(Block id, Settings props) {
super(id, props);
addPropertyOverride(new Identifier("appliedenergistics2:fill_level"), (is, world, entity) -> {
double curPower = getAECurrentPower(is);
double maxPower = getAEMaxPower(is);
FabricModelPredicateProviderRegistry.register(
this,
new Identifier(AppEng.MOD_ID, "fill_level"),
(is, world, entity) -> {
double curPower = getAECurrentPower(is);
double maxPower = getAEMaxPower(is);
return (int) Math.round(100 * curPower / maxPower);
});
return (int) Math.round(100 * curPower / maxPower);
}
);
}
@Override
@Environment(EnvType.CLIENT)
public void addCheckedInformation(final ItemStack stack, final World world, final List<Text> lines,
final ITooltipFlag advancedTooltips) {
final TooltipContext advancedTooltips) {
double internalCurrentPower = 0;
final double internalMaxPower = this.getMaxEnergyCapacity();
@@ -69,9 +74,10 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
final double percent = internalCurrentPower / internalMaxPower;
lines.add(GuiText.StoredEnergy.textComponent()
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
.appendSibling(new TranslatableText(PowerUnits.AE.unlocalizedName))
.appendText(" - " + MessageFormat.format("{0,number,#.##%}", percent)));
.copy()
.append(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
.append(new TranslatableText(PowerUnits.AE.unlocalizedName))
.append(" - " + MessageFormat.format("{0,number,#.##%}", percent)));
}
}
+87 -98
View File
@@ -25,45 +25,42 @@ import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
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.util.DyeColor;
import net.minecraft.text.LiteralText;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.text.Text;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.util.AEColor;
import appeng.api.util.IOrientable;
import appeng.block.networking.CableBusBlock;
import appeng.tile.AEBaseInvTileEntity;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.networking.CableBusTileEntity;
import appeng.tile.storage.SkyChestTileEntity;
import appeng.tile.AEBaseInvBlockEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.networking.CableBusBlockEntity;
import appeng.tile.storage.SkyChestBlockEntity;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBaseBlock {
public abstract class AEBaseTileBlock<T extends AEBaseBlockEntity> extends AEBaseBlock implements BlockEntityProvider {
@Nonnull
private Class<T> tileEntityClass;
private Class<T> blockEntityClass;
@Nonnull
private Supplier<T> tileEntityFactory;
@@ -73,61 +70,45 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
// TODO : Was this change needed?
public void setTileEntity(final Class<T> tileEntityClass, Supplier<T> factory) {
this.tileEntityClass = tileEntityClass;
this.blockEntityClass = tileEntityClass;
this.tileEntityFactory = factory;
this.setInventory(AEBaseInvTileEntity.class.isAssignableFrom(tileEntityClass));
this.setInventory(AEBaseInvBlockEntity.class.isAssignableFrom(tileEntityClass));
}
@Override
public boolean hasTileEntity(BlockState state) {
return this.hasBlockTileEntity();
}
private boolean hasBlockTileEntity() {
return true;
}
public Class<T> getTileEntityClass() {
return this.tileEntityClass;
public Class<T> getBlockEntityClass() {
return this.blockEntityClass;
}
@Nullable
public T getTileEntity(final BlockView w, final int x, final int y, final int z) {
return this.getTileEntity(w, new BlockPos(x, y, z));
public T getBlockEntity(final BlockView w, final int x, final int y, final int z) {
return this.getBlockEntity(w, new BlockPos(x, y, z));
}
@Nullable
public T getTileEntity(final BlockView w, final BlockPos pos) {
if (!this.hasBlockTileEntity()) {
return null;
}
public T getBlockEntity(final BlockView w, final BlockPos pos) {
final BlockEntity te = w.getTileEntity(pos);
final BlockEntity te = w.getBlockEntity(pos);
// FIXME: This gets called as part of building the block state cache
if (this.tileEntityClass != null && this.tileEntityClass.isInstance(te)) {
return this.tileEntityClass.cast(te);
if (this.blockEntityClass != null && this.blockEntityClass.isInstance(te)) {
return this.blockEntityClass.cast(te);
}
return null;
}
@Nullable
@Override
public final BlockEntity createTileEntity(BlockState state, BlockView world) {
public BlockEntity createBlockEntity(BlockView world) {
return this.tileEntityFactory.get();
}
@Override
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
super.dropXpOnBlockBreak(worldIn, pos, amount);
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
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 AEBaseTileEntity te = this.getTileEntity(w, pos);
final AEBaseBlockEntity te = this.getBlockEntity(w, pos);
if (te != null) {
final ArrayList<ItemStack> drops = new ArrayList<>();
if (te.dropItems()) {
@@ -141,84 +122,90 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
}
// super will remove the TE, as it is not an instance of BlockContainer
super.onReplaced(state, w, pos, newState, isMoving);
}
@Override
public boolean recolorBlock(BlockState state, final WorldAccess world, final BlockPos pos, final Direction side,
final DyeColor color) {
final BlockEntity te = this.getTileEntity(world, pos);
if (te instanceof IColorableTile) {
final IColorableTile ct = (IColorableTile) te;
final AEColor c = ct.getColor();
final AEColor newColor = AEColor.values()[color.ordinal()];
if (c != newColor) {
ct.recolourBlock(side, newColor, null);
return true;
}
return false;
}
return super.recolorBlock(state, world, pos, side, color);
super.onStateReplaced(state, w, pos, newState, isMoving);
}
@Override
public int getComparatorOutput(BlockState state, final World w, final BlockPos pos) {
final BlockEntity te = this.getTileEntity(w, pos);
if (te instanceof AEBaseInvTileEntity) {
AEBaseInvTileEntity invTile = (AEBaseInvTileEntity) te;
if (invTile.getInternalInventory().getSlots() > 0) {
return ItemHandlerHelper.calcRedstoneFromInventory(invTile.getInternalInventory());
final BlockEntity te = this.getBlockEntity(w, pos);
if (te instanceof AEBaseInvBlockEntity) {
AEBaseInvBlockEntity invTile = (AEBaseInvBlockEntity) te;
if (invTile.getInternalInventory().getSlotCount() > 0) {
return getRedstoneFromFixedItemInv(invTile.getInternalInventory());
}
}
return 0;
}
@Override
public boolean eventReceived(final BlockState state, final World worldIn, final BlockPos pos, final int eventID,
final int eventParam) {
super.eventReceived(state, worldIn, pos, eventID, eventParam);
final BlockEntity tileentity = worldIn.getTileEntity(pos);
return tileentity != null ? tileentity.receiveClientEvent(eventID, eventParam) : false;
/**
* Calculate redstone output level.
* 0 if completely empty, 1 if _any_ item is present, up to 15 if all slots are full.
*/
private int getRedstoneFromFixedItemInv(FixedItemInv inv) {
boolean foundAnything = false; // ANY slots non-empty?
float fillRatio = 0;
for (int i = 0; i < inv.getSlotCount(); ++i)
{
ItemStack stack = inv.getInvStack(i);
if (stack.isEmpty()) {
continue;
}
int slotMaxCount = inv.getMaxAmount(i, stack);
fillRatio += stack.getCount() / (float)Math.min(slotMaxCount, stack.getMaxCount());
foundAnything = true;
}
// Average the ratio across all slots
fillRatio /= inv.getSlotCount();
// Always return at least non-zero if _any_ slots are non-empty
return (foundAnything ? 1 : 0) + MathHelper.floor(fillRatio * 14.0f);
}
@Override
public void onBlockPlacedBy(final World w, final BlockPos pos, final BlockState state, final LivingEntity placer,
public boolean onSyncedBlockEvent(BlockState state, World world, BlockPos pos, int type, int data) {
super.onSyncedBlockEvent(state, world, pos, type, data);
final BlockEntity tileentity = world.getBlockEntity(pos);
return tileentity != null && tileentity.onSyncedBlockEvent(type, data);
}
@Override
public void onPlaced(final World w, final BlockPos pos, final BlockState state, final LivingEntity placer,
final ItemStack is) {
// Inherit the item stack's display name, but only if it's a user defined string
// rather
// than a translation component, since our custom naming cannot handle
// untranslated
// I18N strings and we would translate it using the server's locale :-(
AEBaseTileEntity te = this.getTileEntity(w, pos);
if (te != null && is.hasDisplayName()) {
Text displayName = is.getDisplayName();
if (displayName instanceof StringTextComponent) {
te.setName(((StringTextComponent) displayName).getText());
AEBaseBlockEntity te = this.getBlockEntity(w, pos);
if (te != null && is.hasCustomName()) {
Text displayName = is.getName();
if (displayName instanceof LiteralText) {
te.setName(((LiteralText) displayName).getRawString());
}
}
}
@Override
public ActionResult onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player,
Hand hand, BlockRayTraceResult hit) {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player,
Hand hand, BlockHitResult hit) {
ItemStack heldItem;
if (player != null && !player.getHeldItem(hand).isEmpty()) {
heldItem = player.getHeldItem(hand);
if (player != null && !player.getStackInHand(hand).isEmpty()) {
heldItem = player.getStackInHand(hand);
if (Platform.isWrench(player, heldItem, pos) && player.isCrouching()) {
if (Platform.isWrench(player, heldItem, pos) && player.isInSneakingPose()) {
final BlockState blockState = world.getBlockState(pos);
final Block block = blockState.getBlock();
final AEBaseTileEntity tile = this.getTileEntity(world, pos);
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile == null) {
return ActionResult.FAIL;
}
if (tile instanceof CableBusTileEntity || tile instanceof SkyChestTileEntity) {
if (tile instanceof CableBusBlockEntity || tile instanceof SkyChestBlockEntity) {
return ActionResult.FAIL;
}
@@ -234,10 +221,12 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
}
}
if (block.removedByPlayer(blockState, world, pos, player, false, world.getFluidState(pos))) {
block.onBreak(world, pos, blockState, player);
boolean bl = world.removeBlock(pos, false);
if (bl) {
block.onBroken(world, pos, blockState);
final List<ItemStack> itemsToDrop = Lists.newArrayList(itemDropCandidates);
Platform.spawnDrops(world, pos, itemsToDrop);
world.removeBlock(pos, false);
}
return ActionResult.FAIL;
@@ -245,7 +234,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) {
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
final AEBaseTileEntity tileEntity = this.getTileEntity(world, pos);
final AEBaseBlockEntity tileEntity = this.getBlockEntity(world, pos);
if (tileEntity == null) {
return ActionResult.FAIL;
@@ -253,7 +242,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
final String name = this.getTranslationKey();
if (player.isCrouching()) {
if (player.isInSneakingPose()) {
final CompoundTag data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD);
if (data != null) {
memoryCard.setMemoryCardContents(heldItem, name, data);
@@ -275,12 +264,12 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
}
}
return this.onActivated(world, pos, player, hand, player.getHeldItem(hand), hit);
return this.onActivated(world, pos, player, hand, player.getStackInHand(hand), hit);
}
@Override
public IOrientable getOrientable(final BlockView w, final BlockPos pos) {
return this.getTileEntity(w, pos);
return this.getBlockEntity(w, pos);
}
/**
@@ -291,12 +280,12 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
* returned unchanged, this is also the case if the given block state does not
* belong to this block.
*/
public final BlockState getTileEntityBlockState(BlockState current, BlockEntity te) {
if (current.getBlock() != this || !tileEntityClass.isInstance(te)) {
public final BlockState getBlockEntityBlockState(BlockState current, BlockEntity te) {
if (current.getBlock() != this || !blockEntityClass.isInstance(te)) {
return current;
}
return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te));
return updateBlockStateFromTileEntity(current, blockEntityClass.cast(te));
}
/**
@@ -26,16 +26,16 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
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.CraftingTileEntity;
import appeng.tile.crafting.CraftingBlockEntity;
public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> extends AEBaseTileBlock<T> {
public abstract class AbstractCraftingUnitBlock<T extends CraftingBlockEntity> extends AEBaseTileBlock<T> {
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -57,33 +57,33 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
@Override
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
final BlockPos fromPos, boolean isMoving) {
final CraftingTileEntity cp = this.getTileEntity(worldIn, pos);
final CraftingBlockEntity cp = this.getBlockEntity(worldIn, pos);
if (cp != null) {
cp.updateMultiBlock();
}
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
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 CraftingTileEntity cp = this.getTileEntity(w, pos);
final CraftingBlockEntity cp = this.getBlockEntity(w, pos);
if (cp != null) {
cp.breakCluster();
}
super.onReplaced(state, w, pos, newState, isMoving);
super.onStateReplaced(state, w, pos, newState, isMoving);
}
@Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
BlockRayTraceResult hit) {
final CraftingTileEntity tg = this.getTileEntity(w, pos);
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.isCrouching() && tg.isFormed() && tg.isActive()) {
if (!w.isRemote()) {
if (tg != null && !p.isInSneakingPose() && tg.isFormed() && tg.isActive()) {
if (!w.isClient()) {
ContainerOpener.openContainer(CraftingCPUContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
}
@@ -91,7 +91,7 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
return ActionResult.SUCCESS;
}
return super.onBlockActivated(state, w, pos, p, hand, hit);
return super.onUse(state, w, pos, p, hand, hit);
}
public enum CraftingUnitType {
@@ -18,10 +18,10 @@
package appeng.block.crafting;
import appeng.tile.crafting.CraftingMonitorTileEntity;
import appeng.tile.crafting.CraftingMonitorBlockEntity;
public class CraftingMonitorBlock extends AbstractCraftingUnitBlock<CraftingMonitorTileEntity> {
public CraftingMonitorBlock(Properties props) {
public class CraftingMonitorBlock extends AbstractCraftingUnitBlock<CraftingMonitorBlockEntity> {
public CraftingMonitorBlock(Settings props) {
super(props, CraftingUnitType.MONITOR);
}
}
@@ -18,11 +18,11 @@
package appeng.block.crafting;
import appeng.tile.crafting.CraftingStorageTileEntity;
import appeng.tile.crafting.CraftingStorageBlockEntity;
public class CraftingStorageBlock extends AbstractCraftingUnitBlock<CraftingStorageTileEntity> {
public class CraftingStorageBlock extends AbstractCraftingUnitBlock<CraftingStorageBlockEntity> {
public CraftingStorageBlock(Properties props, CraftingUnitType type) {
public CraftingStorageBlock(Settings props, CraftingUnitType type) {
super(props, type);
}
@@ -28,7 +28,7 @@ import appeng.core.AEConfig;
public class CraftingStorageItem extends AEBaseBlockItem {
public CraftingStorageItem(Block id, Properties props) {
public CraftingStorageItem(Block id, Settings props) {
super(id, props);
}
@@ -18,11 +18,11 @@
package appeng.block.crafting;
import appeng.tile.crafting.CraftingTileEntity;
import appeng.tile.crafting.CraftingBlockEntity;
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<CraftingTileEntity> {
public class CraftingUnitBlock extends AbstractCraftingUnitBlock<CraftingBlockEntity> {
public CraftingUnitBlock(Properties props, CraftingUnitType type) {
public CraftingUnitBlock(Settings props, CraftingUnitType type) {
super(props, type);
}
@@ -25,17 +25,17 @@ import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
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.util.math.BlockRayTraceResult;
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.MolecularAssemblerTileEntity;
import appeng.tile.crafting.MolecularAssemblerBlockEntity;
public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerTileEntity> {
public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerBlockEntity> {
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -51,23 +51,23 @@ public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerT
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, MolecularAssemblerTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, MolecularAssemblerBlockEntity te) {
return currentState.with(POWERED, te.isPowered());
}
@Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
BlockRayTraceResult hit) {
final MolecularAssemblerTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
if (!tg.isRemote()) {
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.getFace()));
}
return ActionResult.SUCCESS;
}
return super.onBlockActivated(state, w, pos, p, hand, hit);
return super.onUse(state, w, pos, p, hand, hit);
}
}
@@ -32,7 +32,7 @@ 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.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -45,24 +45,24 @@ import net.minecraftforge.common.util.FakePlayer;
import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseTileBlock;
import appeng.core.stats.AeStats;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.grindstone.CrankTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.grindstone.CrankBlockEntity;
public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
public class CrankBlock extends AEBaseTileBlock<CrankBlockEntity> {
public CrankBlock(Properties props) {
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 BlockRayTraceResult hit) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (player instanceof FakePlayer || player == null) {
this.dropCrank(w, pos);
return ActionResult.SUCCESS;
}
final CrankTileEntity tile = this.getTileEntity(w, pos);
final CrankBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
if (tile.power()) {
AeStats.TurnedCranks.addToPlayer(player, 1);
@@ -74,14 +74,14 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
}
private void dropCrank(final World world, final BlockPos pos) {
world.destroyBlock(pos, true);
world.notifyBlockUpdate(pos, this.getDefaultState(), world.getBlockState(pos), 3);
world.breakBlock(pos, true);
world.updateListeners(pos, this.getDefaultState(), world.getBlockState(pos), 3);
}
@Override
public void onBlockPlacedBy(final World world, final BlockPos pos, final BlockState state,
public void onPlaced(final World world, final BlockPos pos, final BlockState state,
final LivingEntity placer, final ItemStack stack) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos);
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) {
final Direction mnt = this.findCrankable(world, pos);
Direction forward = Direction.UP;
@@ -96,8 +96,8 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
@Override
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
final BlockEntity te = w.getTileEntity(pos);
return !(te instanceof CrankTileEntity) || this.isCrankable(w, pos, up.getOpposite());
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) {
@@ -111,7 +111,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
private boolean isCrankable(final BlockView world, final BlockPos pos, final Direction offset) {
final BlockPos o = pos.offset(offset);
final BlockEntity te = world.getTileEntity(o);
final BlockEntity te = world.getBlockEntity(o);
return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite());
}
@@ -124,7 +124,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos);
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) {
if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) {
this.dropCrank(world, pos);
@@ -140,7 +140,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
}
private Direction getUp(BlockView world, BlockPos pos) {
CrankTileEntity crank = getTileEntity(world, pos);
CrankBlockEntity crank = getBlockEntity(world, pos);
return crank != null ? crank.getUp() : null;
}
@@ -152,9 +152,9 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
return VoxelShapes.empty();
} else {
// FIXME: Cache per direction, and build it 'precise', not just from AABB
final double xOff = -0.15 * up.getXOffset();
final double yOff = -0.15 * up.getYOffset();
final double zOff = -0.15 * up.getZOffset();
final double xOff = -0.15 * up.getOffsetX();
final double yOff = -0.15 * up.getOffsetY();
final double zOff = -0.15 * up.getOffsetZ();
return VoxelShapes.create(
new Box(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85));
}
@@ -21,31 +21,31 @@ package appeng.block.grindstone;
import javax.annotation.Nullable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
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.util.math.BlockRayTraceResult;
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.GrinderTileEntity;
import appeng.tile.grindstone.GrinderBlockEntity;
public class GrinderBlock extends AEBaseTileBlock<GrinderTileEntity> {
public class GrinderBlock extends AEBaseTileBlock<GrinderBlockEntity> {
public GrinderBlock(Properties props) {
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 BlockRayTraceResult hit) {
final GrinderTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
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.getFace()));
@@ -26,16 +26,16 @@ 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.math.BlockRayTraceResult;
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.CellWorkbenchTileEntity;
import appeng.tile.misc.CellWorkbenchBlockEntity;
import appeng.util.Platform;
public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchTileEntity> {
public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchBlockEntity> {
public CellWorkbenchBlock() {
super(defaultProps(Material.IRON));
@@ -43,12 +43,12 @@ public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchTileEntity>
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final CellWorkbenchTileEntity tg = this.getTileEntity(w, pos);
final CellWorkbenchBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
CellWorkbenchContainer.open(p, ContainerLocator.forTileEntity(tg));
@@ -31,18 +31,18 @@ import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.TransformationMatrix;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
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.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -57,10 +57,10 @@ import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.tile.misc.ChargerTileEntity;
import appeng.tile.misc.ChargerBlockEntity;
import appeng.util.Platform;
public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
public ChargerBlock() {
super(defaultProps(Material.IRON).notSolid());
@@ -75,13 +75,13 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (player.isInSneakingPose()) {
return ActionResult.PASS;
}
if (Platform.isServer()) {
final ChargerTileEntity tc = this.getTileEntity(w, pos);
final ChargerBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null) {
tc.activate(player);
}
@@ -101,7 +101,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
return;
}
final ChargerTileEntity tile = this.getTileEntity(w, pos);
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) {
@@ -111,7 +111,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.proxy.shouldAddParticles(r)) {
Minecraft.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(),
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(),
yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0, 0.0, 0.0);
}
}
@@ -122,7 +122,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
final ChargerTileEntity tile = this.getTileEntity(w, pos);
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
final double twoPixels = 2.0 / 16.0;
final Direction up = tile.getUp();
@@ -130,15 +130,15 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels,
1.0 - twoPixels, 1.0 - twoPixels);
if (up.getXOffset() != 0) {
if (up.getOffsetX() != 0) {
bb.minX = 0;
bb.maxX = 1;
}
if (up.getYOffset() != 0) {
if (up.getOffsetY() != 0) {
bb.minY = 0;
bb.maxY = 1;
}
if (up.getZOffset() != 0) {
if (up.getOffsetZ() != 0) {
bb.minZ = 0;
bb.maxZ = 1;
}
@@ -178,12 +178,12 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
}
@Environment(EnvType.CLIENT)
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<ChargerTileEntity>> createTesr() {
public static Function<BlockEntityRenderDispatcher, BlockEntityRenderer<ChargerBlockEntity>> createTesr() {
return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(ChargerBlock::getRenderedItem));
}
@Environment(EnvType.CLIENT)
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerTileEntity tile) {
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerBlockEntity tile) {
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
}
@@ -25,18 +25,18 @@ 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.util.math.BlockRayTraceResult;
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.CondenserTileEntity;
import appeng.tile.misc.CondenserBlockEntity;
import appeng.util.Platform;
public class CondenserBlock extends AEBaseTileBlock<CondenserTileEntity> {
public class CondenserBlock extends AEBaseTileBlock<CondenserBlockEntity> {
public CondenserBlock() {
super(defaultProps(Material.IRON));
@@ -44,14 +44,14 @@ public class CondenserBlock extends AEBaseTileBlock<CondenserTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (player.isInSneakingPose()) {
return ActionResult.PASS;
}
if (Platform.isServer()) {
final CondenserTileEntity tc = this.getTileEntity(w, pos);
if (tc != null && !player.isCrouching()) {
final CondenserBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(CondenserContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResult.SUCCESS;
@@ -25,8 +25,8 @@ 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.util.math.BlockRayTraceResult;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
@@ -34,11 +34,11 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.InscriberContainer;
import appeng.tile.misc.InscriberTileEntity;
import appeng.tile.misc.InscriberBlockEntity;
public class InscriberBlock extends AEBaseTileBlock<InscriberTileEntity> {
public class InscriberBlock extends AEBaseTileBlock<InscriberBlockEntity> {
public InscriberBlock(Properties props) {
public InscriberBlock(Settings props) {
super(props);
}
@@ -50,11 +50,11 @@ public class InscriberBlock extends AEBaseTileBlock<InscriberTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (!p.isCrouching()) {
final InscriberTileEntity tg = this.getTileEntity(w, pos);
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (!p.isInSneakingPose()) {
final InscriberBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (!tg.isRemote()) {
if (!tg.isClient()) {
ContainerOpener.openContainer(InscriberContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
}
@@ -7,13 +7,13 @@ import net.fabricmc.api.Environment;
import appeng.bootstrap.TileEntityRendering;
import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.InscriberTESR;
import appeng.tile.misc.InscriberTileEntity;
import appeng.tile.misc.InscriberBlockEntity;
public class InscriberRendering extends TileEntityRenderingCustomizer<InscriberTileEntity> {
public class InscriberRendering extends TileEntityRenderingCustomizer<InscriberBlockEntity> {
@Environment(EnvType.CLIENT)
@Override
public void customize(TileEntityRendering<InscriberTileEntity> rendering) {
public void customize(TileEntityRendering<InscriberBlockEntity> rendering) {
rendering.tileEntityRenderer(InscriberTESR::new);
}
@@ -28,10 +28,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
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.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import appeng.api.util.IOrientable;
@@ -39,10 +39,10 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.InterfaceContainer;
import appeng.tile.misc.InterfaceTileEntity;
import appeng.tile.misc.InterfaceBlockEntity;
import appeng.util.Platform;
public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
public class InterfaceBlock extends AEBaseTileBlock<InterfaceBlockEntity> {
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional");
@@ -57,18 +57,18 @@ public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, InterfaceTileEntity te) {
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 BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final InterfaceTileEntity tg = this.getTileEntity(w, pos);
final InterfaceBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(InterfaceContainer.TYPE, p,
@@ -86,8 +86,8 @@ public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
@Override
protected void customRotateBlock(final IOrientable rotatable, final Direction axis) {
if (rotatable instanceof InterfaceTileEntity) {
((InterfaceTileEntity) rotatable).setSide(axis);
if (rotatable instanceof InterfaceBlockEntity) {
((InterfaceBlockEntity) rotatable).setSide(axis);
}
}
}
@@ -41,9 +41,9 @@ import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.LightDetectorTileEntity;
import appeng.tile.misc.LightDetectorBlockEntity;
public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity> implements IOrientableBlock {
public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorBlockEntity> implements IOrientableBlock {
// Used to alternate between two variants of the fixture on adjacent blocks
public static final BooleanProperty ODD = BooleanProperty.create("odd");
@@ -63,7 +63,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
@Override
public int getWeakPower(final BlockState state, final BlockView w, final BlockPos pos, final Direction side) {
if (w instanceof World && this.getTileEntity(w, pos).isReady()) {
if (w instanceof World && this.getBlockEntity(w, pos).isReady()) {
// FIXME: This is ... uhm... fishy
return ((World) w).getLight(pos) - 6;
}
@@ -75,7 +75,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(state, world, pos, neighbor);
final LightDetectorTileEntity tld = this.getTileEntity(world, pos);
final LightDetectorBlockEntity tld = this.getBlockEntity(world, pos);
if (tld != null) {
tld.updateLight();
}
@@ -104,9 +104,9 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
// called without a world
final Direction up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getXOffset();
final double yOff = -0.3 * up.getYOffset();
final double zOff = -0.3 * up.getZOffset();
final double xOff = -0.3 * up.getOffsetX();
final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getOffsetZ();
return VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
}
@@ -128,8 +128,8 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.breakBlock(pos, true);
w.updateListeners(pos, prev, w.getBlockState(pos), 3);
}
@Override
@@ -27,9 +27,9 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
@@ -64,9 +64,9 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
SHAPES = new EnumMap<>(Direction.class);
for (Direction facing : Direction.values()) {
final double xOff = -0.3 * facing.getXOffset();
final double yOff = -0.3 * facing.getYOffset();
final double zOff = -0.3 * facing.getZOffset();
final double xOff = -0.3 * facing.getOffsetX();
final double yOff = -0.3 * facing.getOffsetY();
final double zOff = -0.3 * facing.getOffsetZ();
VoxelShape shape = VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
SHAPES.put(facing, shape);
@@ -80,8 +80,8 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
public static final BooleanProperty ODD = BooleanProperty.create("odd");
public QuartzFixtureBlock() {
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14)
.sound(BlockSoundGroup.GLASS));
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().strength(0).lightValue(14)
.sounds(BlockSoundGroup.GLASS));
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false));
}
@@ -94,9 +94,9 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
// For reference, see WallTorchBlock
@Override
@Nullable
public BlockState getStateForPlacement(BlockItemUseContext context) {
public BlockState getStateForPlacement(ItemPlacementContext context) {
BlockState blockstate = super.getStateForPlacement(context);
BlockPos pos = context.getPos();
BlockPos pos = context.getBlockPos();
// Set the even/odd property
boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0;
@@ -157,9 +157,9 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
}
final Direction up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getXOffset();
final double yOff = -0.3 * up.getYOffset();
final double zOff = -0.3 * up.getZOffset();
final double xOff = -0.3 * up.getOffsetX();
final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getOffsetZ();
for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.proxy.shouldAddParticles(r)) {
w.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(),
@@ -180,8 +180,8 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.breakBlock(pos, true);
w.updateListeners(pos, prev, w.getBlockState(pos), 3);
}
@Override
@@ -25,7 +25,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.math.Direction;
@@ -38,21 +38,21 @@ import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ParticleTypes;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.tile.misc.QuartzGrowthAcceleratorTileEntity;
import appeng.tile.misc.QuartzGrowthAcceleratorBlockEntity;
import appeng.util.Platform;
public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorTileEntity>
public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorBlockEntity>
implements IOrientableBlock {
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
public QuartzGrowthAcceleratorBlock() {
super(defaultProps(Material.ROCK).sound(BlockSoundGroup.METAL));
super(defaultProps(Material.STONE).sounds(BlockSoundGroup.METAL));
this.setDefaultState(this.getDefaultState().with(POWERED, false));
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuartzGrowthAcceleratorTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuartzGrowthAcceleratorBlockEntity te) {
return currentState.with(POWERED, te.isPowered());
}
@@ -69,7 +69,7 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
return;
}
final QuartzGrowthAcceleratorTileEntity cga = this.getTileEntity(w, pos);
final QuartzGrowthAcceleratorBlockEntity cga = this.getBlockEntity(w, pos);
if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) {
final double d0 = r.nextFloat() - 0.5F;
@@ -83,9 +83,9 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
double ry = 0.5 + pos.getY();
double rz = 0.5 + pos.getZ();
rx += up.getXOffset() * d0;
ry += up.getYOffset() * d0;
rz += up.getZOffset() * d0;
rx += up.getOffsetX() * d0;
ry += up.getOffsetY() * d0;
rz += up.getOffsetZ() * d0;
final int x = pos.getX();
final int y = pos.getY();
@@ -99,25 +99,25 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
case 0:
dx = 0.6;
dz = d1;
pt = new BlockPos(x + west.getXOffset(), y + west.getYOffset(), z + west.getZOffset());
pt = new BlockPos(x + west.getOffsetX(), y + west.getOffsetY(), z + west.getZOffset());
break;
case 1:
dx = d1;
dz += 0.6;
pt = new BlockPos(x + forward.getXOffset(), y + forward.getYOffset(), z + forward.getZOffset());
pt = new BlockPos(x + forward.getOffsetX(), y + forward.getOffsetY(), z + forward.getZOffset());
break;
case 2:
dx = d1;
dz = -0.6;
pt = new BlockPos(x - forward.getXOffset(), y - forward.getYOffset(), z - forward.getZOffset());
pt = new BlockPos(x - forward.getOffsetX(), y - forward.getOffsetY(), z - forward.getZOffset());
break;
case 3:
dx = -0.6;
dz = d1;
pt = new BlockPos(x - west.getXOffset(), y - west.getYOffset(), z - west.getZOffset());
pt = new BlockPos(x - west.getOffsetX(), y - west.getOffsetY(), z - west.getZOffset());
break;
}
@@ -126,15 +126,15 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
return;
}
rx += dx * west.getXOffset();
ry += dx * west.getYOffset();
rz += dx * west.getZOffset();
rx += dx * west.getOffsetX();
ry += dx * west.getOffsetY();
rz += dx * west.getOffsetZ();
rx += dz * forward.getXOffset();
ry += dz * forward.getYOffset();
rz += dz * forward.getZOffset();
rx += dz * forward.getOffsetX();
ry += dz * forward.getOffsetY();
rz += dz * forward.getOffsetZ();
Minecraft.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, rx, ry, rz, 0.0D, 0.0D, 0.0D);
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, rx, ry, rz, 0.0D, 0.0D, 0.0D);
}
}
@@ -30,16 +30,16 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
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.SecurityStationTileEntity;
import appeng.tile.misc.SecurityStationBlockEntity;
public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationTileEntity> {
public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationBlockEntity> {
private static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -56,20 +56,20 @@ public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationTileEnt
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, SecurityStationTileEntity te) {
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 BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final SecurityStationTileEntity tg = this.getTileEntity(w, pos);
final SecurityStationBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (w.isRemote()) {
if (w.isClient()) {
return ActionResult.SUCCESS;
}
@@ -19,7 +19,7 @@
package appeng.block.misc;
import net.fabricmc.api.EnvType;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.Environment;
import appeng.api.util.AEColor;
@@ -34,7 +34,7 @@ public class SecurityStationRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
rendering.blockColor(ColorableTileBlockColor.INSTANCE);
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
}
@@ -33,9 +33,9 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.misc.SkyCompassTileEntity;
import appeng.tile.misc.SkyCompassBlockEntity;
public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassBlockEntity> {
public SkyCompassBlock(Settings props) {
super(props);
@@ -43,7 +43,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
@Override
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
final SkyCompassTileEntity sc = this.getTileEntity(w, pos);
final SkyCompassBlockEntity sc = this.getBlockEntity(w, pos);
if (sc != null) {
return false;
}
@@ -59,7 +59,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final SkyCompassTileEntity sc = this.getTileEntity(world, pos);
final SkyCompassBlockEntity sc = this.getBlockEntity(world, pos);
final Direction forward = sc.getForward();
if (!this.canPlaceAt(world, pos, forward.getOpposite())) {
this.dropTorch(world, pos);
@@ -68,8 +68,8 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.breakBlock(pos, true);
w.updateListeners(pos, prev, w.getBlockState(pos), 3);
}
@Override
@@ -87,7 +87,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
// TODO: This definitely needs to be memoized
final SkyCompassTileEntity tile = this.getTileEntity(w, pos);
final SkyCompassBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
final Direction forward = tile.getForward();
@@ -24,13 +24,13 @@ import net.fabricmc.api.Environment;
import appeng.bootstrap.TileEntityRendering;
import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.SkyCompassTESR;
import appeng.tile.misc.SkyCompassTileEntity;
import appeng.tile.misc.SkyCompassBlockEntity;
public class SkyCompassRendering extends TileEntityRenderingCustomizer<SkyCompassTileEntity> {
public class SkyCompassRendering extends TileEntityRenderingCustomizer<SkyCompassBlockEntity> {
@Override
@Environment(EnvType.CLIENT)
public void customize(TileEntityRendering<SkyCompassTileEntity> rendering) {
public void customize(TileEntityRendering<SkyCompassBlockEntity> rendering) {
rendering.tileEntityRenderer(SkyCompassTESR::new);
}
@@ -34,7 +34,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -68,7 +68,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
this.startFuse(w, pos, player);
w.removeBlock(pos, false);
@@ -82,7 +82,7 @@ public class TinyTNTBlock extends AEBaseBlock {
}
public void startFuse(final World w, final BlockPos pos, final LivingEntity igniter) {
if (!w.isRemote) {
if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
w.addEntity(primedTinyTNTEntity);
@@ -112,7 +112,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override
public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) {
if (entity instanceof AbstractArrowEntity && !w.isRemote) {
if (entity instanceof AbstractArrowEntity && !w.isClient) {
final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity;
if (entityarrow.isBurning()) {
@@ -140,7 +140,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override
public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) {
super.onExplosionDestroy(w, pos, exp);
if (!w.isRemote) {
if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy());
primedTinyTNTEntity
@@ -34,7 +34,7 @@ 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.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
@@ -42,22 +42,22 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.VibrationChamberContainer;
import appeng.core.AEConfig;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.misc.VibrationChamberTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.misc.VibrationChamberBlockEntity;
import appeng.util.Platform;
public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChamberTileEntity> {
public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChamberBlockEntity> {
// Indicates that the vibration chamber is currently working
private static final BooleanProperty ACTIVE = BooleanProperty.create("active");
public VibrationChamberBlock() {
super(defaultProps(Material.IRON).hardnessAndResistance(4.2F));
super(defaultProps(Material.IRON).strength(4.2F));
this.setDefaultState(this.getDefaultState().with(ACTIVE, false));
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, VibrationChamberTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, VibrationChamberBlockEntity te) {
return currentState.with(ACTIVE, te.isOn);
}
@@ -69,14 +69,14 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (player.isInSneakingPose()) {
return ActionResult.PASS;
}
if (Platform.isServer()) {
final VibrationChamberTileEntity tc = this.getTileEntity(w, pos);
if (tc != null && !player.isCrouching()) {
final VibrationChamberBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResult.SUCCESS;
@@ -92,9 +92,9 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
return;
}
final AEBaseTileEntity tile = this.getTileEntity(w, pos);
if (tile instanceof VibrationChamberTileEntity) {
final VibrationChamberTileEntity tc = (VibrationChamberTileEntity) tile;
final AEBaseBlockEntity tile = this.getBlockEntity(w, pos);
if (tile instanceof VibrationChamberBlockEntity) {
final VibrationChamberBlockEntity tc = (VibrationChamberBlockEntity) tile;
if (tc.isOn) {
double f1 = pos.getX() + 0.5F;
double f2 = pos.getY() + 0.5F;
@@ -103,20 +103,20 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
final Direction forward = tc.getForward();
final Direction up = tc.getUp();
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset();
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.getXOffset() * 0.6;
f2 += forward.getYOffset() * 0.6;
f3 += forward.getZOffset() * 0.6;
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.getXOffset() * (-0.3 + oy);
f2 += up.getYOffset() * (-0.3 + oy);
f3 += up.getZOffset() * (-0.3 + oy);
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);
@@ -29,20 +29,21 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.DyeColor;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
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.NonNullList;
@@ -52,7 +53,6 @@ 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.IWorldReader;
import net.minecraft.world.World;
@@ -72,11 +72,11 @@ import appeng.helpers.AEGlassMaterial;
import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.networking.CableBusTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.tile.networking.CableBusBlockEntity;
import appeng.util.Platform;
public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implements IAEFacade {
public class CableBusBlock extends AEBaseTileBlock<CableBusBlockEntity> implements IAEFacade {
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
@@ -137,7 +137,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
public boolean isReplaceable(BlockState state, ItemPlacementContext useContext) {
// FIXME: Potentially check the fluid one too
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty();
}
@@ -146,7 +146,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
boolean willHarvest, IFluidState fluid) {
if (player.abilities.isCreativeMode) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos);
final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) {
tile.disableDrops();
}
@@ -199,7 +199,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
ICableBusContainer cb = this.cb(world, blockPos);
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
BakedModel model = MinecraftClient.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState());
// We cannot add the effect if we don't have the model
@@ -232,7 +232,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
ICableBusContainer cb = this.cb(world, pos);
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher()
BakedModel model = MinecraftClient.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState());
// We cannot add the effect if we dont have the model
@@ -281,11 +281,11 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
private ICableBusContainer cb(final BlockView w, final BlockPos pos) {
final BlockEntity te = w.getTileEntity(pos);
final BlockEntity te = w.getBlockEntity(pos);
ICableBusContainer out = null;
if (te instanceof CableBusTileEntity) {
out = ((CableBusTileEntity) te).getCableBus();
if (te instanceof CableBusBlockEntity) {
out = ((CableBusBlockEntity) te).getCableBus();
}
return out == null ? NULL_CABLE_BUS : out;
@@ -293,11 +293,11 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Nullable
private IFacadeContainer fc(final BlockView w, final BlockPos pos) {
final BlockEntity te = w.getTileEntity(pos);
final BlockEntity te = w.getBlockEntity(pos);
IFacadeContainer out = null;
if (te instanceof CableBusTileEntity) {
out = ((CableBusTileEntity) te).getCableBus().getFacadeContainer();
if (te instanceof CableBusBlockEntity) {
out = ((CableBusBlockEntity) te).getCableBus().getFacadeContainer();
}
return out;
@@ -305,15 +305,15 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if (worldIn.isRemote()) {
final HitResult rtr = Minecraft.getInstance().objectMouseOver;
if (rtr instanceof BlockRayTraceResult) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
if (worldIn.isClient()) {
final HitResult rtr = MinecraftClient.getInstance().objectMouseOver;
if (rtr instanceof BlockHitResult) {
BlockHitResult brtr = (BlockHitResult) rtr;
if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance().sendToServer(new ClickPacket(pos, brtr.getFace(), (float) hitVec.x,
NetworkHandler.instance().sendToServer(new ClickPacket(pos, brtr.getSide(), (float) hitVec.x,
(float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
}
}
@@ -327,18 +327,13 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
// Transform from world into block space
Vec3d hitVec = hit.getHitVec();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResult.SUCCESS : ActionResult.PASS;
}
@Override
public boolean recolorBlock(BlockState state, WorldAccess world, BlockPos pos, Direction side, DyeColor color) {
return recolorBlock(world, pos, side, color, null);
}
public boolean recolorBlock(final BlockView world, final BlockPos pos, final Direction side,
final DyeColor color, final PlayerEntity who) {
try {
@@ -370,7 +365,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
CableBusTileEntity te = getTileEntity(w, pos);
CableBusBlockEntity te = getBlockEntity(w, pos);
if (te == null) {
return VoxelShapes.empty();
} else {
@@ -380,7 +375,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
CableBusTileEntity te = getTileEntity(w, pos);
CableBusBlockEntity te = getBlockEntity(w, pos);
if (te == null) {
return VoxelShapes.empty();
} else {
@@ -22,7 +22,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader;
import net.fabricmc.api.EnvType;
@@ -30,14 +30,14 @@ import net.fabricmc.api.Environment;
import appeng.api.util.AEColor;
import appeng.parts.CableBusContainer;
import appeng.tile.networking.CableBusTileEntity;
import appeng.tile.networking.CableBusBlockEntity;
/**
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium
* variant) and 2 (bright variant).
*/
@Environment(EnvType.CLIENT)
public class CableBusColor implements IBlockColor {
public class CableBusColor implements BlockColorProvider {
@Override
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
@@ -45,9 +45,9 @@ public class CableBusColor implements IBlockColor {
AEColor busColor = AEColor.TRANSPARENT;
if (worldIn != null && pos != null) {
BlockEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof CableBusTileEntity) {
CableBusContainer container = ((CableBusTileEntity) tileEntity).getCableBus();
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity instanceof CableBusBlockEntity) {
CableBusContainer container = ((CableBusBlockEntity) tileEntity).getCableBus();
busColor = container.getColor();
}
}
@@ -34,7 +34,8 @@ public class CableBusRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(rt -> true);
// FIXME This is straight up impossible in Vanilla, and questionable if it's actually needed.
// FIXME rendering.renderType(rt -> true);
rendering.blockColor(new CableBusColor());
rendering.modelCustomizer((loc, model) -> model);
@@ -30,9 +30,9 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.ControllerTileEntity;
import appeng.tile.networking.ControllerBlockEntity;
public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
public class ControllerBlock extends AEBaseTileBlock<ControllerBlockEntity> {
public enum ControllerBlockState implements IStringSerializable {
offline, online, conflicted;
@@ -67,7 +67,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
ControllerRenderType.class);
public ControllerBlock() {
super(defaultProps(Material.IRON).hardnessAndResistance(6));
super(defaultProps(Material.IRON).strength(6));
this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline)
.with(CONTROLLER_TYPE, ControllerRenderType.block));
}
@@ -99,12 +99,12 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
int z = pos.getZ();
// Detect whether controllers are on both sides of the x, y, and z axes
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
&& this.getTileEntity(world, x + 1, y, z) != null;
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
&& this.getTileEntity(world, x, y + 1, z) != null;
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
&& this.getTileEntity(world, x, y, z + 1) != null;
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;
@@ -132,7 +132,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final ControllerTileEntity tc = this.getTileEntity(world, pos);
final ControllerBlockEntity tc = this.getBlockEntity(world, pos);
if (tc != null) {
tc.onNeighborChange(false);
}
@@ -18,7 +18,7 @@
package appeng.block.networking;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
@@ -29,6 +29,6 @@ public class ControllerRendering extends BlockRenderingCustomizer {
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// Disables the default model rotator
rendering.modelCustomizer((loc, model) -> model);
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
}
}
@@ -20,9 +20,9 @@ package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.CreativeEnergyCellTileEntity;
import appeng.tile.networking.CreativeEnergyCellBlockEntity;
public class CreativeEnergyCellBlock extends AEBaseTileBlock<CreativeEnergyCellTileEntity> {
public class CreativeEnergyCellBlock extends AEBaseTileBlock<CreativeEnergyCellBlockEntity> {
public CreativeEnergyCellBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
@@ -21,9 +21,9 @@ package appeng.block.networking;
import net.minecraft.block.Material;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.EnergyAcceptorTileEntity;
import appeng.tile.networking.EnergyAcceptorBlockEntity;
public class EnergyAcceptorBlock extends AEBaseTileBlock<EnergyAcceptorTileEntity> {
public class EnergyAcceptorBlock extends AEBaseTileBlock<EnergyAcceptorBlockEntity> {
public EnergyAcceptorBlock() {
super(defaultProps(Material.IRON));
@@ -31,9 +31,9 @@ import net.minecraft.util.NonNullList;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.EnergyCellTileEntity;
import appeng.tile.networking.EnergyCellBlockEntity;
public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellTileEntity> {
public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellBlockEntity> {
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7);
@@ -24,12 +24,12 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -41,10 +41,10 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.WirelessContainer;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.WirelessTileEntity;
import appeng.tile.networking.WirelessBlockEntity;
import appeng.util.Platform;
public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
public class WirelessBlock extends AEBaseTileBlock<WirelessBlockEntity> {
enum State implements IStringSerializable {
OFF, ON, HAS_CHANNEL;
@@ -58,14 +58,15 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
public static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
public WirelessBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid());
this.setFullSize(false);
this.setOpaque(false);
super(defaultProps(AEGlassMaterial.INSTANCE)
.nonOpaque()
.solidBlock((state, world, pos) -> false)
);
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, WirelessTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, WirelessBlockEntity te) {
State teState = State.OFF;
if (te.isActive()) {
@@ -84,11 +85,11 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
}
@Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand,
BlockRayTraceResult hit) {
final WirelessTileEntity tg = this.getTileEntity(w, pos);
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.isCrouching()) {
if (tg != null && !player.isInSneakingPose()) {
if (Platform.isServer()) {
ContainerOpener.openContainer(WirelessContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
@@ -96,12 +97,12 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
return ActionResult.SUCCESS;
}
return super.onBlockActivated(state, w, pos, player, hand, hit);
return super.onUse(state, w, pos, player, hand, hit);
}
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
final WirelessTileEntity tile = this.getTileEntity(w, pos);
final WirelessBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
final Direction forward = tile.getForward();
@@ -161,7 +162,7 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
final WirelessTileEntity tile = this.getTileEntity(w, pos);
final WirelessBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
final Direction forward = tile.getForward();
@@ -1,7 +1,7 @@
package appeng.block.networking;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -15,7 +15,7 @@ public class WirelessRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
}
}
@@ -26,7 +26,7 @@ import net.minecraftforge.client.model.data.IModelData;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng;
import appeng.helpers.Splotch;
import appeng.tile.misc.PaintSplotchesTileEntity;
import appeng.tile.misc.PaintSplotchesBlockEntity;
/**
* Renders paint blocks, which render multiple "splotches" that have been
@@ -58,7 +58,7 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
return Collections.emptyList();
}
PaintSplotches splotchesState = extraData.getData(PaintSplotchesTileEntity.SPLOTCHES);
PaintSplotches splotchesState = extraData.getData(PaintSplotchesBlockEntity.SPLOTCHES);
if (splotchesState == null) {
// This is the inventory model which should usually not be used other than in
@@ -23,7 +23,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
@@ -37,10 +37,10 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import appeng.block.AEBaseTileBlock;
import appeng.tile.misc.PaintSplotchesTileEntity;
import appeng.tile.misc.PaintSplotchesBlockEntity;
import appeng.util.Platform;
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntity> {
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesBlockEntity> {
public PaintSplotchesBlock() {
super(defaultProps(Material.WATER, MaterialColor.AIR));
this.setFullSize(false);
@@ -61,7 +61,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final PaintSplotchesTileEntity tp = this.getTileEntity(world, pos);
final PaintSplotchesBlockEntity tp = this.getBlockEntity(world, pos);
if (tp != null) {
tp.neighborChanged();
@@ -77,7 +77,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
@Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
final PaintSplotchesTileEntity tp = this.getTileEntity(w, pos);
final PaintSplotchesBlockEntity tp = this.getBlockEntity(w, pos);
if (tp != null) {
return tp.getLightLevel();
@@ -92,7 +92,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
}
@Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
public boolean isReplaceable(BlockState state, ItemPlacementContext useContext) {
return true;
}
@@ -7,12 +7,12 @@ import java.util.function.Function;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.render.model.ModelBakery;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration;
@@ -21,9 +21,9 @@ import net.minecraftforge.client.model.geometry.IModelGeometry;
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel> {
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
return new PaintSplotchesBakedModel(spriteGetter);
}
@@ -1,7 +1,7 @@
package appeng.block.paint;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -14,7 +14,7 @@ public class PaintSplotchesRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
// Disable auto rotation
rendering.modelCustomizer((location, model) -> model);
}
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.renderer.texture.AtlasTexture;
@@ -28,7 +28,7 @@ import net.minecraftforge.client.model.data.IModelData;
import appeng.api.AEApi;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.tile.qnb.QuantumBridgeBlockEntity;
class QnbFormedBakedModel implements IDynamicBakedModel {
@@ -54,7 +54,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
private final IBakedModel baseModel;
private final BakedModel baseModel;
private final Block linkBlock;
@@ -65,7 +65,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
private final TextureAtlasSprite lightTexture;
private final TextureAtlasSprite lightCornerTexture;
public QnbFormedBakedModel(IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
public QnbFormedBakedModel(BakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
this.baseModel = baseModel;
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
@@ -79,7 +79,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
IModelData modelData) {
QnbFormedState formedState = modelData.getData(QuantumBridgeTileEntity.FORMED_STATE);
QnbFormedState formedState = modelData.getData(QuantumBridgeBlockEntity.FORMED_STATE);
if (formedState == null) {
return this.baseModel.getQuads(state, side, rand);
@@ -121,9 +121,9 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
// Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture
// (avoids z-fighting)
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
builder.setDrawFaces(EnumSet.of(facing));
builder.addCube(DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset,
@@ -147,9 +147,9 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
// Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture
// (avoids z-fighting)
float xOffset = Math.abs(facing.getXOffset() * 0.01f);
float yOffset = Math.abs(facing.getYOffset() * 0.01f);
float zOffset = Math.abs(facing.getZOffset() * 0.01f);
float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
builder.setDrawFaces(EnumSet.of(facing));
builder.addCube(-xOffset, -yOffset, -zOffset, 16 + xOffset, 16 + yOffset, 16 + zOffset);
@@ -7,12 +7,12 @@ import java.util.function.Function;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material;
import net.minecraft.client.render.model.ModelBakery;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration;
@@ -25,10 +25,10 @@ public class QnbFormedModel implements IModelGeometry<QnbFormedModel> {
private static final Identifier MODEL_RING = new Identifier(AppEng.MOD_ID, "block/qnb/ring");
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
BakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
return new QnbFormedBakedModel(ringModel, spriteGetter);
}
@@ -31,9 +31,9 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.tile.qnb.QuantumBridgeBlockEntity;
public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTileEntity> {
public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeBlockEntity> {
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
@@ -62,31 +62,31 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeBlockEntity te) {
return currentState.with(FORMED, te.isFormed());
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final QuantumBridgeTileEntity bridge = this.getTileEntity(world, pos);
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(world, pos);
if (bridge != null) {
bridge.neighborUpdate();
}
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
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 QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
if (bridge != null) {
bridge.breakCluster();
}
super.onReplaced(state, w, pos, newState, isMoving);
super.onStateReplaced(state, w, pos, newState, isMoving);
}
}
@@ -1,7 +1,7 @@
package appeng.block.qnb;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -14,7 +14,7 @@ public class QuantumBridgeRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
// Disable auto rotation
rendering.modelCustomizer((location, model) -> model);
}
@@ -29,7 +29,7 @@ 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.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -42,7 +42,7 @@ import appeng.container.ContainerOpener;
import appeng.container.implementations.QNBContainer;
import appeng.core.AppEng;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.tile.qnb.QuantumBridgeBlockEntity;
import appeng.util.Platform;
public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@@ -61,7 +61,7 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@Override
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random rand) {
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
if (bridge != null) {
if (bridge.hasQES()) {
if (AppEng.proxy.shouldAddParticles(rand)) {
@@ -74,12 +74,12 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final QuantumBridgeTileEntity tg = this.getTileEntity(w, pos);
final QuantumBridgeBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(QNBContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
@@ -27,7 +27,7 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.tile.qnb.QuantumBridgeBlockEntity;
public class QuantumRingBlock extends QuantumBaseBlock {
@@ -41,7 +41,7 @@ public class QuantumRingBlock extends QuantumBaseBlock {
@Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos);
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
if (bridge != null && bridge.isCorner()) {
return SHAPE_CORNER;
} else if (bridge != null && bridge.isFormed()) {
@@ -50,7 +50,7 @@ public class MatrixFrameBlock extends AEBaseBlock {
false, PushReaction.PUSH_ONLY);
public MatrixFrameBlock() {
super(Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops());
super(Settings.create(MATERIAL).strength(-1.0F, 6000000.0F).notSolid().noDrops());
}
@Override
@@ -28,17 +28,17 @@ 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.math.BlockRayTraceResult;
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.SpatialIOPortTileEntity;
import appeng.tile.spatial.SpatialIOPortBlockEntity;
import appeng.util.Platform;
public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity> {
public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortBlockEntity> {
public SpatialIOPortBlock() {
super(defaultProps(Material.IRON));
@@ -47,7 +47,7 @@ public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity>
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final SpatialIOPortTileEntity te = this.getTileEntity(world, pos);
final SpatialIOPortBlockEntity te = this.getBlockEntity(world, pos);
if (te != null) {
te.updateRedstoneState();
}
@@ -55,12 +55,12 @@ public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity>
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final SpatialIOPortTileEntity tg = this.getTileEntity(w, pos);
final SpatialIOPortBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(SpatialIOPortContainer.TYPE, p,
@@ -26,9 +26,9 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.spatial.SpatialPylonTileEntity;
import appeng.tile.spatial.SpatialPylonBlockEntity;
public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonBlockEntity> {
public SpatialPylonBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
@@ -37,7 +37,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final SpatialPylonTileEntity tsp = this.getTileEntity(world, pos);
final SpatialPylonBlockEntity tsp = this.getBlockEntity(world, pos);
if (tsp != null) {
tsp.neighborChanged();
}
@@ -45,7 +45,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
@Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) {
final SpatialPylonTileEntity tsp = this.getTileEntity(w, pos);
final SpatialPylonBlockEntity tsp = this.getBlockEntity(w, pos);
if (tsp != null) {
return tsp.getLightValue();
}
@@ -30,7 +30,7 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
@@ -38,9 +38,9 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ChestContainer;
import appeng.core.localization.PlayerMessages;
import appeng.tile.storage.ChestTileEntity;
import appeng.tile.storage.ChestBlockEntity;
public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
DriveSlotState.class);
@@ -57,7 +57,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, ChestTileEntity te) {
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, ChestBlockEntity te) {
DriveSlotState slotState = DriveSlotState.EMPTY;
if (te.getCellCount() >= 1) {
@@ -73,14 +73,14 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final ChestTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
if (w.isRemote()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
final ChestBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !p.isInSneakingPose()) {
if (w.isClient()) {
return ActionResult.SUCCESS;
}
if (hit.getFace() == tg.getUp()) {
if (hit.getSide() == tg.getUp()) {
if (!tg.openGui(p)) {
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
}
@@ -20,7 +20,7 @@ package appeng.block.storage;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import appeng.api.util.AEColor;
import appeng.bootstrap.BlockRenderingCustomizer;
@@ -34,7 +34,7 @@ public class ChestRendering extends BlockRenderingCustomizer {
@Override
@Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
// I checked, the ME chest doesn't keep its color in item form
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
@@ -26,17 +26,17 @@ 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.math.BlockRayTraceResult;
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.DriveTileEntity;
import appeng.tile.storage.DriveBlockEntity;
import appeng.util.Platform;
public class DriveBlock extends AEBaseTileBlock<DriveTileEntity> {
public class DriveBlock extends AEBaseTileBlock<DriveBlockEntity> {
public DriveBlock() {
super(defaultProps(Material.IRON));
@@ -44,12 +44,12 @@ public class DriveBlock extends AEBaseTileBlock<DriveTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final DriveTileEntity tg = this.getTileEntity(w, pos);
final DriveBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(DriveContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
@@ -18,7 +18,7 @@
package appeng.block.storage;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.render.RenderLayer;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
@@ -27,6 +27,6 @@ import appeng.bootstrap.IItemRendering;
public class DriveRendering extends BlockRenderingCustomizer {
@Override
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.renderType(RenderLayer.getCutout());
}
}
@@ -27,18 +27,18 @@ 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.util.math.BlockRayTraceResult;
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.IOPortTileEntity;
import appeng.tile.storage.IOPortBlockEntity;
import appeng.util.Platform;
public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
public class IOPortBlock extends AEBaseTileBlock<IOPortBlockEntity> {
public IOPortBlock() {
super(defaultProps(Material.IRON));
@@ -47,7 +47,7 @@ public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
final IOPortTileEntity te = this.getTileEntity(world, pos);
final IOPortBlockEntity te = this.getBlockEntity(world, pos);
if (te != null) {
te.updateRedstoneState();
}
@@ -55,12 +55,12 @@ public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isInSneakingPose()) {
return ActionResult.PASS;
}
final IOPortTileEntity tg = this.getTileEntity(w, pos);
final IOPortBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) {
if (Platform.isServer()) {
ContainerOpener.openContainer(IOPortContainer.TYPE, p,
@@ -29,7 +29,7 @@ import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
@@ -40,10 +40,10 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.SkyChestContainer;
import appeng.tile.storage.SkyChestTileEntity;
import appeng.tile.storage.SkyChestBlockEntity;
import appeng.util.Platform;
public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
public class SkyChestBlock extends AEBaseTileBlock<SkyChestBlockEntity> {
private static final double AABB_OFFSET_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0.06;
@@ -55,7 +55,7 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
public final SkyChestType type;
public SkyChestBlock(final SkyChestType type, Properties props) {
public SkyChestBlock(final SkyChestType type, Settings props) {
super(props);
this.type = type;
}
@@ -72,9 +72,9 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
@Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (Platform.isServer()) {
SkyChestTileEntity tile = getTileEntity(w, pos);
SkyChestBlockEntity tile = getBlockEntity(w, pos);
if (tile == null) {
return ActionResult.PASS;
}
@@ -93,31 +93,31 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
}
private Box computeAABB(final BlockView w, final BlockPos pos) {
final SkyChestTileEntity sk = this.getTileEntity(w, pos);
final SkyChestBlockEntity sk = this.getBlockEntity(w, pos);
Direction o = Direction.UP;
if (sk != null) {
o = sk.getUp();
}
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetX = o.getOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0;
// for x/z top and bottom is swapped
final double minX = Math.max(0.0,
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP)));
offsetX + (o.getOffsetX() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetX() * AABB_OFFSET_TOP)));
final double minY = Math.max(0.0,
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM)));
offsetY + (o.getOffsetY() < 0 ? AABB_OFFSET_TOP : (o.getOffsetY() * AABB_OFFSET_BOTTOM)));
final double minZ = Math.max(0.0,
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP)));
offsetZ + (o.getOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetZ() * AABB_OFFSET_TOP)));
final double maxX = Math.min(1.0,
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM)));
1.0 - offsetX - (o.getOffsetX() < 0 ? AABB_OFFSET_TOP : (o.getOffsetX() * AABB_OFFSET_BOTTOM)));
final double maxY = Math.min(1.0,
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP)));
1.0 - offsetY - (o.getOffsetY() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetY() * AABB_OFFSET_TOP)));
final double maxZ = Math.min(1.0,
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM)));
1.0 - offsetZ - (o.getOffsetZ() < 0 ? AABB_OFFSET_TOP : (o.getOffsetZ() * AABB_OFFSET_BOTTOM)));
return new Box(minX, minY, minZ, maxX, maxY, maxZ);
}