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);
}
@@ -18,29 +18,11 @@
package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.fabricmc.api.EnvType;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseBlockItem;
import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEItemGroup;
import appeng.core.AppEng;
@@ -48,12 +30,28 @@ import appeng.core.CreativeTab;
import appeng.core.features.BlockDefinition;
import appeng.core.features.TileDefinition;
import appeng.util.Platform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Supplier;
class BlockDefinitionBuilder implements IBlockBuilder {
private final FeatureFactory factory;
private final String registryName;
private final Identifier id;
private final Supplier<? extends Block> blockSupplier;
@@ -67,7 +65,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
private boolean disableItem = false;
private BiFunction<Block, Item.Properties, BlockItem> itemFactory;
private BiFunction<Block, Item.Settings, BlockItem> itemFactory;
@Environment(EnvType.CLIENT)
private BlockRendering blockRendering;
@@ -77,11 +75,11 @@ class BlockDefinitionBuilder implements IBlockBuilder {
BlockDefinitionBuilder(FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier) {
this.factory = factory;
this.registryName = id;
this.id = new Identifier(AppEng.MOD_ID, id);
this.blockSupplier = blockSupplier;
if (Platform.hasClientClasses()) {
this.blockRendering = new BlockRendering();
this.blockRendering = new BlockRendering(this.id);
this.itemRendering = new ItemRendering();
}
}
@@ -121,7 +119,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
}
@Override
public IBlockBuilder item(BiFunction<Block, Item.Properties, BlockItem> factory) {
public IBlockBuilder item(BiFunction<Block, Item.Settings, BlockItem> factory) {
this.itemFactory = factory;
return this;
}
@@ -142,18 +140,12 @@ class BlockDefinitionBuilder implements IBlockBuilder {
public <T extends IBlockDefinition> T build() {
// Create block and matching item, and set factory name of both
Block block = this.blockSupplier.get();
block.setRegistryName(AppEng.MOD_ID, this.registryName);
BlockItem item = this.constructItemFromBlock(block);
if (item != null) {
item.setRegistryName(AppEng.MOD_ID, this.registryName);
}
// Register the item and block with the game
this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
Registry.register(Registry.BLOCK, id, block);
BlockItem item = this.constructItemFromBlock(block);
if (item != null) {
this.factory
.addBootstrapComponent((IItemRegistrationComponent) (side, registry) -> registry.register(item));
Registry.register(Registry.ITEM, id, item);
}
// Register all extra handlers
@@ -174,9 +166,9 @@ class BlockDefinitionBuilder implements IBlockBuilder {
T definition;
if (block instanceof AEBaseTileBlock) {
definition = (T) new TileDefinition(this.registryName, (AEBaseTileBlock<?>) block, item, features);
definition = (T) new TileDefinition(this.id.getPath(), (AEBaseTileBlock<?>) block, item, features);
} else {
definition = (T) new BlockDefinition(this.registryName, block, item, features);
definition = (T) new BlockDefinition(this.id.getPath(), block, item, features);
}
if (itemGroup instanceof AEItemGroup) {
@@ -192,7 +184,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
return null;
}
Item.Properties itemProperties = new Item.Properties();
Item.Settings itemProperties = new Item.Settings();
if (itemGroup != null) {
itemProperties.group(itemGroup);
@@ -24,7 +24,7 @@ import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AppEng;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockStackSrc;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform;
/**
@@ -33,7 +33,7 @@ import appeng.util.Platform;
*
* @param <T>
*/
public class TileEntityBuilder<T extends AEBaseTileEntity> {
public class BlockEntityBuilder<T extends AEBaseBlockEntity> {
private final FeatureFactory factory;
@@ -54,8 +54,8 @@ public class TileEntityBuilder<T extends AEBaseTileEntity> {
private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
public TileEntityBuilder(FeatureFactory factory, String registryName, Class<T> tileClass,
Function<BlockEntityType<T>, T> supplier) {
public BlockEntityBuilder(FeatureFactory factory, String registryName, Class<T> tileClass,
Function<BlockEntityType<T>, T> supplier) {
this.factory = factory;
this.registryName = registryName;
this.tileClass = tileClass;
@@ -66,18 +66,18 @@ public class TileEntityBuilder<T extends AEBaseTileEntity> {
}
}
public TileEntityBuilder<T> features(AEFeature... features) {
public BlockEntityBuilder<T> features(AEFeature... features) {
this.features.clear();
this.addFeatures(features);
return this;
}
public TileEntityBuilder<T> addFeatures(AEFeature... features) {
public BlockEntityBuilder<T> addFeatures(AEFeature... features) {
Collections.addAll(this.features, features);
return this;
}
public TileEntityBuilder<T> rendering(TileEntityRenderingCustomizer<T> customizer) {
public BlockEntityBuilder<T> rendering(TileEntityRenderingCustomizer<T> customizer) {
DistExecutor.runWhenOn(EnvType.CLIENT, () -> () -> customizer.customize(tileEntityRendering));
return this;
}
@@ -95,7 +95,7 @@ public class TileEntityBuilder<T extends AEBaseTileEntity> {
type.setRegistryName(AppEng.MOD_ID, registryName);
registry.register(type);
AEBaseTileEntity.registerTileItem(tileClass, new BlockStackSrc(blocks.get(0), ActivityState.Enabled));
AEBaseBlockEntity.registerTileItem(tileClass, new BlockStackSrc(blocks.get(0), ActivityState.Enabled));
for (Block block : blocks) {
if (block instanceof AEBaseTileBlock) {
@@ -19,69 +19,67 @@
package appeng.bootstrap;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.util.Identifier;
import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.BlockColorComponent;
import appeng.bootstrap.components.RenderTypeComponent;
import appeng.client.render.model.AutoRotatingBakedModel;
import net.minecraft.util.registry.Registry;
class BlockRendering implements IBlockRendering {
@Environment(EnvType.CLIENT)
private BiFunction<Identifier, IBakedModel, IBakedModel> modelCustomizer;
private final Identifier id;
@Environment(EnvType.CLIENT)
private IBlockColor blockColor;
private BiFunction<Identifier, BakedModel, BakedModel> modelCustomizer;
@Environment(EnvType.CLIENT)
private RenderType renderType;
private BlockColorProvider blockColor;
@Environment(EnvType.CLIENT)
private Predicate<RenderType> renderTypes;
private RenderLayer renderType;
public BlockRendering(Identifier id) {
this.id = id;
}
@Override
@Environment(EnvType.CLIENT)
public IBlockRendering modelCustomizer(BiFunction<Identifier, IBakedModel, IBakedModel> customizer) {
public IBlockRendering modelCustomizer(BiFunction<Identifier, BakedModel, BakedModel> customizer) {
this.modelCustomizer = customizer;
return this;
}
@Environment(EnvType.CLIENT)
@Override
public IBlockRendering blockColor(IBlockColor blockColor) {
public IBlockRendering blockColor(BlockColorProvider blockColor) {
this.blockColor = blockColor;
return this;
}
@Override
public IBlockRendering renderType(RenderType type) {
public IBlockRendering renderType(RenderLayer type) {
this.renderType = type;
return this;
}
@Override
public IBlockRendering renderType(Predicate<RenderType> typePredicate) {
this.renderTypes = typePredicate;
return this;
}
void apply(FeatureFactory factory, Block block) {
if (this.modelCustomizer != null) {
factory.addModelOverride(block.getRegistryName().getPath(), this.modelCustomizer);
factory.addModelOverride(id.getPath(), this.modelCustomizer);
} else if (block instanceof AEBaseTileBlock) {
// This is a default rotating model if the base-block uses an AE tile entity
// which exposes UP/FRONT as
// extended props
factory.addModelOverride(block.getRegistryName().getPath(), (l, m) -> new AutoRotatingBakedModel(m));
factory.addModelOverride(id.getPath(), (l, m) -> new AutoRotatingBakedModel(m));
}
// TODO : 1.12
@@ -89,8 +87,8 @@ class BlockRendering implements IBlockRendering {
factory.addBootstrapComponent(new BlockColorComponent(block, this.blockColor));
}
if (this.renderType != null || this.renderTypes != null) {
factory.addBootstrapComponent(new RenderTypeComponent(block, this.renderType, this.renderTypes));
if (this.renderType != null) {
factory.addBootstrapComponent(new RenderTypeComponent(block, this.renderType));
}
}
}
@@ -1,17 +1,15 @@
package appeng.bootstrap;
import appeng.api.features.AEFeature;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.registry.Registry;
import java.util.Collections;
import java.util.EnumSet;
import java.util.function.Consumer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import appeng.api.features.AEFeature;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.core.AppEng;
/**
* Helper to register a custom Entity with Minecraft.
*/
@@ -25,8 +23,8 @@ public class EntityBuilder<T extends Entity> {
private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
public EntityBuilder(FeatureFactory factory, String id, EntityType.IFactory<T> entityFactory,
EntityClassification classification) {
public EntityBuilder(FeatureFactory factory, String id, EntityType.EntityFactory<T> entityFactory,
SpawnGroup classification) {
this.factory = factory;
this.id = id;
this.builder = EntityType.Builder.create(entityFactory, classification);
@@ -49,11 +47,9 @@ public class EntityBuilder<T extends Entity> {
}
public EntityType<T> build() {
EntityType<T> entityType = builder.build("appliedenergistics2:" + id);
entityType.setRegistryName(AppEng.MOD_ID, id);
factory.addBootstrapComponent((IEntityRegistrationComponent) r -> {
r.register(entityType);
});
String fullId = "appliedenergistics2:" + this.id;
EntityType<T> entityType = builder.build(fullId);
Registry.register(Registry.ENTITY_TYPE, fullId, entityType);
return entityType;
}
}
@@ -31,9 +31,9 @@ import java.util.function.Supplier;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.block.entity.BlockEntityType;
@@ -42,7 +42,7 @@ import net.fabricmc.api.EnvType;
import appeng.api.features.AEFeature;
import appeng.bootstrap.components.ModelOverrideComponent;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform;
public class FeatureFactory {
@@ -76,18 +76,18 @@ public class FeatureFactory {
return new BlockDefinitionBuilder(this, id, block).features(this.defaultFeatures);
}
public IItemBuilder item(String id, Function<Item.Properties, Item> itemFactory) {
public IItemBuilder item(String id, Function<Item.Settings, Item> itemFactory) {
return new ItemDefinitionBuilder(this, id, itemFactory).features(this.defaultFeatures);
}
public <T extends Entity> EntityBuilder<T> entity(String id, EntityType.IFactory<T> factory,
EntityClassification classification) {
public <T extends Entity> EntityBuilder<T> entity(String id, EntityType.EntityFactory<T> factory,
SpawnGroup classification) {
return new EntityBuilder<T>(this, id, factory, classification).features(this.defaultFeatures);
}
public <T extends AEBaseTileEntity> TileEntityBuilder<T> tileEntity(String id, Class<T> teClass,
Function<BlockEntityType<T>, T> factory) {
return new TileEntityBuilder<>(this, id, teClass, factory).features(this.defaultFeatures);
public <T extends AEBaseBlockEntity> BlockEntityBuilder<T> tileEntity(String id, Class<T> teClass,
Function<BlockEntityType<T>, T> factory) {
return new BlockEntityBuilder<>(this, id, teClass, factory).features(this.defaultFeatures);
}
public FeatureFactory features(AEFeature... features) {
@@ -105,7 +105,7 @@ public class FeatureFactory {
}
@Environment(EnvType.CLIENT)
void addModelOverride(String resourcePath, BiFunction<Identifier, IBakedModel, IBakedModel> customizer) {
void addModelOverride(String resourcePath, BiFunction<Identifier, BakedModel, BakedModel> customizer) {
this.modelOverrideComponent.addOverride(resourcePath, customizer);
}
@@ -44,7 +44,7 @@ public interface IBlockBuilder {
*/
IBlockBuilder disableItem();
IBlockBuilder item(BiFunction<Block, Item.Properties, BlockItem> factory);
IBlockBuilder item(BiFunction<Block, Item.Settings, BlockItem> factory);
<T extends IBlockDefinition> T build();
}
@@ -23,9 +23,9 @@ import java.util.function.Predicate;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.util.Identifier;
/**
@@ -35,15 +35,12 @@ import net.minecraft.util.Identifier;
public interface IBlockRendering {
@Environment(EnvType.CLIENT)
IBlockRendering modelCustomizer(BiFunction<Identifier, IBakedModel, IBakedModel> customizer);
IBlockRendering modelCustomizer(BiFunction<Identifier, BakedModel, BakedModel> customizer);
@Environment(EnvType.CLIENT)
IBlockRendering blockColor(IBlockColor blockColor);
IBlockRendering blockColor(BlockColorProvider blockColor);
@Environment(EnvType.CLIENT)
IBlockRendering renderType(RenderType type);
@Environment(EnvType.CLIENT)
IBlockRendering renderType(Predicate<RenderType> type);
IBlockRendering renderType(RenderLayer type);
}
@@ -18,10 +18,10 @@
package appeng.bootstrap;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.advancement.criterion.Criterion;
import net.minecraft.advancement.criterion.CriterionConditions;
@FunctionalInterface
public interface ICriterionTriggerRegistry {
void register(ICriterionTrigger<? extends ICriterionInstance> trigger);
void register(Criterion<? extends CriterionConditions> trigger);
}
@@ -22,7 +22,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.dispenser.IDispenseItemBehavior;
import net.minecraft.block.dispenser.DispenserBehavior;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@@ -42,14 +42,14 @@ public interface IItemBuilder {
IItemBuilder itemGroup(ItemGroup tab);
IItemBuilder props(Consumer<Item.Properties> customizer);
IItemBuilder props(Consumer<Item.Settings> customizer);
IItemBuilder rendering(ItemRenderingCustomizer callback);
/**
* Registers a custom dispenser behavior for this item.
*/
IItemBuilder dispenserBehavior(Supplier<IDispenseItemBehavior> behavior);
IItemBuilder dispenserBehavior(Supplier<DispenserBehavior> behavior);
ItemDefinition build();
}
@@ -18,7 +18,7 @@
package appeng.bootstrap;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.color.item.ItemColorProvider;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -32,6 +32,6 @@ public interface IItemRendering {
* and returns a color multiplier.
*/
@Environment(EnvType.CLIENT)
IItemRendering color(IItemColor itemColor);
IItemRendering color(ItemColorProvider itemColor);
}
@@ -27,7 +27,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.block.DispenserBlock;
import net.minecraft.dispenser.IDispenseItemBehavior;
import net.minecraft.block.dispenser.DispenserBehavior;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.fabricmc.api.EnvType;
@@ -35,37 +35,38 @@ import net.fabricmc.api.Environment;
import appeng.api.features.AEFeature;
import appeng.bootstrap.components.IInitComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.core.AEItemGroup;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.features.ItemDefinition;
import appeng.util.Platform;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
class ItemDefinitionBuilder implements IItemBuilder {
private final FeatureFactory factory;
private final String registryName;
private final Identifier id;
private final Function<Item.Properties, Item> itemFactory;
private final Function<Item.Settings, Item> itemFactory;
private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>();
private final Item.Properties props = new Item.Properties();
private final Item.Settings props = new Item.Settings();
private Supplier<IDispenseItemBehavior> dispenserBehaviorSupplier;
private Supplier<DispenserBehavior> dispenserBehaviorSupplier;
@Environment(EnvType.CLIENT)
private ItemRendering itemRendering;
private ItemGroup itemGroup = CreativeTab.INSTANCE;
ItemDefinitionBuilder(FeatureFactory factory, String registryName, Function<Item.Properties, Item> itemFactory) {
ItemDefinitionBuilder(FeatureFactory factory, String id, Function<Item.Settings, Item> itemFactory) {
this.factory = factory;
this.registryName = registryName;
this.id = AppEng.makeId(id);
this.itemFactory = itemFactory;
if (Platform.hasClientClasses()) {
this.itemRendering = new ItemRendering();
@@ -98,7 +99,7 @@ class ItemDefinitionBuilder implements IItemBuilder {
}
@Override
public IItemBuilder props(Consumer<Item.Properties> consumer) {
public IItemBuilder props(Consumer<Item.Settings> consumer) {
consumer.accept(props);
return this;
}
@@ -113,7 +114,7 @@ class ItemDefinitionBuilder implements IItemBuilder {
}
@Override
public IItemBuilder dispenserBehavior(Supplier<IDispenseItemBehavior> behavior) {
public IItemBuilder dispenserBehavior(Supplier<DispenserBehavior> behavior) {
this.dispenserBehaviorSupplier = behavior;
return this;
}
@@ -128,9 +129,8 @@ class ItemDefinitionBuilder implements IItemBuilder {
props.group(itemGroup);
Item item = this.itemFactory.apply(props);
item.setRegistryName(AppEng.MOD_ID, this.registryName);
ItemDefinition definition = new ItemDefinition(this.registryName, item, features);
ItemDefinition definition = new ItemDefinition(id.getPath(), item, features);
// Register all extra handlers
this.boostrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(item)));
@@ -138,12 +138,12 @@ class ItemDefinitionBuilder implements IItemBuilder {
// Register custom dispenser behavior if requested
if (this.dispenserBehaviorSupplier != null) {
this.factory.addBootstrapComponent((IInitComponent) () -> {
IDispenseItemBehavior behavior = this.dispenserBehaviorSupplier.get();
DispenserBlock.registerDispenseBehavior(item, behavior);
DispenserBehavior behavior = this.dispenserBehaviorSupplier.get();
DispenserBlock.registerBehavior(item, behavior);
});
}
this.factory.addBootstrapComponent((IItemRegistrationComponent) (side, reg) -> reg.register(item));
Registry.register(Registry.ITEM, id, item);
if (Platform.hasClientClasses()) {
this.itemRendering.apply(this.factory, item);
@@ -19,7 +19,7 @@
package appeng.bootstrap;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.item.Item;
import net.fabricmc.api.EnvType;
@@ -28,11 +28,11 @@ import appeng.bootstrap.components.ItemColorComponent;
class ItemRendering implements IItemRendering {
@Environment(EnvType.CLIENT)
private IItemColor itemColor;
private ItemColorProvider itemColor;
@Override
@Environment(EnvType.CLIENT)
public IItemRendering color(IItemColor itemColor) {
public IItemRendering color(ItemColorProvider itemColor) {
this.itemColor = itemColor;
return this;
}
@@ -20,21 +20,21 @@ package appeng.bootstrap;
import java.util.function.Function;
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.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
public class TileEntityRendering<T extends AEBaseTileEntity> {
public class TileEntityRendering<T extends AEBaseBlockEntity> {
@Environment(EnvType.CLIENT)
Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer;
Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> tileEntityRenderer;
@Environment(EnvType.CLIENT)
public TileEntityRendering<T> tileEntityRenderer(
Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer) {
Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> tileEntityRenderer) {
this.tileEntityRenderer = tileEntityRenderer;
return this;
}
@@ -21,14 +21,14 @@ package appeng.bootstrap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.AEBaseBlockEntity;
/**
* A callback that allows the rendering of a tile entity to be customized. Sadly
* this class is required and no lambdas can be used due to them not being able
* to be annotated with @OnlyIn(CLIENT).
*/
public abstract class TileEntityRenderingCustomizer<T extends AEBaseTileEntity> {
public abstract class TileEntityRenderingCustomizer<T extends AEBaseBlockEntity> {
@Environment(EnvType.CLIENT)
public abstract void customize(TileEntityRendering<T> rendering);
@@ -19,23 +19,23 @@
package appeng.bootstrap.components;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.block.BlockColorProvider;
public class BlockColorComponent implements IInitComponent {
private final Block block;
private final IBlockColor blockColor;
private final BlockColorProvider blockColor;
public BlockColorComponent(Block block, IBlockColor blockColor) {
public BlockColorComponent(Block block, BlockColorProvider blockColor) {
this.block = block;
this.blockColor = blockColor;
}
@Override
public void initialize() {
Minecraft.getInstance().getBlockColors().register(this.blockColor, this.block);
MinecraftClient.getInstance().getBlockColors().registerColorProvider(this.blockColor, this.block);
}
}
@@ -1,13 +0,0 @@
package appeng.bootstrap.components;
import net.fabricmc.api.EnvType;
import net.minecraft.block.Block;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IBlockRegistrationComponent extends IBootstrapComponent {
void blockRegistration(EnvType dist, IForgeRegistry<Block> blockRegistry);
}
@@ -1,12 +0,0 @@
package appeng.bootstrap.components;
import net.minecraft.entity.EntityType;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IEntityRegistrationComponent extends IBootstrapComponent {
void entityRegistration(IForgeRegistry<EntityType<?>> entityRegistry);
}
@@ -1,7 +1,7 @@
package appeng.bootstrap.components;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
import appeng.bootstrap.IBootstrapComponent;
@@ -1,13 +0,0 @@
package appeng.bootstrap.components;
import net.minecraft.item.Item;
import net.fabricmc.api.EnvType;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IItemRegistrationComponent extends IBootstrapComponent {
void itemRegistration(EnvType dist, IForgeRegistry<Item> itemRegistry);
}
@@ -1,13 +0,0 @@
package appeng.bootstrap.components;
import net.fabricmc.api.EnvType;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IRecipeRegistrationComponent extends IBootstrapComponent {
void recipeRegistration(EnvType dist, IForgeRegistry<IRecipeSerializer<?>> recipeRegistry);
}
@@ -18,17 +18,17 @@
package appeng.bootstrap.components;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.item.Item;
public class ItemColorComponent implements IItemColorRegistrationComponent {
private final Item item;
private final IItemColor itemColor;
private final ItemColorProvider itemColor;
public ItemColorComponent(Item item, IItemColor itemColor) {
public ItemColorComponent(Item item, ItemColorProvider itemColor) {
this.item = item;
this.itemColor = itemColor;
}
@@ -25,8 +25,8 @@ import java.util.function.BiFunction;
import com.google.common.collect.Sets;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.ModelBakery;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.util.Identifier;
import net.minecraftforge.client.event.ModelBakeEvent;
@@ -35,33 +35,33 @@ import appeng.core.AppEng;
public class ModelOverrideComponent implements IModelBakeComponent {
// Maps from resource path to customizer
private final Map<String, BiFunction<Identifier, IBakedModel, IBakedModel>> customizer = new HashMap<>();
private final Map<String, BiFunction<Identifier, BakedModel, BakedModel>> customizer = new HashMap<>();
public void addOverride(String resourcePath, BiFunction<Identifier, IBakedModel, IBakedModel> customizer) {
public void addOverride(String resourcePath, BiFunction<Identifier, BakedModel, BakedModel> customizer) {
this.customizer.put(resourcePath, customizer);
}
@Override
public void onModelBakeEvent(final ModelBakeEvent event) {
Map<Identifier, IBakedModel> modelRegistry = event.getModelRegistry();
Map<Identifier, BakedModel> modelRegistry = event.getModelRegistry();
Set<Identifier> keys = Sets.newHashSet(modelRegistry.keySet());
IBakedModel missingModel = modelRegistry.get(ModelBakery.MODEL_MISSING);
BakedModel missingModel = modelRegistry.get(ModelLoader.MISSING);
for (Identifier location : keys) {
if (!location.getNamespace().equals(AppEng.MOD_ID)) {
continue;
}
IBakedModel orgModel = modelRegistry.get(location);
BakedModel orgModel = modelRegistry.get(location);
// Don't customize the missing model. This causes Forge to swallow exceptions
if (orgModel == missingModel) {
continue;
}
BiFunction<Identifier, IBakedModel, IBakedModel> customizer = this.customizer.get(location.getPath());
BiFunction<Identifier, BakedModel, BakedModel> customizer = this.customizer.get(location.getPath());
if (customizer != null) {
IBakedModel newModel = customizer.apply(location, orgModel);
BakedModel newModel = customizer.apply(location, orgModel);
if (newModel != orgModel) {
modelRegistry.put(location, newModel);
@@ -1,10 +1,9 @@
package appeng.bootstrap.components;
import java.util.function.Predicate;
import com.google.common.base.Preconditions;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.render.RenderLayer;
/**
* Sets the rendering type for a block.
@@ -13,25 +12,16 @@ public class RenderTypeComponent implements IClientSetupComponent {
private final Block block;
private final RenderType renderType;
private final RenderLayer renderType;
private final Predicate<RenderType> renderTypes;
public RenderTypeComponent(Block block, RenderType renderType, Predicate<RenderType> renderTypes) {
public RenderTypeComponent(Block block, RenderLayer renderType) {
this.block = block;
this.renderType = renderType;
this.renderTypes = renderTypes;
this.renderType = Preconditions.checkNotNull(renderType);
}
@Override
public void setup() {
if (renderType != null) {
RenderTypeLookup.setRenderLayer(block, renderType);
}
if (renderTypes != null) {
RenderTypeLookup.setRenderLayer(block, renderTypes);
}
BlockRenderLayerMap.INSTANCE.putBlock(block, renderType);
}
}
+15 -15
View File
@@ -23,7 +23,7 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerEntity;
@@ -67,7 +67,7 @@ public class ClientHelper extends ServerHelper {
@Override
public World getWorld() {
if (Platform.isClient()) {
return Minecraft.getInstance().world;
return MinecraftClient.getInstance().world;
} else {
return super.getWorld();
}
@@ -81,7 +81,7 @@ public class ClientHelper extends ServerHelper {
@Override
public List<? extends PlayerEntity> getPlayers() {
if (Platform.isClient()) {
return Collections.singletonList(Minecraft.getInstance().player);
return Collections.singletonList(MinecraftClient.getInstance().player);
} else {
return super.getPlayers();
}
@@ -113,7 +113,7 @@ public class ClientHelper extends ServerHelper {
@Override
public boolean shouldAddParticles(final Random r) {
switch (Minecraft.getInstance().gameSettings.particles) {
switch (MinecraftClient.getInstance().gameSettings.particles) {
default:
case ALL:
return true;
@@ -126,7 +126,7 @@ public class ClientHelper extends ServerHelper {
@Override
public HitResult getRTR() {
return Minecraft.getInstance().objectMouseOver;
return MinecraftClient.getInstance().objectMouseOver;
}
@Override
@@ -139,7 +139,7 @@ public class ClientHelper extends ServerHelper {
return super.getRenderMode();
}
final Minecraft mc = Minecraft.getInstance();
final MinecraftClient mc = MinecraftClient.getInstance();
final PlayerEntity player = mc.player;
return this.renderModeForPlayer(player);
@@ -147,7 +147,7 @@ public class ClientHelper extends ServerHelper {
@Override
public void triggerUpdates() {
final Minecraft mc = Minecraft.getInstance();
final MinecraftClient mc = MinecraftClient.getInstance();
if (mc.player == null || mc.world == null) {
return;
}
@@ -183,7 +183,7 @@ public class ClientHelper extends ServerHelper {
final double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
final double d2 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
Minecraft.getInstance().particles.addParticle(ParticleTypes.VIBRANT, x + d0, y + d1, z + d2, 0.0D, 0.0D,
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.VIBRANT, x + d0, y + d1, z + d2, 0.0D, 0.0D,
0.0D);
}
}
@@ -193,12 +193,12 @@ public class ClientHelper extends ServerHelper {
final float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
Minecraft.getInstance().particles.addParticle(EnergyParticleData.FOR_BLOCK, posX + x, posY + y, posZ + z,
MinecraftClient.getInstance().particles.addParticle(EnergyParticleData.FOR_BLOCK, posX + x, posY + y, posZ + z,
-x * 0.1, -y * 0.1, -z * 0.1);
}
private void spawnLightning(final World world, final double posX, final double posY, final double posZ) {
Minecraft.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, posX, posY + 0.3f, posZ, 0.0f, 0.0f,
MinecraftClient.getInstance().particles.addParticle(ParticleTypes.LIGHTNING, posX, posY + 0.3f, posZ, 0.0f, 0.0f,
0.0f);
}
@@ -206,7 +206,7 @@ public class ClientHelper extends ServerHelper {
final Vec3d second) {
final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f,
0.0f);
Minecraft.getInstance().particles.addEffect(fx);
MinecraftClient.getInstance().particles.addEffect(fx);
}
private void wheelEvent(final InputEvent.MouseScrollEvent me) {
@@ -214,11 +214,11 @@ public class ClientHelper extends ServerHelper {
return;
}
final Minecraft mc = Minecraft.getInstance();
final MinecraftClient mc = MinecraftClient.getInstance();
final PlayerEntity player = mc.player;
if (player.isCrouching()) {
final boolean mainHand = player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem;
if (player.isInSneakingPose()) {
final boolean mainHand = player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getStackInHand(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem;
if (mainHand || offHand) {
NetworkHandler.instance()
@@ -30,10 +30,10 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.gui.widget.Widget;
@@ -356,7 +356,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return;
}
if (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE)) {
if (InputMappings.isKeyDown(MinecraftClient.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_SPACE)) {
if (this.enableSpaceClicking()) {
IAEItemStack stack = null;
if (slot instanceof SlotME) {
@@ -25,7 +25,7 @@ import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.TerminalPart;
import appeng.tile.storage.ChestTileEntity;
import appeng.tile.storage.ChestBlockEntity;
/**
* Utility class for sub-screens of other containers that allow returning to the
@@ -47,7 +47,7 @@ final class AESubScreen {
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if (containerTarget instanceof ChestTileEntity) {
if (containerTarget instanceof ChestBlockEntity) {
// A chest is also a priority host, but the priority _interface_ can only be
// opened from the
// chest ui that doesn't actually show the contents of the inserted cell.
@@ -95,7 +95,7 @@ final class AESubScreen {
public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y, @Nullable String label) {
if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) {
if (label == null) {
label = previousContainerIcon.getDisplayName().getString();
label = previousContainerIcon.getName().getString();
}
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
TabButton button = new TabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label,
@@ -54,7 +54,7 @@ import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.abstraction.JEIFacade;
import appeng.parts.reporting.AbstractTerminalPart;
import appeng.tile.misc.SecurityStationTileEntity;
import appeng.tile.misc.SecurityStationBlockEntity;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
@@ -110,7 +110,7 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
this.viewCell = te instanceof IViewCellStorage;
if (te instanceof SecurityStationTileEntity) {
if (te instanceof SecurityStationBlockEntity) {
this.myName = GuiText.Security;
} else if (te instanceof WirelessTerminalGuiObject) {
this.myName = GuiText.WirelessTerminal;
@@ -29,7 +29,7 @@ import appeng.client.gui.widgets.ProgressBar;
import appeng.client.gui.widgets.ProgressBar.Direction;
import appeng.container.implementations.VibrationChamberContainer;
import appeng.core.localization.GuiText;
import appeng.tile.misc.VibrationChamberTileEntity;
import appeng.tile.misc.VibrationChamberBlockEntity;
public class VibrationChamberScreen extends AEBaseScreen<VibrationChamberContainer> {
@@ -54,8 +54,8 @@ public class VibrationChamberScreen extends AEBaseScreen<VibrationChamberContain
this.font.drawString(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
this.pb.setFullMsg(VibrationChamberTileEntity.POWER_PER_TICK * this.container.getCurrentProgress()
/ VibrationChamberTileEntity.DILATION_SCALING + " AE/t");
this.pb.setFullMsg(VibrationChamberBlockEntity.POWER_PER_TICK * this.container.getCurrentProgress()
/ VibrationChamberBlockEntity.DILATION_SCALING + " AE/t");
if (this.container.getRemainingBurnTime() > 0) {
final int i1 = this.container.getRemainingBurnTime() * 12 / 100;
@@ -1,7 +1,7 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@@ -28,7 +28,7 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
public void slotClicked(final ItemStack clickStack, final int mouseButton) {
}
public abstract void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks);
public abstract void drawContent(final MinecraftClient mc, final int mouseX, final int mouseY, final float partialTicks);
public void drawBackground(int guileft, int guitop, int currentZIndex) {
}
@@ -20,7 +20,7 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.Identifier;
@@ -44,7 +44,7 @@ public abstract class IconButton extends Button implements ITooltip {
@Override
public void renderButton(final int mouseX, final int mouseY, float partial) {
Minecraft minecraft = Minecraft.getInstance();
MinecraftClient minecraft = MinecraftClient.getInstance();
if (this.visible) {
final int iconIndex = this.getIconIndex();
@@ -18,7 +18,7 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.Identifier;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -55,7 +55,7 @@ public class ProgressBar extends Widget implements ITooltip {
@Override
public void renderButton(final int par2, final int par3, final float partial) {
if (this.visible) {
Minecraft.getInstance().getTextureManager().bindTexture(this.texture);
MinecraftClient.getInstance().getTextureManager().bindTexture(this.texture);
final int max = this.source.getMaxProgress();
final int current = this.source.getCurrentProgress();
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.text.Text;
@@ -229,7 +229,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
}
private void triggerPress() {
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown();
boolean backwards = MinecraftClient.getInstance().mouseHelper.isRightDown();
onPress.handle(this, backwards);
}
@@ -20,7 +20,7 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
@@ -61,7 +61,7 @@ public class TabButton extends Button implements ITooltip {
@Override
public void renderButton(final int x, final int y, float partial) {
final Minecraft minecraft = Minecraft.getInstance();
final MinecraftClient minecraft = MinecraftClient.getInstance();
if (this.visible) {
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
@@ -22,7 +22,7 @@ import java.util.regex.Pattern;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.Identifier;
@@ -59,7 +59,7 @@ public class ToggleButton extends Button implements ITooltip {
final int iconIndex = this.getIconIndex();
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
Minecraft.getInstance().textureManager.bindTexture(TEXTURE_STATES);
MinecraftClient.getInstance().textureManager.bindTexture(TEXTURE_STATES);
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
@@ -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;
@@ -32,7 +32,7 @@ import appeng.api.util.AEColor;
/**
* Automatically exposes the color of a colorable tile using tint indices 0-2
*/
public class ColorableTileBlockColor implements IBlockColor {
public class ColorableTileBlockColor implements BlockColorProvider {
public static final ColorableTileBlockColor INSTANCE = new ColorableTileBlockColor();
@@ -41,7 +41,7 @@ public class ColorableTileBlockColor implements IBlockColor {
AEColor color = AEColor.TRANSPARENT; // Default to a neutral color
if (worldIn != null && pos != null) {
BlockEntity te = worldIn.getTileEntity(pos);
BlockEntity te = worldIn.getBlockEntity(pos);
if (te instanceof IColorableTile) {
color = ((IColorableTile) te).getColor();
}
@@ -23,20 +23,20 @@ import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.util.math.MatrixStack;
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.ItemCameraTransforms;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.Direction;
public abstract class DelegateBakedModel implements IBakedModel {
private final IBakedModel baseModel;
public abstract class DelegateBakedModel implements BakedModel {
private final BakedModel baseModel;
protected DelegateBakedModel(IBakedModel base) {
protected DelegateBakedModel(BakedModel base) {
this.baseModel = base;
}
@@ -57,7 +57,7 @@ public abstract class DelegateBakedModel implements IBakedModel {
}
@Override
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
public BakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
baseModel.handlePerspective(cameraTransformType, mat);
return this;
}
@@ -87,7 +87,7 @@ public abstract class DelegateBakedModel implements IBakedModel {
return this.baseModel.isBuiltInRenderer();
}
public IBakedModel getBaseModel() {
public BakedModel getBaseModel() {
return this.baseModel;
}
}
@@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.Direction;
@@ -37,7 +37,7 @@ import net.minecraft.util.math.Direction;
* @version rv6 - 2018-01-22
* @since rv6 2018-01-22
*/
public class DummyFluidBakedModel implements IBakedModel {
public class DummyFluidBakedModel implements BakedModel {
private final ImmutableList<BakedQuad> quads;
public DummyFluidBakedModel(ImmutableList<BakedQuad> quads) {
@@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.TransformationMatrix;
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;
@@ -55,8 +55,8 @@ import appeng.fluids.items.FluidDummyItem;
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
private final Function<Material, TextureAtlasSprite> bakedTextureGetter;
public DummyFluidDispatcherBakedModel(IBakedModel baseModel,
Function<Material, TextureAtlasSprite> bakedTextureGetter) {
public DummyFluidDispatcherBakedModel(BakedModel baseModel,
Function<Material, TextureAtlasSprite> bakedTextureGetter) {
super(baseModel);
this.bakedTextureGetter = bakedTextureGetter;
}
@@ -86,8 +86,8 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
public ItemOverrideList getOverrides() {
return new ItemOverrideList() {
@Override
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) {
public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) {
if (!(stack.getItem() instanceof FluidDummyItem)) {
return originalModel;
}
@@ -25,12 +25,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;
@@ -48,10 +48,10 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
"item/dummy_fluid_item_base");
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
return new DummyFluidDispatcherBakedModel(bakedBaseModel, spriteGetter);
}
@@ -26,8 +26,8 @@ import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
@@ -48,7 +48,7 @@ public class FacadeBakedItemModel extends DelegateBakedModel {
private final FacadeBuilder facadeBuilder;
private List<BakedQuad> quads = null;
protected FacadeBakedItemModel(IBakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) {
protected FacadeBakedItemModel(BakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) {
super(base);
this.textureStack = textureStack;
this.facadeBuilder = facadeBuilder;
@@ -20,7 +20,7 @@ package appeng.client.render;
import java.util.Objects;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
@@ -41,7 +41,7 @@ public class FacadeDispatcherBakedModel extends DelegateBakedModel {
private final FacadeBuilder facadeBuilder;
private final Int2ObjectMap<FacadeBakedItemModel> cache = new Int2ObjectArrayMap<>();
public FacadeDispatcherBakedModel(IBakedModel baseModel, FacadeBuilder facadeBuilder) {
public FacadeDispatcherBakedModel(BakedModel baseModel, FacadeBuilder facadeBuilder) {
super(baseModel);
this.facadeBuilder = facadeBuilder;
}
@@ -50,8 +50,8 @@ public class FacadeDispatcherBakedModel extends DelegateBakedModel {
public ItemOverrideList getOverrides() {
return new ItemOverrideList() {
@Override
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) {
public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) {
if (!(stack.getItem() instanceof FacadeItem)) {
return originalModel;
}
@@ -43,10 +43,10 @@ public class FacadeItemModel implements IModelGeometry<FacadeItemModel> {
private static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/facade_base");
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) {
BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
FacadeBuilder facadeBuilder = new FacadeBuilder();
return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder);
@@ -25,7 +25,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Quaternion;
import net.minecraft.client.renderer.RenderHelper;
@@ -57,7 +57,7 @@ public class SpatialSkyRender implements SkyRenderHandler {
new Quaternion(0.0F, 0.0F, 90.0F, true), new Quaternion(0.0F, 0.0F, -90.0F, true), };
@Override
public void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc) {
public void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, MinecraftClient mc) {
final long now = System.currentTimeMillis();
if (now - this.cycle > 2000) {
this.cycle = now;
@@ -21,7 +21,7 @@ package appeng.client.render;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
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;
@@ -30,7 +30,7 @@ import appeng.api.util.AEColor;
/**
* Returns the shades of a single AE color for tint indices 0, 1, and 2.
*/
public class StaticBlockColor implements IBlockColor {
public class StaticBlockColor implements BlockColorProvider {
private final AEColor color;

Some files were not shown because too many files have changed in this diff Show More