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
+4
View File
@@ -76,6 +76,10 @@ allprojects {
} }
} }
dependencies {
compile project(":api")
}
subprojects { subprojects {
apply plugin: 'kotlin-platform-jvm' apply plugin: 'kotlin-platform-jvm'
+19 -43
View File
@@ -20,7 +20,7 @@ package appeng.block;
import javax.annotation.Nullable; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
@@ -28,18 +28,17 @@ import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.World; 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.IOrientable;
import appeng.api.util.IOrientableBlock; import appeng.api.util.IOrientableBlock;
@@ -48,8 +47,6 @@ import appeng.util.Platform;
public abstract class AEBaseBlock extends Block { public abstract class AEBaseBlock extends Block {
private boolean isOpaque = true;
private boolean isFullSize = true;
private boolean isInventory = false; private boolean isInventory = false;
protected AEBaseBlock(final Settings props) { 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 * Utility function to create block properties with some sensible defaults for
* AE blocks. * AE blocks.
*/ */
public static Settings defaultProps(Material material) { public static FabricBlockSettings defaultProps(Material material) {
return defaultProps(material, material.getColor()); 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 * Utility function to create block properties with some sensible defaults for
* AE blocks. * AE blocks.
*/ */
public static Settings defaultProps(Material material, MaterialColor color) { public static FabricBlockSettings defaultProps(Material material, MaterialColor color) {
return Settings.create(material, color) return FabricBlockSettings.of(material, color)
// These values previousls were encoded in AEBaseBlock // These values previousls were encoded in AEBaseBlock
.hardnessAndResistance(2.2f, 11.f).harvestTool(ToolType.PICKAXE).harvestLevel(0) .strength(2.2f, 11.f)
.sound(getDefaultSoundByMaterial(material)); .breakByTool(FabricToolTags.PICKAXES, 0)
.sounds(getDefaultSoundByMaterial(material));
} }
private static BlockSoundGroup getDefaultSoundByMaterial(Material mat) { private static BlockSoundGroup getDefaultSoundByMaterial(Material mat) {
if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) { if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) {
return BlockSoundGroup.GLASS; return BlockSoundGroup.GLASS;
} else if (mat == Material.ROCK) { } else if (mat == Material.STONE) {
return BlockSoundGroup.STONE; return BlockSoundGroup.STONE;
} else if (mat == Material.WOOD) { } else if (mat == Material.WOOD) {
return BlockSoundGroup.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 @Override
public boolean hasComparatorOutput(BlockState state) { public boolean hasComparatorOutput(BlockState state) {
return this.isInventory(); 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, 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; return ActionResult.PASS;
} }
@@ -151,13 +144,13 @@ public abstract class AEBaseBlock extends Block {
return dir; return dir;
} }
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); final int west_x = forward.getOffsetY() * up.getOffsetZ() - forward.getOffsetZ() * up.getOffsetY();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); final int west_y = forward.getOffsetZ() * up.getOffsetX() - forward.getOffsetX() * up.getOffsetZ();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); final int west_z = forward.getOffsetX() * up.getOffsetY() - forward.getOffsetY() * up.getOffsetX();
Direction west = null; Direction west = null;
for (final Direction dx : Direction.values()) { 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; west = dx;
} }
} }
@@ -192,7 +185,8 @@ public abstract class AEBaseBlock extends Block {
@Override @Override
public String toString() { 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 + "]"; return this.getClass().getSimpleName() + "[" + regName + "]";
} }
@@ -221,24 +215,6 @@ public abstract class AEBaseBlock extends Block {
return true; 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() { protected boolean isInventory() {
return this.isInventory; return this.isInventory;
} }
+19 -25
View File
@@ -22,11 +22,10 @@ import java.util.List;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.minecraft.block.Block; 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.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -40,33 +39,28 @@ import appeng.block.misc.LightDetectorBlock;
import appeng.block.misc.SkyCompassBlock; import appeng.block.misc.SkyCompassBlock;
import appeng.block.networking.WirelessBlock; import appeng.block.networking.WirelessBlock;
import appeng.me.helpers.IGridProxyable; import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
public class AEBaseBlockItem extends BlockItem { public class AEBaseBlockItem extends BlockItem {
private final AEBaseBlock blockType; private final AEBaseBlock blockType;
public AEBaseBlockItem(final Block id, Item.Properties props) { public AEBaseBlockItem(final Block id, Settings props) {
super(id, props); super(id, props);
this.blockType = (AEBaseBlock) id; this.blockType = (AEBaseBlock) id;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public final void addInformation(final ItemStack itemStack, final World world, final List<Text> toolTip, public final void appendTooltip(final ItemStack itemStack, final World world, final List<Text> toolTip,
final ITooltipFlag advancedTooltips) { final TooltipContext advancedTooltips) {
this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips); this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips);
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void addCheckedInformation(final ItemStack itemStack, final World world, final List<Text> toolTip, public void addCheckedInformation(final ItemStack itemStack, final World world, final List<Text> toolTip,
final ITooltipFlag advancedTooltips) { final TooltipContext advancedTooltips) {
this.blockType.addInformation(itemStack, world, toolTip, advancedTooltips); this.blockType.buildTooltip(itemStack, world, toolTip, advancedTooltips);
}
@Override
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
return false;
} }
@Override @Override
@@ -75,12 +69,12 @@ public class AEBaseBlockItem extends BlockItem {
} }
@Override @Override
public ActionResult tryPlace(BlockItemUseContext context) { public ActionResult place(ItemPlacementContext context) {
Direction up = null; Direction up = null;
Direction forward = null; Direction forward = null;
Direction side = context.getFace(); Direction side = context.getSide();
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
if (this.blockType instanceof AEBaseTileBlock) { if (this.blockType instanceof AEBaseTileBlock) {
@@ -100,13 +94,13 @@ public class AEBaseBlockItem extends BlockItem {
} }
} else { } else {
up = Direction.UP; up = Direction.UP;
forward = context.getPlacementHorizontalFacing().getOpposite(); forward = context.getPlayerFacing().getOpposite();
if (player != null) { if (player != null) {
if (player.rotationPitch > 65) { if (player.pitch > 65) {
up = forward.getOpposite(); up = forward.getOpposite();
forward = Direction.UP; forward = Direction.UP;
} else if (player.rotationPitch < -65) { } else if (player.pitch < -65) {
up = forward.getOpposite(); up = forward.getOpposite();
forward = Direction.DOWN; forward = Direction.DOWN;
} }
@@ -116,26 +110,26 @@ public class AEBaseBlockItem extends BlockItem {
IOrientable ori = null; IOrientable ori = null;
if (this.blockType instanceof IOrientableBlock) { 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; up = side;
forward = Direction.SOUTH; forward = Direction.SOUTH;
if (up.getYOffset() == 0) { if (up.getOffsetY() == 0) {
forward = Direction.UP; 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; return ActionResult.FAIL;
} }
ActionResult result = super.tryPlace(context); ActionResult result = super.place(context);
if (result != ActionResult.SUCCESS) { if (result != ActionResult.SUCCESS) {
return result; return result;
} }
if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof LightDetectorBlock)) { if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof LightDetectorBlock)) {
final AEBaseTileEntity tile = ((AEBaseTileBlock<?>) this.blockType).getTileEntity(context.getWorld(), final AEBaseBlockEntity tile = ((AEBaseTileBlock<?>) this.blockType).getBlockEntity(context.getWorld(),
context.getPos()); context.getBlockPos());
ori = tile; ori = tile;
if (tile == null) { if (tile == null) {
@@ -18,45 +18,50 @@
package appeng.block; 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.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits; import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.AppEng;
import appeng.core.localization.GuiText; 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 class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage {
public AEBaseBlockItemChargeable(Block id, Properties props) { public AEBaseBlockItemChargeable(Block id, Settings props) {
super(id, props); super(id, props);
addPropertyOverride(new Identifier("appliedenergistics2:fill_level"), (is, world, entity) -> { FabricModelPredicateProviderRegistry.register(
double curPower = getAECurrentPower(is); this,
double maxPower = getAEMaxPower(is); 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 @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void addCheckedInformation(final ItemStack stack, final World world, final List<Text> lines, public void addCheckedInformation(final ItemStack stack, final World world, final List<Text> lines,
final ITooltipFlag advancedTooltips) { final TooltipContext advancedTooltips) {
double internalCurrentPower = 0; double internalCurrentPower = 0;
final double internalMaxPower = this.getMaxEnergyCapacity(); final double internalMaxPower = this.getMaxEnergyCapacity();
@@ -69,9 +74,10 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
final double percent = internalCurrentPower / internalMaxPower; final double percent = internalCurrentPower / internalMaxPower;
lines.add(GuiText.StoredEnergy.textComponent() lines.add(GuiText.StoredEnergy.textComponent()
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower)) .copy()
.appendSibling(new TranslatableText(PowerUnits.AE.unlocalizedName)) .append(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
.appendText(" - " + MessageFormat.format("{0,number,#.##%}", percent))); .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.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DyeColor; import net.minecraft.text.LiteralText;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ActionResult; 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.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.text.Text; 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.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages; import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.util.AEColor;
import appeng.api.util.IOrientable; import appeng.api.util.IOrientable;
import appeng.block.networking.CableBusBlock; import appeng.block.networking.CableBusBlock;
import appeng.tile.AEBaseInvTileEntity; import appeng.tile.AEBaseInvBlockEntity;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.tile.networking.CableBusTileEntity; import appeng.tile.networking.CableBusBlockEntity;
import appeng.tile.storage.SkyChestTileEntity; import appeng.tile.storage.SkyChestBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.SettingsFrom; 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 @Nonnull
private Class<T> tileEntityClass; private Class<T> blockEntityClass;
@Nonnull @Nonnull
private Supplier<T> tileEntityFactory; private Supplier<T> tileEntityFactory;
@@ -73,61 +70,45 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
// TODO : Was this change needed? // TODO : Was this change needed?
public void setTileEntity(final Class<T> tileEntityClass, Supplier<T> factory) { public void setTileEntity(final Class<T> tileEntityClass, Supplier<T> factory) {
this.tileEntityClass = tileEntityClass; this.blockEntityClass = tileEntityClass;
this.tileEntityFactory = factory; this.tileEntityFactory = factory;
this.setInventory(AEBaseInvTileEntity.class.isAssignableFrom(tileEntityClass)); this.setInventory(AEBaseInvBlockEntity.class.isAssignableFrom(tileEntityClass));
} }
@Override public Class<T> getBlockEntityClass() {
public boolean hasTileEntity(BlockState state) { return this.blockEntityClass;
return this.hasBlockTileEntity();
}
private boolean hasBlockTileEntity() {
return true;
}
public Class<T> getTileEntityClass() {
return this.tileEntityClass;
} }
@Nullable @Nullable
public T getTileEntity(final BlockView w, final int x, final int y, final int z) { public T getBlockEntity(final BlockView w, final int x, final int y, final int z) {
return this.getTileEntity(w, new BlockPos(x, y, z)); return this.getBlockEntity(w, new BlockPos(x, y, z));
} }
@Nullable @Nullable
public T getTileEntity(final BlockView w, final BlockPos pos) { public T getBlockEntity(final BlockView w, final BlockPos pos) {
if (!this.hasBlockTileEntity()) {
return null;
}
final BlockEntity te = w.getTileEntity(pos); final BlockEntity te = w.getBlockEntity(pos);
// FIXME: This gets called as part of building the block state cache // FIXME: This gets called as part of building the block state cache
if (this.tileEntityClass != null && this.tileEntityClass.isInstance(te)) { if (this.blockEntityClass != null && this.blockEntityClass.isInstance(te)) {
return this.tileEntityClass.cast(te); return this.blockEntityClass.cast(te);
} }
return null; return null;
} }
@Nullable
@Override @Override
public final BlockEntity createTileEntity(BlockState state, BlockView world) { public BlockEntity createBlockEntity(BlockView world) {
return this.tileEntityFactory.get(); return this.tileEntityFactory.get();
} }
@Override @Override
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) { public void onStateReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
super.dropXpOnBlockBreak(worldIn, pos, amount);
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
if (newState.getBlock() == state.getBlock()) { if (newState.getBlock() == state.getBlock()) {
return; // Just a block state change return; // Just a block state change
} }
final AEBaseTileEntity te = this.getTileEntity(w, pos); final AEBaseBlockEntity te = this.getBlockEntity(w, pos);
if (te != null) { if (te != null) {
final ArrayList<ItemStack> drops = new ArrayList<>(); final ArrayList<ItemStack> drops = new ArrayList<>();
if (te.dropItems()) { 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 will remove the TE, as it is not an instance of BlockContainer
super.onReplaced(state, w, pos, newState, isMoving); super.onStateReplaced(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);
} }
@Override @Override
public int getComparatorOutput(BlockState state, final World w, final BlockPos pos) { public int getComparatorOutput(BlockState state, final World w, final BlockPos pos) {
final BlockEntity te = this.getTileEntity(w, pos); final BlockEntity te = this.getBlockEntity(w, pos);
if (te instanceof AEBaseInvTileEntity) { if (te instanceof AEBaseInvBlockEntity) {
AEBaseInvTileEntity invTile = (AEBaseInvTileEntity) te; AEBaseInvBlockEntity invTile = (AEBaseInvBlockEntity) te;
if (invTile.getInternalInventory().getSlots() > 0) { if (invTile.getInternalInventory().getSlotCount() > 0) {
return ItemHandlerHelper.calcRedstoneFromInventory(invTile.getInternalInventory()); return getRedstoneFromFixedItemInv(invTile.getInternalInventory());
} }
} }
return 0; return 0;
} }
@Override /**
public boolean eventReceived(final BlockState state, final World worldIn, final BlockPos pos, final int eventID, * Calculate redstone output level.
final int eventParam) { * 0 if completely empty, 1 if _any_ item is present, up to 15 if all slots are full.
super.eventReceived(state, worldIn, pos, eventID, eventParam); */
final BlockEntity tileentity = worldIn.getTileEntity(pos); private int getRedstoneFromFixedItemInv(FixedItemInv inv) {
return tileentity != null ? tileentity.receiveClientEvent(eventID, eventParam) : false; 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 @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) { final ItemStack is) {
// Inherit the item stack's display name, but only if it's a user defined string // Inherit the item stack's display name, but only if it's a user defined string
// rather // rather
// than a translation component, since our custom naming cannot handle // than a translation component, since our custom naming cannot handle
// untranslated // untranslated
// I18N strings and we would translate it using the server's locale :-( // I18N strings and we would translate it using the server's locale :-(
AEBaseTileEntity te = this.getTileEntity(w, pos); AEBaseBlockEntity te = this.getBlockEntity(w, pos);
if (te != null && is.hasDisplayName()) { if (te != null && is.hasCustomName()) {
Text displayName = is.getDisplayName(); Text displayName = is.getName();
if (displayName instanceof StringTextComponent) { if (displayName instanceof LiteralText) {
te.setName(((StringTextComponent) displayName).getText()); te.setName(((LiteralText) displayName).getRawString());
} }
} }
} }
@Override @Override
public ActionResult onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player,
Hand hand, BlockRayTraceResult hit) { Hand hand, BlockHitResult hit) {
ItemStack heldItem; ItemStack heldItem;
if (player != null && !player.getHeldItem(hand).isEmpty()) { if (player != null && !player.getStackInHand(hand).isEmpty()) {
heldItem = player.getHeldItem(hand); 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 BlockState blockState = world.getBlockState(pos);
final Block block = blockState.getBlock(); final Block block = blockState.getBlock();
final AEBaseTileEntity tile = this.getTileEntity(world, pos); final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile == null) { if (tile == null) {
return ActionResult.FAIL; return ActionResult.FAIL;
} }
if (tile instanceof CableBusTileEntity || tile instanceof SkyChestTileEntity) { if (tile instanceof CableBusBlockEntity || tile instanceof SkyChestBlockEntity) {
return ActionResult.FAIL; 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); final List<ItemStack> itemsToDrop = Lists.newArrayList(itemDropCandidates);
Platform.spawnDrops(world, pos, itemsToDrop); Platform.spawnDrops(world, pos, itemsToDrop);
world.removeBlock(pos, false);
} }
return ActionResult.FAIL; return ActionResult.FAIL;
@@ -245,7 +234,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) { if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) {
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem(); final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
final AEBaseTileEntity tileEntity = this.getTileEntity(world, pos); final AEBaseBlockEntity tileEntity = this.getBlockEntity(world, pos);
if (tileEntity == null) { if (tileEntity == null) {
return ActionResult.FAIL; return ActionResult.FAIL;
@@ -253,7 +242,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
final String name = this.getTranslationKey(); final String name = this.getTranslationKey();
if (player.isCrouching()) { if (player.isInSneakingPose()) {
final CompoundTag data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD); final CompoundTag data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD);
if (data != null) { if (data != null) {
memoryCard.setMemoryCardContents(heldItem, name, data); 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 @Override
public IOrientable getOrientable(final BlockView w, final BlockPos pos) { 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 * returned unchanged, this is also the case if the given block state does not
* belong to this block. * belong to this block.
*/ */
public final BlockState getTileEntityBlockState(BlockState current, BlockEntity te) { public final BlockState getBlockEntityBlockState(BlockState current, BlockEntity te) {
if (current.getBlock() != this || !tileEntityClass.isInstance(te)) { if (current.getBlock() != this || !blockEntityClass.isInstance(te)) {
return current; 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.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.CraftingCPUContainer; 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 FORMED = BooleanProperty.create("formed");
public static final BooleanProperty POWERED = BooleanProperty.create("powered"); public static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -57,33 +57,33 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
@Override @Override
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn, public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
final BlockPos fromPos, boolean isMoving) { final BlockPos fromPos, boolean isMoving) {
final CraftingTileEntity cp = this.getTileEntity(worldIn, pos); final CraftingBlockEntity cp = this.getBlockEntity(worldIn, pos);
if (cp != null) { if (cp != null) {
cp.updateMultiBlock(); cp.updateMultiBlock();
} }
} }
@Override @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()) { if (newState.getBlock() == state.getBlock()) {
return; // Just a block state change return; // Just a block state change
} }
final CraftingTileEntity cp = this.getTileEntity(w, pos); final CraftingBlockEntity cp = this.getBlockEntity(w, pos);
if (cp != null) { if (cp != null) {
cp.breakCluster(); cp.breakCluster();
} }
super.onReplaced(state, w, pos, newState, isMoving); super.onStateReplaced(state, w, pos, newState, isMoving);
} }
@Override @Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
BlockRayTraceResult hit) { BlockHitResult hit) {
final CraftingTileEntity tg = this.getTileEntity(w, pos); final CraftingBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive()) { if (tg != null && !p.isInSneakingPose() && tg.isFormed() && tg.isActive()) {
if (!w.isRemote()) { if (!w.isClient()) {
ContainerOpener.openContainer(CraftingCPUContainer.TYPE, p, ContainerOpener.openContainer(CraftingCPUContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace())); ContainerLocator.forTileEntitySide(tg, hit.getFace()));
} }
@@ -91,7 +91,7 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
return super.onBlockActivated(state, w, pos, p, hand, hit); return super.onUse(state, w, pos, p, hand, hit);
} }
public enum CraftingUnitType { public enum CraftingUnitType {
@@ -18,10 +18,10 @@
package appeng.block.crafting; package appeng.block.crafting;
import appeng.tile.crafting.CraftingMonitorTileEntity; import appeng.tile.crafting.CraftingMonitorBlockEntity;
public class CraftingMonitorBlock extends AbstractCraftingUnitBlock<CraftingMonitorTileEntity> { public class CraftingMonitorBlock extends AbstractCraftingUnitBlock<CraftingMonitorBlockEntity> {
public CraftingMonitorBlock(Properties props) { public CraftingMonitorBlock(Settings props) {
super(props, CraftingUnitType.MONITOR); super(props, CraftingUnitType.MONITOR);
} }
} }
@@ -18,11 +18,11 @@
package appeng.block.crafting; 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); super(props, type);
} }
@@ -28,7 +28,7 @@ import appeng.core.AEConfig;
public class CraftingStorageItem extends AEBaseBlockItem { public class CraftingStorageItem extends AEBaseBlockItem {
public CraftingStorageItem(Block id, Properties props) { public CraftingStorageItem(Block id, Settings props) {
super(id, props); super(id, props);
} }
@@ -18,11 +18,11 @@
package appeng.block.crafting; 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); super(props, type);
} }
@@ -25,17 +25,17 @@ import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.MolecularAssemblerContainer; 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"); public static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -51,23 +51,23 @@ public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerT
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, MolecularAssemblerTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, MolecularAssemblerBlockEntity te) {
return currentState.with(POWERED, te.isPowered()); return currentState.with(POWERED, te.isPowered());
} }
@Override @Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
BlockRayTraceResult hit) { BlockHitResult hit) {
final MolecularAssemblerTileEntity tg = this.getTileEntity(w, pos); final MolecularAssemblerBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !p.isCrouching()) { if (tg != null && !p.isInSneakingPose()) {
if (!tg.isRemote()) { if (!tg.isClient()) {
ContainerOpener.openContainer(MolecularAssemblerContainer.TYPE, p, ContainerOpener.openContainer(MolecularAssemblerContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace())); ContainerLocator.forTileEntitySide(tg, hit.getFace()));
} }
return ActionResult.SUCCESS; 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.Hand;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos; 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.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -45,24 +45,24 @@ import net.minecraftforge.common.util.FakePlayer;
import appeng.api.implementations.tiles.ICrankable; import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.core.stats.AeStats; import appeng.core.stats.AeStats;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.tile.grindstone.CrankTileEntity; 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); super(props);
} }
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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) { if (player instanceof FakePlayer || player == null) {
this.dropCrank(w, pos); this.dropCrank(w, pos);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
final CrankTileEntity tile = this.getTileEntity(w, pos); final CrankBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) { if (tile != null) {
if (tile.power()) { if (tile.power()) {
AeStats.TurnedCranks.addToPlayer(player, 1); AeStats.TurnedCranks.addToPlayer(player, 1);
@@ -74,14 +74,14 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
} }
private void dropCrank(final World world, final BlockPos pos) { private void dropCrank(final World world, final BlockPos pos) {
world.destroyBlock(pos, true); world.breakBlock(pos, true);
world.notifyBlockUpdate(pos, this.getDefaultState(), world.getBlockState(pos), 3); world.updateListeners(pos, this.getDefaultState(), world.getBlockState(pos), 3);
} }
@Override @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 LivingEntity placer, final ItemStack stack) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos); final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) { if (tile != null) {
final Direction mnt = this.findCrankable(world, pos); final Direction mnt = this.findCrankable(world, pos);
Direction forward = Direction.UP; Direction forward = Direction.UP;
@@ -96,8 +96,8 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
@Override @Override
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) { public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) {
final BlockEntity te = w.getTileEntity(pos); final BlockEntity te = w.getBlockEntity(pos);
return !(te instanceof CrankTileEntity) || this.isCrankable(w, pos, up.getOpposite()); return !(te instanceof CrankBlockEntity) || this.isCrankable(w, pos, up.getOpposite());
} }
private Direction findCrankable(final BlockView world, final BlockPos pos) { 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) { private boolean isCrankable(final BlockView world, final BlockPos pos, final Direction offset) {
final BlockPos o = pos.offset(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()); return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite());
} }
@@ -124,7 +124,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos); final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) { if (tile != null) {
if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) { if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) {
this.dropCrank(world, pos); this.dropCrank(world, pos);
@@ -140,7 +140,7 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
} }
private Direction getUp(BlockView world, BlockPos pos) { private Direction getUp(BlockView world, BlockPos pos) {
CrankTileEntity crank = getTileEntity(world, pos); CrankBlockEntity crank = getBlockEntity(world, pos);
return crank != null ? crank.getUp() : null; return crank != null ? crank.getUp() : null;
} }
@@ -152,9 +152,9 @@ public class CrankBlock extends AEBaseTileBlock<CrankTileEntity> {
return VoxelShapes.empty(); return VoxelShapes.empty();
} else { } else {
// FIXME: Cache per direction, and build it 'precise', not just from AABB // FIXME: Cache per direction, and build it 'precise', not just from AABB
final double xOff = -0.15 * up.getXOffset(); final double xOff = -0.15 * up.getOffsetX();
final double yOff = -0.15 * up.getYOffset(); final double yOff = -0.15 * up.getOffsetY();
final double zOff = -0.15 * up.getZOffset(); final double zOff = -0.15 * up.getOffsetZ();
return VoxelShapes.create( return VoxelShapes.create(
new Box(xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85)); 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 javax.annotation.Nullable;
import net.minecraft.entity.player.PlayerEntity; 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.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.GrinderContainer; 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); super(props);
} }
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
final GrinderTileEntity tg = this.getTileEntity(w, pos); final GrinderBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !p.isCrouching()) { if (tg != null && !p.isInSneakingPose()) {
if (p instanceof ServerPlayerEntity) { if (p instanceof ServerPlayerEntity) {
ContainerOpener.openContainer(GrinderContainer.TYPE, p, ContainerOpener.openContainer(GrinderContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace())); ContainerLocator.forTileEntitySide(tg, hit.getFace()));
@@ -26,16 +26,16 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.implementations.CellWorkbenchContainer; import appeng.container.implementations.CellWorkbenchContainer;
import appeng.tile.misc.CellWorkbenchTileEntity; import appeng.tile.misc.CellWorkbenchBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchTileEntity> { public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchBlockEntity> {
public CellWorkbenchBlock() { public CellWorkbenchBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -43,12 +43,12 @@ public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchTileEntity>
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final CellWorkbenchTileEntity tg = this.getTileEntity(w, pos); final CellWorkbenchBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
CellWorkbenchContainer.open(p, ContainerLocator.forTileEntity(tg)); 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.BlockState;
import net.minecraft.block.Material; 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.TransformationMatrix;
import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; 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.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -57,10 +57,10 @@ import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR; import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.tile.misc.ChargerTileEntity; import appeng.tile.misc.ChargerBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> { public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
public ChargerBlock() { public ChargerBlock() {
super(defaultProps(Material.IRON).notSolid()); super(defaultProps(Material.IRON).notSolid());
@@ -75,13 +75,13 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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.isCrouching()) { if (player.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
if (Platform.isServer()) { if (Platform.isServer()) {
final ChargerTileEntity tc = this.getTileEntity(w, pos); final ChargerBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null) { if (tc != null) {
tc.activate(player); tc.activate(player);
} }
@@ -101,7 +101,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
return; return;
} }
final ChargerTileEntity tile = this.getTileEntity(w, pos); final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) { if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged() if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) { .isSameAs(tile.getInternalInventory().getStackInSlot(0))) {
@@ -111,7 +111,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
for (int bolts = 0; bolts < 3; bolts++) { for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.proxy.shouldAddParticles(r)) { 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); 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 @Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { 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) { if (tile != null) {
final double twoPixels = 2.0 / 16.0; final double twoPixels = 2.0 / 16.0;
final Direction up = tile.getUp(); 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, final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels,
1.0 - twoPixels, 1.0 - twoPixels); 1.0 - twoPixels, 1.0 - twoPixels);
if (up.getXOffset() != 0) { if (up.getOffsetX() != 0) {
bb.minX = 0; bb.minX = 0;
bb.maxX = 1; bb.maxX = 1;
} }
if (up.getYOffset() != 0) { if (up.getOffsetY() != 0) {
bb.minY = 0; bb.minY = 0;
bb.maxY = 1; bb.maxY = 1;
} }
if (up.getZOffset() != 0) { if (up.getOffsetZ() != 0) {
bb.minZ = 0; bb.minZ = 0;
bb.maxZ = 1; bb.maxZ = 1;
} }
@@ -178,12 +178,12 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
} }
@Environment(EnvType.CLIENT) @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)); return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(ChargerBlock::getRenderedItem));
} }
@Environment(EnvType.CLIENT) @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); TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform); 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.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.CondenserContainer; import appeng.container.implementations.CondenserContainer;
import appeng.tile.misc.CondenserTileEntity; import appeng.tile.misc.CondenserBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class CondenserBlock extends AEBaseTileBlock<CondenserTileEntity> { public class CondenserBlock extends AEBaseTileBlock<CondenserBlockEntity> {
public CondenserBlock() { public CondenserBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -44,14 +44,14 @@ public class CondenserBlock extends AEBaseTileBlock<CondenserTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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.isCrouching()) { if (player.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
if (Platform.isServer()) { if (Platform.isServer()) {
final CondenserTileEntity tc = this.getTileEntity(w, pos); final CondenserBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isCrouching()) { if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(CondenserContainer.TYPE, player, ContainerOpener.openContainer(CondenserContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace())); ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
@@ -25,8 +25,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -34,11 +34,11 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.InscriberContainer; 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); super(props);
} }
@@ -50,11 +50,11 @@ public class InscriberBlock extends AEBaseTileBlock<InscriberTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (!p.isCrouching()) { if (!p.isInSneakingPose()) {
final InscriberTileEntity tg = this.getTileEntity(w, pos); final InscriberBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (!tg.isRemote()) { if (!tg.isClient()) {
ContainerOpener.openContainer(InscriberContainer.TYPE, p, ContainerOpener.openContainer(InscriberContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace())); ContainerLocator.forTileEntitySide(tg, hit.getFace()));
} }
@@ -7,13 +7,13 @@ import net.fabricmc.api.Environment;
import appeng.bootstrap.TileEntityRendering; import appeng.bootstrap.TileEntityRendering;
import appeng.bootstrap.TileEntityRenderingCustomizer; import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.InscriberTESR; 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) @Environment(EnvType.CLIENT)
@Override @Override
public void customize(TileEntityRendering<InscriberTileEntity> rendering) { public void customize(TileEntityRendering<InscriberBlockEntity> rendering) {
rendering.tileEntityRenderer(InscriberTESR::new); rendering.tileEntityRenderer(InscriberTESR::new);
} }
@@ -28,10 +28,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.IOrientable; import appeng.api.util.IOrientable;
@@ -39,10 +39,10 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.InterfaceContainer; import appeng.container.implementations.InterfaceContainer;
import appeng.tile.misc.InterfaceTileEntity; import appeng.tile.misc.InterfaceBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> { public class InterfaceBlock extends AEBaseTileBlock<InterfaceBlockEntity> {
private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional"); private static final BooleanProperty OMNIDIRECTIONAL = BooleanProperty.create("omnidirectional");
@@ -57,18 +57,18 @@ public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, InterfaceTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, InterfaceBlockEntity te) {
return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional()); return currentState.with(OMNIDIRECTIONAL, te.isOmniDirectional());
} }
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final InterfaceTileEntity tg = this.getTileEntity(w, pos); final InterfaceBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(InterfaceContainer.TYPE, p, ContainerOpener.openContainer(InterfaceContainer.TYPE, p,
@@ -86,8 +86,8 @@ public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
@Override @Override
protected void customRotateBlock(final IOrientable rotatable, final Direction axis) { protected void customRotateBlock(final IOrientable rotatable, final Direction axis) {
if (rotatable instanceof InterfaceTileEntity) { if (rotatable instanceof InterfaceBlockEntity) {
((InterfaceTileEntity) rotatable).setSide(axis); ((InterfaceBlockEntity) rotatable).setSide(axis);
} }
} }
} }
@@ -41,9 +41,9 @@ import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock; import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.helpers.MetaRotation; 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 // Used to alternate between two variants of the fixture on adjacent blocks
public static final BooleanProperty ODD = BooleanProperty.create("odd"); public static final BooleanProperty ODD = BooleanProperty.create("odd");
@@ -63,7 +63,7 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
@Override @Override
public int getWeakPower(final BlockState state, final BlockView w, final BlockPos pos, final Direction side) { 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 // FIXME: This is ... uhm... fishy
return ((World) w).getLight(pos) - 6; 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) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(state, world, pos, neighbor); super.onNeighborChange(state, world, pos, neighbor);
final LightDetectorTileEntity tld = this.getTileEntity(world, pos); final LightDetectorBlockEntity tld = this.getBlockEntity(world, pos);
if (tld != null) { if (tld != null) {
tld.updateLight(); tld.updateLight();
} }
@@ -104,9 +104,9 @@ public class LightDetectorBlock extends AEBaseTileBlock<LightDetectorTileEntity>
// called without a world // called without a world
final Direction up = this.getOrientable(w, pos).getUp(); final Direction up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getXOffset(); final double xOff = -0.3 * up.getOffsetX();
final double yOff = -0.3 * up.getYOffset(); final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getZOffset(); final double zOff = -0.3 * up.getOffsetZ();
return VoxelShapes return VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7)); .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) { private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos); final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true); w.breakBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); w.updateListeners(pos, prev, w.getBlockState(pos), 3);
} }
@Override @Override
@@ -27,9 +27,9 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
@@ -64,9 +64,9 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
SHAPES = new EnumMap<>(Direction.class); SHAPES = new EnumMap<>(Direction.class);
for (Direction facing : Direction.values()) { for (Direction facing : Direction.values()) {
final double xOff = -0.3 * facing.getXOffset(); final double xOff = -0.3 * facing.getOffsetX();
final double yOff = -0.3 * facing.getYOffset(); final double yOff = -0.3 * facing.getOffsetY();
final double zOff = -0.3 * facing.getZOffset(); final double zOff = -0.3 * facing.getOffsetZ();
VoxelShape shape = VoxelShapes VoxelShape shape = VoxelShapes
.create(new Box(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7)); .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); SHAPES.put(facing, shape);
@@ -80,8 +80,8 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
public static final BooleanProperty ODD = BooleanProperty.create("odd"); public static final BooleanProperty ODD = BooleanProperty.create("odd");
public QuartzFixtureBlock() { public QuartzFixtureBlock() {
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14) super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().strength(0).lightValue(14)
.sound(BlockSoundGroup.GLASS)); .sounds(BlockSoundGroup.GLASS));
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false)); 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 // For reference, see WallTorchBlock
@Override @Override
@Nullable @Nullable
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(ItemPlacementContext context) {
BlockState blockstate = super.getStateForPlacement(context); BlockState blockstate = super.getStateForPlacement(context);
BlockPos pos = context.getPos(); BlockPos pos = context.getBlockPos();
// Set the even/odd property // Set the even/odd property
boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0; 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 Direction up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getXOffset(); final double xOff = -0.3 * up.getOffsetX();
final double yOff = -0.3 * up.getYOffset(); final double yOff = -0.3 * up.getOffsetY();
final double zOff = -0.3 * up.getZOffset(); final double zOff = -0.3 * up.getOffsetZ();
for (int bolts = 0; bolts < 3; bolts++) { for (int bolts = 0; bolts < 3; bolts++) {
if (AppEng.proxy.shouldAddParticles(r)) { if (AppEng.proxy.shouldAddParticles(r)) {
w.addParticle(ParticleTypes.LIGHTNING, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), 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) { private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos); final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true); w.breakBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); w.updateListeners(pos, prev, w.getBlockState(pos), 3);
} }
@Override @Override
@@ -25,7 +25,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -38,21 +38,21 @@ import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ParticleTypes; import appeng.client.render.effects.ParticleTypes;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.tile.misc.QuartzGrowthAcceleratorTileEntity; import appeng.tile.misc.QuartzGrowthAcceleratorBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorTileEntity> public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAcceleratorBlockEntity>
implements IOrientableBlock { implements IOrientableBlock {
private static final BooleanProperty POWERED = BooleanProperty.create("powered"); private static final BooleanProperty POWERED = BooleanProperty.create("powered");
public QuartzGrowthAcceleratorBlock() { public QuartzGrowthAcceleratorBlock() {
super(defaultProps(Material.ROCK).sound(BlockSoundGroup.METAL)); super(defaultProps(Material.STONE).sounds(BlockSoundGroup.METAL));
this.setDefaultState(this.getDefaultState().with(POWERED, false)); this.setDefaultState(this.getDefaultState().with(POWERED, false));
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuartzGrowthAcceleratorTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuartzGrowthAcceleratorBlockEntity te) {
return currentState.with(POWERED, te.isPowered()); return currentState.with(POWERED, te.isPowered());
} }
@@ -69,7 +69,7 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
return; return;
} }
final QuartzGrowthAcceleratorTileEntity cga = this.getTileEntity(w, pos); final QuartzGrowthAcceleratorBlockEntity cga = this.getBlockEntity(w, pos);
if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) { if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) {
final double d0 = r.nextFloat() - 0.5F; final double d0 = r.nextFloat() - 0.5F;
@@ -83,9 +83,9 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
double ry = 0.5 + pos.getY(); double ry = 0.5 + pos.getY();
double rz = 0.5 + pos.getZ(); double rz = 0.5 + pos.getZ();
rx += up.getXOffset() * d0; rx += up.getOffsetX() * d0;
ry += up.getYOffset() * d0; ry += up.getOffsetY() * d0;
rz += up.getZOffset() * d0; rz += up.getOffsetZ() * d0;
final int x = pos.getX(); final int x = pos.getX();
final int y = pos.getY(); final int y = pos.getY();
@@ -99,25 +99,25 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
case 0: case 0:
dx = 0.6; dx = 0.6;
dz = d1; 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; break;
case 1: case 1:
dx = d1; dx = d1;
dz += 0.6; 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; break;
case 2: case 2:
dx = d1; dx = d1;
dz = -0.6; 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; break;
case 3: case 3:
dx = -0.6; dx = -0.6;
dz = d1; 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; break;
} }
@@ -126,15 +126,15 @@ public class QuartzGrowthAcceleratorBlock extends AEBaseTileBlock<QuartzGrowthAc
return; return;
} }
rx += dx * west.getXOffset(); rx += dx * west.getOffsetX();
ry += dx * west.getYOffset(); ry += dx * west.getOffsetY();
rz += dx * west.getZOffset(); rz += dx * west.getOffsetZ();
rx += dz * forward.getXOffset(); rx += dz * forward.getOffsetX();
ry += dz * forward.getYOffset(); ry += dz * forward.getOffsetY();
rz += dz * forward.getZOffset(); 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.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.SecurityStationContainer; 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"); private static final BooleanProperty POWERED = BooleanProperty.create("powered");
@@ -56,20 +56,20 @@ public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationTileEnt
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, SecurityStationTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, SecurityStationBlockEntity te) {
return currentState.with(POWERED, te.isActive()); return currentState.with(POWERED, te.isActive());
} }
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final SecurityStationTileEntity tg = this.getTileEntity(w, pos); final SecurityStationBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (w.isRemote()) { if (w.isClient()) {
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
@@ -19,7 +19,7 @@
package appeng.block.misc; package appeng.block.misc;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
@@ -34,7 +34,7 @@ public class SecurityStationRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout()); rendering.renderType(RenderLayer.getCutout());
rendering.blockColor(ColorableTileBlockColor.INSTANCE); rendering.blockColor(ColorableTileBlockColor.INSTANCE);
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT)); itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
} }
@@ -33,9 +33,9 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; 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) { public SkyCompassBlock(Settings props) {
super(props); super(props);
@@ -43,7 +43,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
@Override @Override
public boolean isValidOrientation(final WorldAccess w, final BlockPos pos, final Direction forward, final Direction up) { 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) { if (sc != null) {
return false; return false;
} }
@@ -59,7 +59,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final SkyCompassTileEntity sc = this.getTileEntity(world, pos); final SkyCompassBlockEntity sc = this.getBlockEntity(world, pos);
final Direction forward = sc.getForward(); final Direction forward = sc.getForward();
if (!this.canPlaceAt(world, pos, forward.getOpposite())) { if (!this.canPlaceAt(world, pos, forward.getOpposite())) {
this.dropTorch(world, pos); this.dropTorch(world, pos);
@@ -68,8 +68,8 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
private void dropTorch(final World w, final BlockPos pos) { private void dropTorch(final World w, final BlockPos pos) {
final BlockState prev = w.getBlockState(pos); final BlockState prev = w.getBlockState(pos);
w.destroyBlock(pos, true); w.breakBlock(pos, true);
w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3); w.updateListeners(pos, prev, w.getBlockState(pos), 3);
} }
@Override @Override
@@ -87,7 +87,7 @@ public class SkyCompassBlock extends AEBaseTileBlock<SkyCompassTileEntity> {
// TODO: This definitely needs to be memoized // TODO: This definitely needs to be memoized
final SkyCompassTileEntity tile = this.getTileEntity(w, pos); final SkyCompassBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) { if (tile != null) {
final Direction forward = tile.getForward(); final Direction forward = tile.getForward();
@@ -24,13 +24,13 @@ import net.fabricmc.api.Environment;
import appeng.bootstrap.TileEntityRendering; import appeng.bootstrap.TileEntityRendering;
import appeng.bootstrap.TileEntityRenderingCustomizer; import appeng.bootstrap.TileEntityRenderingCustomizer;
import appeng.client.render.tesr.SkyCompassTESR; 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 @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(TileEntityRendering<SkyCompassTileEntity> rendering) { public void customize(TileEntityRendering<SkyCompassBlockEntity> rendering) {
rendering.tileEntityRenderer(SkyCompassTESR::new); rendering.tileEntityRenderer(SkyCompassTESR::new);
} }
@@ -34,7 +34,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos; 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.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -68,7 +68,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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) { if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
this.startFuse(w, pos, player); this.startFuse(w, pos, player);
w.removeBlock(pos, false); 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) { 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, final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter); pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
w.addEntity(primedTinyTNTEntity); w.addEntity(primedTinyTNTEntity);
@@ -112,7 +112,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override @Override
public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) { 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; final AbstractArrowEntity entityarrow = (AbstractArrowEntity) entity;
if (entityarrow.isBurning()) { if (entityarrow.isBurning()) {
@@ -140,7 +140,7 @@ public class TinyTNTBlock extends AEBaseBlock {
@Override @Override
public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) { public void onExplosionDestroy(final World w, final BlockPos pos, final Explosion exp) {
super.onExplosionDestroy(w, pos, exp); super.onExplosionDestroy(w, pos, exp);
if (!w.isRemote) { if (!w.isClient) {
final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F, final TinyTNTPrimedEntity primedTinyTNTEntity = new TinyTNTPrimedEntity(w, pos.getX() + 0.5F,
pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy()); pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy());
primedTinyTNTEntity primedTinyTNTEntity
@@ -34,7 +34,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
@@ -42,22 +42,22 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.VibrationChamberContainer; import appeng.container.implementations.VibrationChamberContainer;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.tile.misc.VibrationChamberTileEntity; import appeng.tile.misc.VibrationChamberBlockEntity;
import appeng.util.Platform; 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 // Indicates that the vibration chamber is currently working
private static final BooleanProperty ACTIVE = BooleanProperty.create("active"); private static final BooleanProperty ACTIVE = BooleanProperty.create("active");
public VibrationChamberBlock() { public VibrationChamberBlock() {
super(defaultProps(Material.IRON).hardnessAndResistance(4.2F)); super(defaultProps(Material.IRON).strength(4.2F));
this.setDefaultState(this.getDefaultState().with(ACTIVE, false)); this.setDefaultState(this.getDefaultState().with(ACTIVE, false));
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, VibrationChamberTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, VibrationChamberBlockEntity te) {
return currentState.with(ACTIVE, te.isOn); return currentState.with(ACTIVE, te.isOn);
} }
@@ -69,14 +69,14 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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.isCrouching()) { if (player.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
if (Platform.isServer()) { if (Platform.isServer()) {
final VibrationChamberTileEntity tc = this.getTileEntity(w, pos); final VibrationChamberBlockEntity tc = this.getBlockEntity(w, pos);
if (tc != null && !player.isCrouching()) { if (tc != null && !player.isInSneakingPose()) {
ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player, ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace())); ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
@@ -92,9 +92,9 @@ public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChambe
return; return;
} }
final AEBaseTileEntity tile = this.getTileEntity(w, pos); final AEBaseBlockEntity tile = this.getBlockEntity(w, pos);
if (tile instanceof VibrationChamberTileEntity) { if (tile instanceof VibrationChamberBlockEntity) {
final VibrationChamberTileEntity tc = (VibrationChamberTileEntity) tile; final VibrationChamberBlockEntity tc = (VibrationChamberBlockEntity) tile;
if (tc.isOn) { if (tc.isOn) {
double f1 = pos.getX() + 0.5F; double f1 = pos.getX() + 0.5F;
double f2 = pos.getY() + 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 forward = tc.getForward();
final Direction up = tc.getUp(); final Direction up = tc.getUp();
final int west_x = forward.getYOffset() * up.getZOffset() - forward.getZOffset() * up.getYOffset(); final int west_x = forward.getOffsetY() * up.getOffsetZ() - forward.getOffsetZ() * up.getOffsetY();
final int west_y = forward.getZOffset() * up.getXOffset() - forward.getXOffset() * up.getZOffset(); final int west_y = forward.getOffsetZ() * up.getOffsetX() - forward.getOffsetX() * up.getOffsetZ();
final int west_z = forward.getXOffset() * up.getYOffset() - forward.getYOffset() * up.getXOffset(); final int west_z = forward.getOffsetX() * up.getOffsetY() - forward.getOffsetY() * up.getOffsetX();
f1 += forward.getXOffset() * 0.6; f1 += forward.getOffsetX() * 0.6;
f2 += forward.getYOffset() * 0.6; f2 += forward.getOffsetY() * 0.6;
f3 += forward.getZOffset() * 0.6; f3 += forward.getOffsetZ() * 0.6;
final double ox = r.nextDouble(); final double ox = r.nextDouble();
final double oy = r.nextDouble() * 0.2f; final double oy = r.nextDouble() * 0.2f;
f1 += up.getXOffset() * (-0.3 + oy); f1 += up.getOffsetX() * (-0.3 + oy);
f2 += up.getYOffset() * (-0.3 + oy); f2 += up.getOffsetY() * (-0.3 + oy);
f3 += up.getZOffset() * (-0.3 + oy); f3 += up.getOffsetZ() * (-0.3 + oy);
f1 += west_x * (0.3 * ox - 0.15); f1 += west_x * (0.3 * ox - 0.15);
f2 += west_y * (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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; 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.Particle;
import net.minecraft.client.particle.ParticleManager; 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.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState; import net.minecraft.fluid.IFluidState;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.DyeColor; import net.minecraft.util.DyeColor;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList; 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.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -72,11 +72,11 @@ import appeng.helpers.AEGlassMaterial;
import appeng.integration.abstraction.IAEFacade; import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer; import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer; import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.tile.networking.CableBusTileEntity; import appeng.tile.networking.CableBusBlockEntity;
import appeng.util.Platform; 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(); private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
@@ -137,7 +137,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
} }
@Override @Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { public boolean isReplaceable(BlockState state, ItemPlacementContext useContext) {
// FIXME: Potentially check the fluid one too // FIXME: Potentially check the fluid one too
return super.isReplaceable(state, useContext) && this.cb(useContext.getWorld(), useContext.getPos()).isEmpty(); 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, public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
boolean willHarvest, IFluidState fluid) { boolean willHarvest, IFluidState fluid) {
if (player.abilities.isCreativeMode) { if (player.abilities.isCreativeMode) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos); final AEBaseBlockEntity tile = this.getBlockEntity(world, pos);
if (tile != null) { if (tile != null) {
tile.disableDrops(); tile.disableDrops();
} }
@@ -199,7 +199,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
ICableBusContainer cb = this.cb(world, blockPos); ICableBusContainer cb = this.cb(world, blockPos);
// Our built-in model has the actual baked sprites we need // Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher() BakedModel model = MinecraftClient.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState()); .getModelForState(this.getDefaultState());
// We cannot add the effect if we don't have the model // 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); ICableBusContainer cb = this.cb(world, pos);
// Our built-in model has the actual baked sprites we need // Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher() BakedModel model = MinecraftClient.getInstance().getBlockRendererDispatcher()
.getModelForState(this.getDefaultState()); .getModelForState(this.getDefaultState());
// We cannot add the effect if we dont have the model // 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) { private ICableBusContainer cb(final BlockView w, final BlockPos pos) {
final BlockEntity te = w.getTileEntity(pos); final BlockEntity te = w.getBlockEntity(pos);
ICableBusContainer out = null; ICableBusContainer out = null;
if (te instanceof CableBusTileEntity) { if (te instanceof CableBusBlockEntity) {
out = ((CableBusTileEntity) te).getCableBus(); out = ((CableBusBlockEntity) te).getCableBus();
} }
return out == null ? NULL_CABLE_BUS : out; return out == null ? NULL_CABLE_BUS : out;
@@ -293,11 +293,11 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Nullable @Nullable
private IFacadeContainer fc(final BlockView w, final BlockPos pos) { private IFacadeContainer fc(final BlockView w, final BlockPos pos) {
final BlockEntity te = w.getTileEntity(pos); final BlockEntity te = w.getBlockEntity(pos);
IFacadeContainer out = null; IFacadeContainer out = null;
if (te instanceof CableBusTileEntity) { if (te instanceof CableBusBlockEntity) {
out = ((CableBusTileEntity) te).getCableBus().getFacadeContainer(); out = ((CableBusBlockEntity) te).getCableBus().getFacadeContainer();
} }
return out; return out;
@@ -305,15 +305,15 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override @Override
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if (worldIn.isRemote()) { if (worldIn.isClient()) {
final HitResult rtr = Minecraft.getInstance().objectMouseOver; final HitResult rtr = MinecraftClient.getInstance().objectMouseOver;
if (rtr instanceof BlockRayTraceResult) { if (rtr instanceof BlockHitResult) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr; BlockHitResult brtr = (BlockHitResult) rtr;
if (brtr.getPos().equals(pos)) { if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos)); final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) { 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)); (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
} }
} }
@@ -327,18 +327,13 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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 // Transform from world into block space
Vec3d hitVec = hit.getHitVec(); Vec3d hitVec = hit.getHitVec();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ()); 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; 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, public boolean recolorBlock(final BlockView world, final BlockPos pos, final Direction side,
final DyeColor color, final PlayerEntity who) { final DyeColor color, final PlayerEntity who) {
try { try {
@@ -370,7 +365,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override @Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
CableBusTileEntity te = getTileEntity(w, pos); CableBusBlockEntity te = getBlockEntity(w, pos);
if (te == null) { if (te == null) {
return VoxelShapes.empty(); return VoxelShapes.empty();
} else { } else {
@@ -380,7 +375,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) {
CableBusTileEntity te = getTileEntity(w, pos); CableBusBlockEntity te = getBlockEntity(w, pos);
if (te == null) { if (te == null) {
return VoxelShapes.empty(); return VoxelShapes.empty();
} else { } else {
@@ -22,7 +22,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; 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.util.math.BlockPos;
import net.minecraft.world.ILightReader; import net.minecraft.world.ILightReader;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@@ -30,14 +30,14 @@ import net.fabricmc.api.Environment;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.parts.CableBusContainer; 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 * Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium
* variant) and 2 (bright variant). * variant) and 2 (bright variant).
*/ */
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class CableBusColor implements IBlockColor { public class CableBusColor implements BlockColorProvider {
@Override @Override
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) { 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; AEColor busColor = AEColor.TRANSPARENT;
if (worldIn != null && pos != null) { if (worldIn != null && pos != null) {
BlockEntity tileEntity = worldIn.getTileEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity instanceof CableBusTileEntity) { if (tileEntity instanceof CableBusBlockEntity) {
CableBusContainer container = ((CableBusTileEntity) tileEntity).getCableBus(); CableBusContainer container = ((CableBusBlockEntity) tileEntity).getCableBus();
busColor = container.getColor(); busColor = container.getColor();
} }
} }
@@ -34,7 +34,8 @@ public class CableBusRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { 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.blockColor(new CableBusColor());
rendering.modelCustomizer((loc, model) -> model); rendering.modelCustomizer((loc, model) -> model);
@@ -30,9 +30,9 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; 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 { public enum ControllerBlockState implements IStringSerializable {
offline, online, conflicted; offline, online, conflicted;
@@ -67,7 +67,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
ControllerRenderType.class); ControllerRenderType.class);
public ControllerBlock() { public ControllerBlock() {
super(defaultProps(Material.IRON).hardnessAndResistance(6)); super(defaultProps(Material.IRON).strength(6));
this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline) this.setDefaultState(this.getDefaultState().with(CONTROLLER_STATE, ControllerBlockState.offline)
.with(CONTROLLER_TYPE, ControllerRenderType.block)); .with(CONTROLLER_TYPE, ControllerRenderType.block));
} }
@@ -99,12 +99,12 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
int z = pos.getZ(); int z = pos.getZ();
// Detect whether controllers are on both sides of the x, y, and z axes // 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 final boolean xx = this.getBlockEntity(world, x - 1, y, z) != null
&& this.getTileEntity(world, x + 1, y, z) != null; && this.getBlockEntity(world, x + 1, y, z) != null;
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null final boolean yy = this.getBlockEntity(world, x, y - 1, z) != null
&& this.getTileEntity(world, x, y + 1, z) != null; && this.getBlockEntity(world, x, y + 1, z) != null;
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null final boolean zz = this.getBlockEntity(world, x, y, z - 1) != null
&& this.getTileEntity(world, x, y, z + 1) != null; && this.getBlockEntity(world, x, y, z + 1) != null;
if (xx && !yy && !zz) { if (xx && !yy && !zz) {
type = ControllerRenderType.column_x; type = ControllerRenderType.column_x;
@@ -132,7 +132,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final ControllerTileEntity tc = this.getTileEntity(world, pos); final ControllerBlockEntity tc = this.getBlockEntity(world, pos);
if (tc != null) { if (tc != null) {
tc.onNeighborChange(false); tc.onNeighborChange(false);
} }
@@ -18,7 +18,7 @@
package appeng.block.networking; package appeng.block.networking;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.render.RenderLayer;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
@@ -29,6 +29,6 @@ public class ControllerRendering extends BlockRenderingCustomizer {
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
// Disables the default model rotator // Disables the default model rotator
rendering.modelCustomizer((loc, model) -> model); 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.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial; 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() { public CreativeEnergyCellBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE)); super(defaultProps(AEGlassMaterial.INSTANCE));
@@ -21,9 +21,9 @@ package appeng.block.networking;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import appeng.block.AEBaseTileBlock; 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() { public EnergyAcceptorBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -31,9 +31,9 @@ import net.minecraft.util.NonNullList;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial; 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); 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.EnumProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -41,10 +41,10 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.WirelessContainer; import appeng.container.implementations.WirelessContainer;
import appeng.helpers.AEGlassMaterial; import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.WirelessTileEntity; import appeng.tile.networking.WirelessBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> { public class WirelessBlock extends AEBaseTileBlock<WirelessBlockEntity> {
enum State implements IStringSerializable { enum State implements IStringSerializable {
OFF, ON, HAS_CHANNEL; 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 static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
public WirelessBlock() { public WirelessBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid()); super(defaultProps(AEGlassMaterial.INSTANCE)
this.setFullSize(false); .nonOpaque()
this.setOpaque(false); .solidBlock((state, world, pos) -> false)
);
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF)); this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, WirelessTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, WirelessBlockEntity te) {
State teState = State.OFF; State teState = State.OFF;
if (te.isActive()) { if (te.isActive()) {
@@ -84,11 +85,11 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
} }
@Override @Override
public ActionResult onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, public ActionResult onUse(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand,
BlockRayTraceResult hit) { BlockHitResult hit) {
final WirelessTileEntity tg = this.getTileEntity(w, pos); final WirelessBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !player.isCrouching()) { if (tg != null && !player.isInSneakingPose()) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(WirelessContainer.TYPE, player, ContainerOpener.openContainer(WirelessContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tg, hit.getFace())); ContainerLocator.forTileEntitySide(tg, hit.getFace()));
@@ -96,12 +97,12 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
return super.onBlockActivated(state, w, pos, player, hand, hit); return super.onUse(state, w, pos, player, hand, hit);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { 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) { if (tile != null) {
final Direction forward = tile.getForward(); final Direction forward = tile.getForward();
@@ -161,7 +162,7 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { 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) { if (tile != null) {
final Direction forward = tile.getForward(); final Direction forward = tile.getForward();
@@ -1,7 +1,7 @@
package appeng.block.networking; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@@ -15,7 +15,7 @@ public class WirelessRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout()); rendering.renderType(RenderLayer.getCutout());
rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT)); 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.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.helpers.Splotch; import appeng.helpers.Splotch;
import appeng.tile.misc.PaintSplotchesTileEntity; import appeng.tile.misc.PaintSplotchesBlockEntity;
/** /**
* Renders paint blocks, which render multiple "splotches" that have been * Renders paint blocks, which render multiple "splotches" that have been
@@ -58,7 +58,7 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
return Collections.emptyList(); return Collections.emptyList();
} }
PaintSplotches splotchesState = extraData.getData(PaintSplotchesTileEntity.SPLOTCHES); PaintSplotches splotchesState = extraData.getData(PaintSplotchesBlockEntity.SPLOTCHES);
if (splotchesState == null) { if (splotchesState == null) {
// This is the inventory model which should usually not be used other than in // 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.Material;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
@@ -37,10 +37,10 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.tile.misc.PaintSplotchesTileEntity; import appeng.tile.misc.PaintSplotchesBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntity> { public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesBlockEntity> {
public PaintSplotchesBlock() { public PaintSplotchesBlock() {
super(defaultProps(Material.WATER, MaterialColor.AIR)); super(defaultProps(Material.WATER, MaterialColor.AIR));
this.setFullSize(false); this.setFullSize(false);
@@ -61,7 +61,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final PaintSplotchesTileEntity tp = this.getTileEntity(world, pos); final PaintSplotchesBlockEntity tp = this.getBlockEntity(world, pos);
if (tp != null) { if (tp != null) {
tp.neighborChanged(); tp.neighborChanged();
@@ -77,7 +77,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
@Override @Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) { 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) { if (tp != null) {
return tp.getLightLevel(); return tp.getLightLevel();
@@ -92,7 +92,7 @@ public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntit
} }
@Override @Override
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { public boolean isReplaceable(BlockState state, ItemPlacementContext useContext) {
return true; return true;
} }
@@ -7,12 +7,12 @@ import java.util.function.Function;
import com.mojang.datafixers.util.Pair; 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.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel; import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverrideList; import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material; 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.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.IModelConfiguration;
@@ -21,9 +21,9 @@ import net.minecraftforge.client.model.geometry.IModelGeometry;
public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel> { public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel> {
@Override @Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) { ItemOverrideList overrides, Identifier modelLocation) {
return new PaintSplotchesBakedModel(spriteGetter); return new PaintSplotchesBakedModel(spriteGetter);
} }
@@ -1,7 +1,7 @@
package appeng.block.paint; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@@ -14,7 +14,7 @@ public class PaintSplotchesRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout()); rendering.renderType(RenderLayer.getCutout());
// Disable auto rotation // Disable auto rotation
rendering.modelCustomizer((location, model) -> model); rendering.modelCustomizer((location, model) -> model);
} }
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad; 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.ItemOverrideList;
import net.minecraft.client.render.model.Material; import net.minecraft.client.render.model.Material;
import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.AtlasTexture;
@@ -28,7 +28,7 @@ import net.minecraftforge.client.model.data.IModelData;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.client.render.cablebus.CubeBuilder; import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.tile.qnb.QuantumBridgeTileEntity; import appeng.tile.qnb.QuantumBridgeBlockEntity;
class QnbFormedBakedModel implements IDynamicBakedModel { 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_MIN = -0.01f;
private static final float CENTER_POWERED_RENDER_MAX = 16.01f; private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
private final IBakedModel baseModel; private final BakedModel baseModel;
private final Block linkBlock; private final Block linkBlock;
@@ -65,7 +65,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
private final TextureAtlasSprite lightTexture; private final TextureAtlasSprite lightTexture;
private final TextureAtlasSprite lightCornerTexture; private final TextureAtlasSprite lightCornerTexture;
public QnbFormedBakedModel(IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) { public QnbFormedBakedModel(BakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
this.baseModel = baseModel; this.baseModel = baseModel;
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK); this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING); this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
@@ -79,7 +79,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
@Override @Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
IModelData modelData) { IModelData modelData) {
QnbFormedState formedState = modelData.getData(QuantumBridgeTileEntity.FORMED_STATE); QnbFormedState formedState = modelData.getData(QuantumBridgeBlockEntity.FORMED_STATE);
if (formedState == null) { if (formedState == null) {
return this.baseModel.getQuads(state, side, rand); 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 // Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture // ring texture
// (avoids z-fighting) // (avoids z-fighting)
float xOffset = Math.abs(facing.getXOffset() * 0.01f); float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
float yOffset = Math.abs(facing.getYOffset() * 0.01f); float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
float zOffset = Math.abs(facing.getZOffset() * 0.01f); float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
builder.setDrawFaces(EnumSet.of(facing)); builder.setDrawFaces(EnumSet.of(facing));
builder.addCube(DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, 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 // Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture // ring texture
// (avoids z-fighting) // (avoids z-fighting)
float xOffset = Math.abs(facing.getXOffset() * 0.01f); float xOffset = Math.abs(facing.getOffsetX() * 0.01f);
float yOffset = Math.abs(facing.getYOffset() * 0.01f); float yOffset = Math.abs(facing.getOffsetY() * 0.01f);
float zOffset = Math.abs(facing.getZOffset() * 0.01f); float zOffset = Math.abs(facing.getOffsetZ() * 0.01f);
builder.setDrawFaces(EnumSet.of(facing)); builder.setDrawFaces(EnumSet.of(facing));
builder.addCube(-xOffset, -yOffset, -zOffset, 16 + xOffset, 16 + yOffset, 16 + zOffset); 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 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.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel; import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverrideList; import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material; 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.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration; 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"); private static final Identifier MODEL_RING = new Identifier(AppEng.MOD_ID, "block/qnb/ring");
@Override @Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) { ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter); BakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
return new QnbFormedBakedModel(ringModel, spriteGetter); return new QnbFormedBakedModel(ringModel, spriteGetter);
} }
@@ -31,9 +31,9 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; 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"); public static final BooleanProperty FORMED = BooleanProperty.create("formed");
@@ -62,31 +62,31 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, QuantumBridgeBlockEntity te) {
return currentState.with(FORMED, te.isFormed()); return currentState.with(FORMED, te.isFormed());
} }
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final QuantumBridgeTileEntity bridge = this.getTileEntity(world, pos); final QuantumBridgeBlockEntity bridge = this.getBlockEntity(world, pos);
if (bridge != null) { if (bridge != null) {
bridge.neighborUpdate(); bridge.neighborUpdate();
} }
} }
@Override @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()) { if (newState.getBlock() == state.getBlock()) {
return; // Just a block state change return; // Just a block state change
} }
final QuantumBridgeTileEntity bridge = this.getTileEntity(w, pos); final QuantumBridgeBlockEntity bridge = this.getBlockEntity(w, pos);
if (bridge != null) { if (bridge != null) {
bridge.breakCluster(); bridge.breakCluster();
} }
super.onReplaced(state, w, pos, newState, isMoving); super.onStateReplaced(state, w, pos, newState, isMoving);
} }
} }
@@ -1,7 +1,7 @@
package appeng.block.qnb; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@@ -14,7 +14,7 @@ public class QuantumBridgeRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout()); rendering.renderType(RenderLayer.getCutout());
// Disable auto rotation // Disable auto rotation
rendering.modelCustomizer((location, model) -> model); rendering.modelCustomizer((location, model) -> model);
} }
@@ -29,7 +29,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos; 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.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -42,7 +42,7 @@ import appeng.container.ContainerOpener;
import appeng.container.implementations.QNBContainer; import appeng.container.implementations.QNBContainer;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.helpers.AEGlassMaterial; import appeng.helpers.AEGlassMaterial;
import appeng.tile.qnb.QuantumBridgeTileEntity; import appeng.tile.qnb.QuantumBridgeBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class QuantumLinkChamberBlock extends QuantumBaseBlock { public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@@ -61,7 +61,7 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@Override @Override
public void animateTick(final BlockState state, final World w, final BlockPos pos, final Random rand) { 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 != null) {
if (bridge.hasQES()) { if (bridge.hasQES()) {
if (AppEng.proxy.shouldAddParticles(rand)) { if (AppEng.proxy.shouldAddParticles(rand)) {
@@ -74,12 +74,12 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final QuantumBridgeTileEntity tg = this.getTileEntity(w, pos); final QuantumBridgeBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(QNBContainer.TYPE, p, ContainerLocator.forTileEntity(tg)); 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.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import appeng.tile.qnb.QuantumBridgeTileEntity; import appeng.tile.qnb.QuantumBridgeBlockEntity;
public class QuantumRingBlock extends QuantumBaseBlock { public class QuantumRingBlock extends QuantumBaseBlock {
@@ -41,7 +41,7 @@ public class QuantumRingBlock extends QuantumBaseBlock {
@Override @Override
public VoxelShape getShape(BlockState state, BlockView w, BlockPos pos, ShapeContext context) { 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()) { if (bridge != null && bridge.isCorner()) {
return SHAPE_CORNER; return SHAPE_CORNER;
} else if (bridge != null && bridge.isFormed()) { } else if (bridge != null && bridge.isFormed()) {
@@ -50,7 +50,7 @@ public class MatrixFrameBlock extends AEBaseBlock {
false, PushReaction.PUSH_ONLY); false, PushReaction.PUSH_ONLY);
public MatrixFrameBlock() { 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 @Override
@@ -28,17 +28,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.SpatialIOPortContainer; import appeng.container.implementations.SpatialIOPortContainer;
import appeng.tile.spatial.SpatialIOPortTileEntity; import appeng.tile.spatial.SpatialIOPortBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity> { public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortBlockEntity> {
public SpatialIOPortBlock() { public SpatialIOPortBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -47,7 +47,7 @@ public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity>
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final SpatialIOPortTileEntity te = this.getTileEntity(world, pos); final SpatialIOPortBlockEntity te = this.getBlockEntity(world, pos);
if (te != null) { if (te != null) {
te.updateRedstoneState(); te.updateRedstoneState();
} }
@@ -55,12 +55,12 @@ public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity>
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final SpatialIOPortTileEntity tg = this.getTileEntity(w, pos); final SpatialIOPortBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(SpatialIOPortContainer.TYPE, p, ContainerOpener.openContainer(SpatialIOPortContainer.TYPE, p,
@@ -26,9 +26,9 @@ import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial; 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() { public SpatialPylonBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE)); super(defaultProps(AEGlassMaterial.INSTANCE));
@@ -37,7 +37,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final SpatialPylonTileEntity tsp = this.getTileEntity(world, pos); final SpatialPylonBlockEntity tsp = this.getBlockEntity(world, pos);
if (tsp != null) { if (tsp != null) {
tsp.neighborChanged(); tsp.neighborChanged();
} }
@@ -45,7 +45,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
@Override @Override
public int getLightValue(final BlockState state, final BlockView w, final BlockPos pos) { 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) { if (tsp != null) {
return tsp.getLightValue(); return tsp.getLightValue();
} }
@@ -30,7 +30,7 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
@@ -38,9 +38,9 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.ChestContainer; import appeng.container.implementations.ChestContainer;
import appeng.core.localization.PlayerMessages; 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", private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
DriveSlotState.class); DriveSlotState.class);
@@ -57,7 +57,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
} }
@Override @Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, ChestTileEntity te) { protected BlockState updateBlockStateFromTileEntity(BlockState currentState, ChestBlockEntity te) {
DriveSlotState slotState = DriveSlotState.EMPTY; DriveSlotState slotState = DriveSlotState.EMPTY;
if (te.getCellCount() >= 1) { if (te.getCellCount() >= 1) {
@@ -73,14 +73,14 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
final ChestTileEntity tg = this.getTileEntity(w, pos); final ChestBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null && !p.isCrouching()) { if (tg != null && !p.isInSneakingPose()) {
if (w.isRemote()) { if (w.isClient()) {
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
if (hit.getFace() == tg.getUp()) { if (hit.getSide() == tg.getUp()) {
if (!tg.openGui(p)) { if (!tg.openGui(p)) {
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get()); p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
} }
@@ -20,7 +20,7 @@ package appeng.block.storage;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.render.RenderLayer;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
@@ -34,7 +34,7 @@ public class ChestRendering extends BlockRenderingCustomizer {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { 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 // I checked, the ME chest doesn't keep its color in item form
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT)); itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
@@ -26,17 +26,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.DriveContainer; import appeng.container.implementations.DriveContainer;
import appeng.tile.storage.DriveTileEntity; import appeng.tile.storage.DriveBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class DriveBlock extends AEBaseTileBlock<DriveTileEntity> { public class DriveBlock extends AEBaseTileBlock<DriveBlockEntity> {
public DriveBlock() { public DriveBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -44,12 +44,12 @@ public class DriveBlock extends AEBaseTileBlock<DriveTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final DriveTileEntity tg = this.getTileEntity(w, pos); final DriveBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(DriveContainer.TYPE, p, ContainerLocator.forTileEntity(tg)); ContainerOpener.openContainer(DriveContainer.TYPE, p, ContainerLocator.forTileEntity(tg));
@@ -18,7 +18,7 @@
package appeng.block.storage; package appeng.block.storage;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.render.RenderLayer;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
@@ -27,6 +27,6 @@ import appeng.bootstrap.IItemRendering;
public class DriveRendering extends BlockRenderingCustomizer { public class DriveRendering extends BlockRenderingCustomizer {
@Override @Override
public void customize(IBlockRendering rendering, IItemRendering itemRendering) { 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.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.IOPortContainer; import appeng.container.implementations.IOPortContainer;
import appeng.tile.storage.IOPortTileEntity; import appeng.tile.storage.IOPortBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> { public class IOPortBlock extends AEBaseTileBlock<IOPortBlockEntity> {
public IOPortBlock() { public IOPortBlock() {
super(defaultProps(Material.IRON)); super(defaultProps(Material.IRON));
@@ -47,7 +47,7 @@ public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
@Override @Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
final IOPortTileEntity te = this.getTileEntity(world, pos); final IOPortBlockEntity te = this.getBlockEntity(world, pos);
if (te != null) { if (te != null) {
te.updateRedstoneState(); te.updateRedstoneState();
} }
@@ -55,12 +55,12 @@ public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) { final @Nullable ItemStack heldItem, final BlockHitResult hit) {
if (p.isCrouching()) { if (p.isInSneakingPose()) {
return ActionResult.PASS; return ActionResult.PASS;
} }
final IOPortTileEntity tg = this.getTileEntity(w, pos); final IOPortBlockEntity tg = this.getBlockEntity(w, pos);
if (tg != null) { if (tg != null) {
if (Platform.isServer()) { if (Platform.isServer()) {
ContainerOpener.openContainer(IOPortContainer.TYPE, p, 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.math.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; 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.block.ShapeContext;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@@ -40,10 +40,10 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.SkyChestContainer; import appeng.container.implementations.SkyChestContainer;
import appeng.tile.storage.SkyChestTileEntity; import appeng.tile.storage.SkyChestBlockEntity;
import appeng.util.Platform; 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_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0.06; private static final double AABB_OFFSET_SIDES = 0.06;
@@ -55,7 +55,7 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
public final SkyChestType type; public final SkyChestType type;
public SkyChestBlock(final SkyChestType type, Properties props) { public SkyChestBlock(final SkyChestType type, Settings props) {
super(props); super(props);
this.type = type; this.type = type;
} }
@@ -72,9 +72,9 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
@Override @Override
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, 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()) { if (Platform.isServer()) {
SkyChestTileEntity tile = getTileEntity(w, pos); SkyChestBlockEntity tile = getBlockEntity(w, pos);
if (tile == null) { if (tile == null) {
return ActionResult.PASS; return ActionResult.PASS;
} }
@@ -93,31 +93,31 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
} }
private Box computeAABB(final BlockView w, final BlockPos pos) { 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; Direction o = Direction.UP;
if (sk != null) { if (sk != null) {
o = sk.getUp(); o = sk.getUp();
} }
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; final double offsetX = o.getOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; final double offsetY = o.getOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getZOffset() == 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 // for x/z top and bottom is swapped
final double minX = Math.max(0.0, 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, 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, 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, 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, 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, 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); return new Box(minX, minY, minZ, maxX, maxY, maxZ);
} }
@@ -18,29 +18,11 @@
package appeng.bootstrap; 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.definitions.IBlockDefinition;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
import appeng.block.AEBaseBlockItem; import appeng.block.AEBaseBlockItem;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.definitions.TileEntityDefinition; import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEItemGroup; import appeng.core.AEItemGroup;
import appeng.core.AppEng; import appeng.core.AppEng;
@@ -48,12 +30,28 @@ import appeng.core.CreativeTab;
import appeng.core.features.BlockDefinition; import appeng.core.features.BlockDefinition;
import appeng.core.features.TileDefinition; import appeng.core.features.TileDefinition;
import appeng.util.Platform; 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 { class BlockDefinitionBuilder implements IBlockBuilder {
private final FeatureFactory factory; private final FeatureFactory factory;
private final String registryName; private final Identifier id;
private final Supplier<? extends Block> blockSupplier; private final Supplier<? extends Block> blockSupplier;
@@ -67,7 +65,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
private boolean disableItem = false; private boolean disableItem = false;
private BiFunction<Block, Item.Properties, BlockItem> itemFactory; private BiFunction<Block, Item.Settings, BlockItem> itemFactory;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private BlockRendering blockRendering; private BlockRendering blockRendering;
@@ -77,11 +75,11 @@ class BlockDefinitionBuilder implements IBlockBuilder {
BlockDefinitionBuilder(FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier) { BlockDefinitionBuilder(FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier) {
this.factory = factory; this.factory = factory;
this.registryName = id; this.id = new Identifier(AppEng.MOD_ID, id);
this.blockSupplier = blockSupplier; this.blockSupplier = blockSupplier;
if (Platform.hasClientClasses()) { if (Platform.hasClientClasses()) {
this.blockRendering = new BlockRendering(); this.blockRendering = new BlockRendering(this.id);
this.itemRendering = new ItemRendering(); this.itemRendering = new ItemRendering();
} }
} }
@@ -121,7 +119,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
} }
@Override @Override
public IBlockBuilder item(BiFunction<Block, Item.Properties, BlockItem> factory) { public IBlockBuilder item(BiFunction<Block, Item.Settings, BlockItem> factory) {
this.itemFactory = factory; this.itemFactory = factory;
return this; return this;
} }
@@ -142,18 +140,12 @@ class BlockDefinitionBuilder implements IBlockBuilder {
public <T extends IBlockDefinition> T build() { public <T extends IBlockDefinition> T build() {
// Create block and matching item, and set factory name of both // Create block and matching item, and set factory name of both
Block block = this.blockSupplier.get(); 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 // 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) { if (item != null) {
this.factory Registry.register(Registry.ITEM, id, item);
.addBootstrapComponent((IItemRegistrationComponent) (side, registry) -> registry.register(item));
} }
// Register all extra handlers // Register all extra handlers
@@ -174,9 +166,9 @@ class BlockDefinitionBuilder implements IBlockBuilder {
T definition; T definition;
if (block instanceof AEBaseTileBlock) { 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 { } else {
definition = (T) new BlockDefinition(this.registryName, block, item, features); definition = (T) new BlockDefinition(this.id.getPath(), block, item, features);
} }
if (itemGroup instanceof AEItemGroup) { if (itemGroup instanceof AEItemGroup) {
@@ -192,7 +184,7 @@ class BlockDefinitionBuilder implements IBlockBuilder {
return null; return null;
} }
Item.Properties itemProperties = new Item.Properties(); Item.Settings itemProperties = new Item.Settings();
if (itemGroup != null) { if (itemGroup != null) {
itemProperties.group(itemGroup); itemProperties.group(itemGroup);
@@ -24,7 +24,7 @@ import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.features.ActivityState; import appeng.core.features.ActivityState;
import appeng.core.features.BlockStackSrc; import appeng.core.features.BlockStackSrc;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
/** /**
@@ -33,7 +33,7 @@ import appeng.util.Platform;
* *
* @param <T> * @param <T>
*/ */
public class TileEntityBuilder<T extends AEBaseTileEntity> { public class BlockEntityBuilder<T extends AEBaseBlockEntity> {
private final FeatureFactory factory; private final FeatureFactory factory;
@@ -54,8 +54,8 @@ public class TileEntityBuilder<T extends AEBaseTileEntity> {
private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class); private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
public TileEntityBuilder(FeatureFactory factory, String registryName, Class<T> tileClass, public BlockEntityBuilder(FeatureFactory factory, String registryName, Class<T> tileClass,
Function<BlockEntityType<T>, T> supplier) { Function<BlockEntityType<T>, T> supplier) {
this.factory = factory; this.factory = factory;
this.registryName = registryName; this.registryName = registryName;
this.tileClass = tileClass; 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.features.clear();
this.addFeatures(features); this.addFeatures(features);
return this; return this;
} }
public TileEntityBuilder<T> addFeatures(AEFeature... features) { public BlockEntityBuilder<T> addFeatures(AEFeature... features) {
Collections.addAll(this.features, features); Collections.addAll(this.features, features);
return this; return this;
} }
public TileEntityBuilder<T> rendering(TileEntityRenderingCustomizer<T> customizer) { public BlockEntityBuilder<T> rendering(TileEntityRenderingCustomizer<T> customizer) {
DistExecutor.runWhenOn(EnvType.CLIENT, () -> () -> customizer.customize(tileEntityRendering)); DistExecutor.runWhenOn(EnvType.CLIENT, () -> () -> customizer.customize(tileEntityRendering));
return this; return this;
} }
@@ -95,7 +95,7 @@ public class TileEntityBuilder<T extends AEBaseTileEntity> {
type.setRegistryName(AppEng.MOD_ID, registryName); type.setRegistryName(AppEng.MOD_ID, registryName);
registry.register(type); 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) { for (Block block : blocks) {
if (block instanceof AEBaseTileBlock) { if (block instanceof AEBaseTileBlock) {
@@ -19,69 +19,67 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Predicate;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.IBakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.BlockColorComponent; import appeng.bootstrap.components.BlockColorComponent;
import appeng.bootstrap.components.RenderTypeComponent; import appeng.bootstrap.components.RenderTypeComponent;
import appeng.client.render.model.AutoRotatingBakedModel; import appeng.client.render.model.AutoRotatingBakedModel;
import net.minecraft.util.registry.Registry;
class BlockRendering implements IBlockRendering { class BlockRendering implements IBlockRendering {
@Environment(EnvType.CLIENT) private final Identifier id;
private BiFunction<Identifier, IBakedModel, IBakedModel> modelCustomizer;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private IBlockColor blockColor; private BiFunction<Identifier, BakedModel, BakedModel> modelCustomizer;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private RenderType renderType; private BlockColorProvider blockColor;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private Predicate<RenderType> renderTypes; private RenderLayer renderType;
public BlockRendering(Identifier id) {
this.id = id;
}
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public IBlockRendering modelCustomizer(BiFunction<Identifier, IBakedModel, IBakedModel> customizer) { public IBlockRendering modelCustomizer(BiFunction<Identifier, BakedModel, BakedModel> customizer) {
this.modelCustomizer = customizer; this.modelCustomizer = customizer;
return this; return this;
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Override @Override
public IBlockRendering blockColor(IBlockColor blockColor) { public IBlockRendering blockColor(BlockColorProvider blockColor) {
this.blockColor = blockColor; this.blockColor = blockColor;
return this; return this;
} }
@Override @Override
public IBlockRendering renderType(RenderType type) { public IBlockRendering renderType(RenderLayer type) {
this.renderType = type; this.renderType = type;
return this; return this;
} }
@Override
public IBlockRendering renderType(Predicate<RenderType> typePredicate) {
this.renderTypes = typePredicate;
return this;
}
void apply(FeatureFactory factory, Block block) { void apply(FeatureFactory factory, Block block) {
if (this.modelCustomizer != null) { if (this.modelCustomizer != null) {
factory.addModelOverride(block.getRegistryName().getPath(), this.modelCustomizer); factory.addModelOverride(id.getPath(), this.modelCustomizer);
} else if (block instanceof AEBaseTileBlock) { } else if (block instanceof AEBaseTileBlock) {
// This is a default rotating model if the base-block uses an AE tile entity // This is a default rotating model if the base-block uses an AE tile entity
// which exposes UP/FRONT as // which exposes UP/FRONT as
// extended props // extended props
factory.addModelOverride(block.getRegistryName().getPath(), (l, m) -> new AutoRotatingBakedModel(m)); factory.addModelOverride(id.getPath(), (l, m) -> new AutoRotatingBakedModel(m));
} }
// TODO : 1.12 // TODO : 1.12
@@ -89,8 +87,8 @@ class BlockRendering implements IBlockRendering {
factory.addBootstrapComponent(new BlockColorComponent(block, this.blockColor)); factory.addBootstrapComponent(new BlockColorComponent(block, this.blockColor));
} }
if (this.renderType != null || this.renderTypes != null) { if (this.renderType != null) {
factory.addBootstrapComponent(new RenderTypeComponent(block, this.renderType, this.renderTypes)); factory.addBootstrapComponent(new RenderTypeComponent(block, this.renderType));
} }
} }
} }
@@ -1,17 +1,15 @@
package appeng.bootstrap; 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.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.function.Consumer; 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. * 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); private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
public EntityBuilder(FeatureFactory factory, String id, EntityType.IFactory<T> entityFactory, public EntityBuilder(FeatureFactory factory, String id, EntityType.EntityFactory<T> entityFactory,
EntityClassification classification) { SpawnGroup classification) {
this.factory = factory; this.factory = factory;
this.id = id; this.id = id;
this.builder = EntityType.Builder.create(entityFactory, classification); this.builder = EntityType.Builder.create(entityFactory, classification);
@@ -49,11 +47,9 @@ public class EntityBuilder<T extends Entity> {
} }
public EntityType<T> build() { public EntityType<T> build() {
EntityType<T> entityType = builder.build("appliedenergistics2:" + id); String fullId = "appliedenergistics2:" + this.id;
entityType.setRegistryName(AppEng.MOD_ID, id); EntityType<T> entityType = builder.build(fullId);
factory.addBootstrapComponent((IEntityRegistrationComponent) r -> { Registry.register(Registry.ENTITY_TYPE, fullId, entityType);
r.register(entityType);
});
return entityType; return entityType;
} }
} }
@@ -31,9 +31,9 @@ import java.util.function.Supplier;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.block.Block; 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.Entity;
import net.minecraft.entity.EntityClassification; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
@@ -42,7 +42,7 @@ import net.fabricmc.api.EnvType;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.bootstrap.components.ModelOverrideComponent; import appeng.bootstrap.components.ModelOverrideComponent;
import appeng.tile.AEBaseTileEntity; import appeng.tile.AEBaseBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
public class FeatureFactory { public class FeatureFactory {
@@ -76,18 +76,18 @@ public class FeatureFactory {
return new BlockDefinitionBuilder(this, id, block).features(this.defaultFeatures); 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); return new ItemDefinitionBuilder(this, id, itemFactory).features(this.defaultFeatures);
} }
public <T extends Entity> EntityBuilder<T> entity(String id, EntityType.IFactory<T> factory, public <T extends Entity> EntityBuilder<T> entity(String id, EntityType.EntityFactory<T> factory,
EntityClassification classification) { SpawnGroup classification) {
return new EntityBuilder<T>(this, id, factory, classification).features(this.defaultFeatures); return new EntityBuilder<T>(this, id, factory, classification).features(this.defaultFeatures);
} }
public <T extends AEBaseTileEntity> TileEntityBuilder<T> tileEntity(String id, Class<T> teClass, public <T extends AEBaseBlockEntity> BlockEntityBuilder<T> tileEntity(String id, Class<T> teClass,
Function<BlockEntityType<T>, T> factory) { Function<BlockEntityType<T>, T> factory) {
return new TileEntityBuilder<>(this, id, teClass, factory).features(this.defaultFeatures); return new BlockEntityBuilder<>(this, id, teClass, factory).features(this.defaultFeatures);
} }
public FeatureFactory features(AEFeature... features) { public FeatureFactory features(AEFeature... features) {
@@ -105,7 +105,7 @@ public class FeatureFactory {
} }
@Environment(EnvType.CLIENT) @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); this.modelOverrideComponent.addOverride(resourcePath, customizer);
} }
@@ -44,7 +44,7 @@ public interface IBlockBuilder {
*/ */
IBlockBuilder disableItem(); IBlockBuilder disableItem();
IBlockBuilder item(BiFunction<Block, Item.Properties, BlockItem> factory); IBlockBuilder item(BiFunction<Block, Item.Settings, BlockItem> factory);
<T extends IBlockDefinition> T build(); <T extends IBlockDefinition> T build();
} }
@@ -23,9 +23,9 @@ import java.util.function.Predicate;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.IBakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
/** /**
@@ -35,15 +35,12 @@ import net.minecraft.util.Identifier;
public interface IBlockRendering { public interface IBlockRendering {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
IBlockRendering modelCustomizer(BiFunction<Identifier, IBakedModel, IBakedModel> customizer); IBlockRendering modelCustomizer(BiFunction<Identifier, BakedModel, BakedModel> customizer);
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
IBlockRendering blockColor(IBlockColor blockColor); IBlockRendering blockColor(BlockColorProvider blockColor);
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
IBlockRendering renderType(RenderType type); IBlockRendering renderType(RenderLayer type);
@Environment(EnvType.CLIENT)
IBlockRendering renderType(Predicate<RenderType> type);
} }
@@ -18,10 +18,10 @@
package appeng.bootstrap; package appeng.bootstrap;
import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancement.criterion.Criterion;
import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.advancement.criterion.CriterionConditions;
@FunctionalInterface @FunctionalInterface
public interface ICriterionTriggerRegistry { 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.Function;
import java.util.function.Supplier; 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.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
@@ -42,14 +42,14 @@ public interface IItemBuilder {
IItemBuilder itemGroup(ItemGroup tab); IItemBuilder itemGroup(ItemGroup tab);
IItemBuilder props(Consumer<Item.Properties> customizer); IItemBuilder props(Consumer<Item.Settings> customizer);
IItemBuilder rendering(ItemRenderingCustomizer callback); IItemBuilder rendering(ItemRenderingCustomizer callback);
/** /**
* Registers a custom dispenser behavior for this item. * Registers a custom dispenser behavior for this item.
*/ */
IItemBuilder dispenserBehavior(Supplier<IDispenseItemBehavior> behavior); IItemBuilder dispenserBehavior(Supplier<DispenserBehavior> behavior);
ItemDefinition build(); ItemDefinition build();
} }
@@ -18,7 +18,7 @@
package appeng.bootstrap; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@@ -32,6 +32,6 @@ public interface IItemRendering {
* and returns a color multiplier. * and returns a color multiplier.
*/ */
@Environment(EnvType.CLIENT) @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 java.util.function.Supplier;
import net.minecraft.block.DispenserBlock; 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.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@@ -35,37 +35,38 @@ import net.fabricmc.api.Environment;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.bootstrap.components.IInitComponent; import appeng.bootstrap.components.IInitComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.core.AEItemGroup; import appeng.core.AEItemGroup;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.CreativeTab; import appeng.core.CreativeTab;
import appeng.core.features.ItemDefinition; import appeng.core.features.ItemDefinition;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
class ItemDefinitionBuilder implements IItemBuilder { class ItemDefinitionBuilder implements IItemBuilder {
private final FeatureFactory factory; 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 EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>(); 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) @Environment(EnvType.CLIENT)
private ItemRendering itemRendering; private ItemRendering itemRendering;
private ItemGroup itemGroup = CreativeTab.INSTANCE; 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.factory = factory;
this.registryName = registryName; this.id = AppEng.makeId(id);
this.itemFactory = itemFactory; this.itemFactory = itemFactory;
if (Platform.hasClientClasses()) { if (Platform.hasClientClasses()) {
this.itemRendering = new ItemRendering(); this.itemRendering = new ItemRendering();
@@ -98,7 +99,7 @@ class ItemDefinitionBuilder implements IItemBuilder {
} }
@Override @Override
public IItemBuilder props(Consumer<Item.Properties> consumer) { public IItemBuilder props(Consumer<Item.Settings> consumer) {
consumer.accept(props); consumer.accept(props);
return this; return this;
} }
@@ -113,7 +114,7 @@ class ItemDefinitionBuilder implements IItemBuilder {
} }
@Override @Override
public IItemBuilder dispenserBehavior(Supplier<IDispenseItemBehavior> behavior) { public IItemBuilder dispenserBehavior(Supplier<DispenserBehavior> behavior) {
this.dispenserBehaviorSupplier = behavior; this.dispenserBehaviorSupplier = behavior;
return this; return this;
} }
@@ -128,9 +129,8 @@ class ItemDefinitionBuilder implements IItemBuilder {
props.group(itemGroup); props.group(itemGroup);
Item item = this.itemFactory.apply(props); 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 // Register all extra handlers
this.boostrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(item))); this.boostrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(item)));
@@ -138,12 +138,12 @@ class ItemDefinitionBuilder implements IItemBuilder {
// Register custom dispenser behavior if requested // Register custom dispenser behavior if requested
if (this.dispenserBehaviorSupplier != null) { if (this.dispenserBehaviorSupplier != null) {
this.factory.addBootstrapComponent((IInitComponent) () -> { this.factory.addBootstrapComponent((IInitComponent) () -> {
IDispenseItemBehavior behavior = this.dispenserBehaviorSupplier.get(); DispenserBehavior behavior = this.dispenserBehaviorSupplier.get();
DispenserBlock.registerDispenseBehavior(item, behavior); DispenserBlock.registerBehavior(item, behavior);
}); });
} }
this.factory.addBootstrapComponent((IItemRegistrationComponent) (side, reg) -> reg.register(item)); Registry.register(Registry.ITEM, id, item);
if (Platform.hasClientClasses()) { if (Platform.hasClientClasses()) {
this.itemRendering.apply(this.factory, item); this.itemRendering.apply(this.factory, item);
@@ -19,7 +19,7 @@
package appeng.bootstrap; package appeng.bootstrap;
import net.fabricmc.api.Environment; 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.minecraft.item.Item;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@@ -28,11 +28,11 @@ import appeng.bootstrap.components.ItemColorComponent;
class ItemRendering implements IItemRendering { class ItemRendering implements IItemRendering {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private IItemColor itemColor; private ItemColorProvider itemColor;
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public IItemRendering color(IItemColor itemColor) { public IItemRendering color(ItemColorProvider itemColor) {
this.itemColor = itemColor; this.itemColor = itemColor;
return this; return this;
} }
@@ -20,21 +20,21 @@ package appeng.bootstrap;
import java.util.function.Function; import java.util.function.Function;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; 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) @Environment(EnvType.CLIENT)
Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer; Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> tileEntityRenderer;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public TileEntityRendering<T> tileEntityRenderer( public TileEntityRendering<T> tileEntityRenderer(
Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer) { Function<BlockEntityRenderDispatcher, BlockEntityRenderer<T>> tileEntityRenderer) {
this.tileEntityRenderer = tileEntityRenderer; this.tileEntityRenderer = tileEntityRenderer;
return this; return this;
} }
@@ -21,14 +21,14 @@ package appeng.bootstrap;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; 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 * 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 * this class is required and no lambdas can be used due to them not being able
* to be annotated with @OnlyIn(CLIENT). * to be annotated with @OnlyIn(CLIENT).
*/ */
public abstract class TileEntityRenderingCustomizer<T extends AEBaseTileEntity> { public abstract class TileEntityRenderingCustomizer<T extends AEBaseBlockEntity> {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public abstract void customize(TileEntityRendering<T> rendering); public abstract void customize(TileEntityRendering<T> rendering);
@@ -19,23 +19,23 @@
package appeng.bootstrap.components; package appeng.bootstrap.components;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.color.block.BlockColorProvider;
public class BlockColorComponent implements IInitComponent { public class BlockColorComponent implements IInitComponent {
private final Block block; 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.block = block;
this.blockColor = blockColor; this.blockColor = blockColor;
} }
@Override @Override
public void initialize() { 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; package appeng.bootstrap.components;
import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.color.item.ItemColors;
import appeng.bootstrap.IBootstrapComponent; 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; package appeng.bootstrap.components;
import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.color.item.ItemColors;
import net.minecraft.item.Item; import net.minecraft.item.Item;
public class ItemColorComponent implements IItemColorRegistrationComponent { public class ItemColorComponent implements IItemColorRegistrationComponent {
private final Item item; 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.item = item;
this.itemColor = itemColor; this.itemColor = itemColor;
} }
@@ -25,8 +25,8 @@ import java.util.function.BiFunction;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.minecraft.client.render.model.IBakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakery; import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelBakeEvent;
@@ -35,33 +35,33 @@ import appeng.core.AppEng;
public class ModelOverrideComponent implements IModelBakeComponent { public class ModelOverrideComponent implements IModelBakeComponent {
// Maps from resource path to customizer // 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); this.customizer.put(resourcePath, customizer);
} }
@Override @Override
public void onModelBakeEvent(final ModelBakeEvent event) { 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()); Set<Identifier> keys = Sets.newHashSet(modelRegistry.keySet());
IBakedModel missingModel = modelRegistry.get(ModelBakery.MODEL_MISSING); BakedModel missingModel = modelRegistry.get(ModelLoader.MISSING);
for (Identifier location : keys) { for (Identifier location : keys) {
if (!location.getNamespace().equals(AppEng.MOD_ID)) { if (!location.getNamespace().equals(AppEng.MOD_ID)) {
continue; continue;
} }
IBakedModel orgModel = modelRegistry.get(location); BakedModel orgModel = modelRegistry.get(location);
// Don't customize the missing model. This causes Forge to swallow exceptions // Don't customize the missing model. This causes Forge to swallow exceptions
if (orgModel == missingModel) { if (orgModel == missingModel) {
continue; continue;
} }
BiFunction<Identifier, IBakedModel, IBakedModel> customizer = this.customizer.get(location.getPath()); BiFunction<Identifier, BakedModel, BakedModel> customizer = this.customizer.get(location.getPath());
if (customizer != null) { if (customizer != null) {
IBakedModel newModel = customizer.apply(location, orgModel); BakedModel newModel = customizer.apply(location, orgModel);
if (newModel != orgModel) { if (newModel != orgModel) {
modelRegistry.put(location, newModel); modelRegistry.put(location, newModel);
@@ -1,10 +1,9 @@
package appeng.bootstrap.components; 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.block.Block;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.renderer.RenderTypeLookup;
/** /**
* Sets the rendering type for a block. * Sets the rendering type for a block.
@@ -13,25 +12,16 @@ public class RenderTypeComponent implements IClientSetupComponent {
private final Block block; private final Block block;
private final RenderType renderType; private final RenderLayer renderType;
private final Predicate<RenderType> renderTypes; public RenderTypeComponent(Block block, RenderLayer renderType) {
public RenderTypeComponent(Block block, RenderType renderType, Predicate<RenderType> renderTypes) {
this.block = block; this.block = block;
this.renderType = renderType; this.renderType = Preconditions.checkNotNull(renderType);
this.renderTypes = renderTypes;
} }
@Override @Override
public void setup() { public void setup() {
if (renderType != null) { BlockRenderLayerMap.INSTANCE.putBlock(block, renderType);
RenderTypeLookup.setRenderLayer(block, renderType);
}
if (renderTypes != null) {
RenderTypeLookup.setRenderLayer(block, renderTypes);
}
} }
} }
+15 -15
View File
@@ -23,7 +23,7 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -67,7 +67,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public World getWorld() { public World getWorld() {
if (Platform.isClient()) { if (Platform.isClient()) {
return Minecraft.getInstance().world; return MinecraftClient.getInstance().world;
} else { } else {
return super.getWorld(); return super.getWorld();
} }
@@ -81,7 +81,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public List<? extends PlayerEntity> getPlayers() { public List<? extends PlayerEntity> getPlayers() {
if (Platform.isClient()) { if (Platform.isClient()) {
return Collections.singletonList(Minecraft.getInstance().player); return Collections.singletonList(MinecraftClient.getInstance().player);
} else { } else {
return super.getPlayers(); return super.getPlayers();
} }
@@ -113,7 +113,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public boolean shouldAddParticles(final Random r) { public boolean shouldAddParticles(final Random r) {
switch (Minecraft.getInstance().gameSettings.particles) { switch (MinecraftClient.getInstance().gameSettings.particles) {
default: default:
case ALL: case ALL:
return true; return true;
@@ -126,7 +126,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public HitResult getRTR() { public HitResult getRTR() {
return Minecraft.getInstance().objectMouseOver; return MinecraftClient.getInstance().objectMouseOver;
} }
@Override @Override
@@ -139,7 +139,7 @@ public class ClientHelper extends ServerHelper {
return super.getRenderMode(); return super.getRenderMode();
} }
final Minecraft mc = Minecraft.getInstance(); final MinecraftClient mc = MinecraftClient.getInstance();
final PlayerEntity player = mc.player; final PlayerEntity player = mc.player;
return this.renderModeForPlayer(player); return this.renderModeForPlayer(player);
@@ -147,7 +147,7 @@ public class ClientHelper extends ServerHelper {
@Override @Override
public void triggerUpdates() { public void triggerUpdates() {
final Minecraft mc = Minecraft.getInstance(); final MinecraftClient mc = MinecraftClient.getInstance();
if (mc.player == null || mc.world == null) { if (mc.player == null || mc.world == null) {
return; return;
} }
@@ -183,7 +183,7 @@ public class ClientHelper extends ServerHelper {
final double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D; final double d1 = (Platform.getRandomFloat() - 0.5F) * 0.26D;
final double d2 = (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); 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 y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
final float z = (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); -x * 0.1, -y * 0.1, -z * 0.1);
} }
private void spawnLightning(final World world, final double posX, final double posY, final double posZ) { 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); 0.0f);
} }
@@ -206,7 +206,7 @@ public class ClientHelper extends ServerHelper {
final Vec3d second) { final Vec3d second) {
final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f, final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f,
0.0f); 0.0f);
Minecraft.getInstance().particles.addEffect(fx); MinecraftClient.getInstance().particles.addEffect(fx);
} }
private void wheelEvent(final InputEvent.MouseScrollEvent me) { private void wheelEvent(final InputEvent.MouseScrollEvent me) {
@@ -214,11 +214,11 @@ public class ClientHelper extends ServerHelper {
return; return;
} }
final Minecraft mc = Minecraft.getInstance(); final MinecraftClient mc = MinecraftClient.getInstance();
final PlayerEntity player = mc.player; final PlayerEntity player = mc.player;
if (player.isCrouching()) { if (player.isInSneakingPose()) {
final boolean mainHand = player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem; final boolean mainHand = player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem; final boolean offHand = player.getStackInHand(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem;
if (mainHand || offHand) { if (mainHand || offHand) {
NetworkHandler.instance() NetworkHandler.instance()
@@ -30,10 +30,10 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.Widget;
@@ -356,7 +356,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return; 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()) { if (this.enableSpaceClicking()) {
IAEItemStack stack = null; IAEItemStack stack = null;
if (slot instanceof SlotME) { if (slot instanceof SlotME) {
@@ -25,7 +25,7 @@ import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.CraftingTerminalPart; import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.PatternTerminalPart; import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.TerminalPart; 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 * 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 IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts(); 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 // A chest is also a priority host, but the priority _interface_ can only be
// opened from the // opened from the
// chest ui that doesn't actually show the contents of the inserted cell. // 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) { public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y, @Nullable String label) {
if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) { if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) {
if (label == null) { if (label == null) {
label = previousContainerIcon.getDisplayName().getString(); label = previousContainerIcon.getName().getString();
} }
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer(); ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
TabButton button = new TabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label, 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.helpers.WirelessTerminalGuiObject;
import appeng.integration.abstraction.JEIFacade; import appeng.integration.abstraction.JEIFacade;
import appeng.parts.reporting.AbstractTerminalPart; import appeng.parts.reporting.AbstractTerminalPart;
import appeng.tile.misc.SecurityStationTileEntity; import appeng.tile.misc.SecurityStationBlockEntity;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
@@ -110,7 +110,7 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
this.viewCell = te instanceof IViewCellStorage; this.viewCell = te instanceof IViewCellStorage;
if (te instanceof SecurityStationTileEntity) { if (te instanceof SecurityStationBlockEntity) {
this.myName = GuiText.Security; this.myName = GuiText.Security;
} else if (te instanceof WirelessTerminalGuiObject) { } else if (te instanceof WirelessTerminalGuiObject) {
this.myName = GuiText.WirelessTerminal; this.myName = GuiText.WirelessTerminal;
@@ -29,7 +29,7 @@ import appeng.client.gui.widgets.ProgressBar;
import appeng.client.gui.widgets.ProgressBar.Direction; import appeng.client.gui.widgets.ProgressBar.Direction;
import appeng.container.implementations.VibrationChamberContainer; import appeng.container.implementations.VibrationChamberContainer;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.tile.misc.VibrationChamberTileEntity; import appeng.tile.misc.VibrationChamberBlockEntity;
public class VibrationChamberScreen extends AEBaseScreen<VibrationChamberContainer> { 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(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
this.pb.setFullMsg(VibrationChamberTileEntity.POWER_PER_TICK * this.container.getCurrentProgress() this.pb.setFullMsg(VibrationChamberBlockEntity.POWER_PER_TICK * this.container.getCurrentProgress()
/ VibrationChamberTileEntity.DILATION_SCALING + " AE/t"); / VibrationChamberBlockEntity.DILATION_SCALING + " AE/t");
if (this.container.getRemainingBurnTime() > 0) { if (this.container.getRemainingBurnTime() > 0) {
final int i1 = this.container.getRemainingBurnTime() * 12 / 100; final int i1 = this.container.getRemainingBurnTime() * 12 / 100;
@@ -1,7 +1,7 @@
package appeng.client.gui.widgets; package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.AbstractGui;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; 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 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) { 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 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.gui.widget.button.Button;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -44,7 +44,7 @@ public abstract class IconButton extends Button implements ITooltip {
@Override @Override
public void renderButton(final int mouseX, final int mouseY, float partial) { public void renderButton(final int mouseX, final int mouseY, float partial) {
Minecraft minecraft = Minecraft.getInstance(); MinecraftClient minecraft = MinecraftClient.getInstance();
if (this.visible) { if (this.visible) {
final int iconIndex = this.getIconIndex(); final int iconIndex = this.getIconIndex();
@@ -18,7 +18,7 @@
package appeng.client.gui.widgets; 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.client.gui.widget.Widget;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -55,7 +55,7 @@ public class ProgressBar extends Widget implements ITooltip {
@Override @Override
public void renderButton(final int par2, final int par3, final float partial) { public void renderButton(final int par2, final int par3, final float partial) {
if (this.visible) { if (this.visible) {
Minecraft.getInstance().getTextureManager().bindTexture(this.texture); MinecraftClient.getInstance().getTextureManager().bindTexture(this.texture);
final int max = this.source.getMaxProgress(); final int max = this.source.getMaxProgress();
final int current = this.source.getCurrentProgress(); final int current = this.source.getCurrentProgress();
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Pattern; 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.client.gui.widget.button.Button;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@@ -229,7 +229,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
} }
private void triggerPress() { private void triggerPress() {
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown(); boolean backwards = MinecraftClient.getInstance().mouseHelper.isRightDown();
onPress.handle(this, backwards); onPress.handle(this, backwards);
} }
@@ -20,7 +20,7 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem; 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.gui.widget.button.Button;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
@@ -61,7 +61,7 @@ public class TabButton extends Button implements ITooltip {
@Override @Override
public void renderButton(final int x, final int y, float partial) { public void renderButton(final int x, final int y, float partial) {
final Minecraft minecraft = Minecraft.getInstance(); final MinecraftClient minecraft = MinecraftClient.getInstance();
if (this.visible) { if (this.visible) {
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); 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 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.gui.widget.button.Button;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -59,7 +59,7 @@ public class ToggleButton extends Button implements ITooltip {
final int iconIndex = this.getIconIndex(); final int iconIndex = this.getIconIndex();
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); 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_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 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.BlockState;
import net.minecraft.block.entity.BlockEntity; 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.util.math.BlockPos;
import net.minecraft.world.ILightReader; 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 * 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(); 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 AEColor color = AEColor.TRANSPARENT; // Default to a neutral color
if (worldIn != null && pos != null) { if (worldIn != null && pos != null) {
BlockEntity te = worldIn.getTileEntity(pos); BlockEntity te = worldIn.getBlockEntity(pos);
if (te instanceof IColorableTile) { if (te instanceof IColorableTile) {
color = ((IColorableTile) te).getColor(); color = ((IColorableTile) te).getColor();
} }
@@ -23,20 +23,20 @@ import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad; 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.ItemCameraTransforms;
import net.minecraft.client.render.model.ItemOverrideList; import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
public abstract class DelegateBakedModel implements IBakedModel { public abstract class DelegateBakedModel implements BakedModel {
private final IBakedModel baseModel; private final BakedModel baseModel;
protected DelegateBakedModel(IBakedModel base) { protected DelegateBakedModel(BakedModel base) {
this.baseModel = base; this.baseModel = base;
} }
@@ -57,7 +57,7 @@ public abstract class DelegateBakedModel implements IBakedModel {
} }
@Override @Override
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) { public BakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
baseModel.handlePerspective(cameraTransformType, mat); baseModel.handlePerspective(cameraTransformType, mat);
return this; return this;
} }
@@ -87,7 +87,7 @@ public abstract class DelegateBakedModel implements IBakedModel {
return this.baseModel.isBuiltInRenderer(); return this.baseModel.isBuiltInRenderer();
} }
public IBakedModel getBaseModel() { public BakedModel getBaseModel() {
return this.baseModel; return this.baseModel;
} }
} }
@@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad; 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.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -37,7 +37,7 @@ import net.minecraft.util.math.Direction;
* @version rv6 - 2018-01-22 * @version rv6 - 2018-01-22
* @since rv6 2018-01-22 * @since rv6 2018-01-22
*/ */
public class DummyFluidBakedModel implements IBakedModel { public class DummyFluidBakedModel implements BakedModel {
private final ImmutableList<BakedQuad> quads; private final ImmutableList<BakedQuad> quads;
public DummyFluidBakedModel(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.block.BlockState;
import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.client.renderer.TransformationMatrix;
import net.minecraft.client.render.model.BakedQuad; 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.ItemOverrideList;
import net.minecraft.client.render.model.Material; import net.minecraft.client.render.model.Material;
import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.AtlasTexture;
@@ -55,8 +55,8 @@ import appeng.fluids.items.FluidDummyItem;
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel { public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
private final Function<Material, TextureAtlasSprite> bakedTextureGetter; private final Function<Material, TextureAtlasSprite> bakedTextureGetter;
public DummyFluidDispatcherBakedModel(IBakedModel baseModel, public DummyFluidDispatcherBakedModel(BakedModel baseModel,
Function<Material, TextureAtlasSprite> bakedTextureGetter) { Function<Material, TextureAtlasSprite> bakedTextureGetter) {
super(baseModel); super(baseModel);
this.bakedTextureGetter = bakedTextureGetter; this.bakedTextureGetter = bakedTextureGetter;
} }
@@ -86,8 +86,8 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel {
public ItemOverrideList getOverrides() { public ItemOverrideList getOverrides() {
return new ItemOverrideList() { return new ItemOverrideList() {
@Override @Override
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) { LivingEntity entity) {
if (!(stack.getItem() instanceof FluidDummyItem)) { if (!(stack.getItem() instanceof FluidDummyItem)) {
return originalModel; return originalModel;
} }
@@ -25,12 +25,12 @@ import java.util.function.Function;
import com.mojang.datafixers.util.Pair; 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.IModelTransform;
import net.minecraft.client.render.model.IUnbakedModel; import net.minecraft.client.render.model.IUnbakedModel;
import net.minecraft.client.render.model.ItemOverrideList; import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.client.render.model.Material; 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.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.IModelConfiguration;
@@ -48,10 +48,10 @@ public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
"item/dummy_fluid_item_base"); "item/dummy_fluid_item_base");
@Override @Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) { ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
return new DummyFluidDispatcherBakedModel(bakedBaseModel, spriteGetter); return new DummyFluidDispatcherBakedModel(bakedBaseModel, spriteGetter);
} }
@@ -26,8 +26,8 @@ import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.block.BlockState; 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.BakedQuad;
import net.minecraft.client.render.model.IBakedModel;
import net.minecraft.client.render.model.ItemOverrideList; import net.minecraft.client.render.model.ItemOverrideList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -48,7 +48,7 @@ public class FacadeBakedItemModel extends DelegateBakedModel {
private final FacadeBuilder facadeBuilder; private final FacadeBuilder facadeBuilder;
private List<BakedQuad> quads = null; private List<BakedQuad> quads = null;
protected FacadeBakedItemModel(IBakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) { protected FacadeBakedItemModel(BakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) {
super(base); super(base);
this.textureStack = textureStack; this.textureStack = textureStack;
this.facadeBuilder = facadeBuilder; this.facadeBuilder = facadeBuilder;
@@ -20,7 +20,7 @@ package appeng.client.render;
import java.util.Objects; 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.client.render.model.ItemOverrideList;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -41,7 +41,7 @@ public class FacadeDispatcherBakedModel extends DelegateBakedModel {
private final FacadeBuilder facadeBuilder; private final FacadeBuilder facadeBuilder;
private final Int2ObjectMap<FacadeBakedItemModel> cache = new Int2ObjectArrayMap<>(); private final Int2ObjectMap<FacadeBakedItemModel> cache = new Int2ObjectArrayMap<>();
public FacadeDispatcherBakedModel(IBakedModel baseModel, FacadeBuilder facadeBuilder) { public FacadeDispatcherBakedModel(BakedModel baseModel, FacadeBuilder facadeBuilder) {
super(baseModel); super(baseModel);
this.facadeBuilder = facadeBuilder; this.facadeBuilder = facadeBuilder;
} }
@@ -50,8 +50,8 @@ public class FacadeDispatcherBakedModel extends DelegateBakedModel {
public ItemOverrideList getOverrides() { public ItemOverrideList getOverrides() {
return new ItemOverrideList() { return new ItemOverrideList() {
@Override @Override
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, public BakedModel getModelWithOverrides(BakedModel originalModel, ItemStack stack, World world,
LivingEntity entity) { LivingEntity entity) {
if (!(stack.getItem() instanceof FacadeItem)) { if (!(stack.getItem() instanceof FacadeItem)) {
return originalModel; 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"); private static final Identifier MODEL_BASE = new Identifier(AppEng.MOD_ID, "item/facade_base");
@Override @Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, Identifier modelLocation) { ItemOverrideList overrides, Identifier modelLocation) {
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter); BakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
FacadeBuilder facadeBuilder = new FacadeBuilder(); FacadeBuilder facadeBuilder = new FacadeBuilder();
return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder); return new FacadeDispatcherBakedModel(bakedBaseModel, facadeBuilder);
@@ -25,7 +25,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.opengl.GL11; 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.BufferBuilder;
import net.minecraft.client.renderer.Quaternion; import net.minecraft.client.renderer.Quaternion;
import net.minecraft.client.renderer.RenderHelper; 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), }; new Quaternion(0.0F, 0.0F, 90.0F, true), new Quaternion(0.0F, 0.0F, -90.0F, true), };
@Override @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(); final long now = System.currentTimeMillis();
if (now - this.cycle > 2000) { if (now - this.cycle > 2000) {
this.cycle = now; this.cycle = now;

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