Fabric port in progress
This commit is contained in:
@@ -22,7 +22,7 @@ import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class ChunkLoaderBlock extends AEBaseTileBlock<ChunkLoaderTileEntity> {
|
||||
public class ChunkLoaderBlock extends AEBaseTileBlock<ChunkLoaderBlockEntity> {
|
||||
|
||||
public ChunkLoaderBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
|
||||
+3
-3
@@ -25,11 +25,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class ChunkLoaderTileEntity extends AEBaseTileEntity implements ITickableTileEntity {
|
||||
public class ChunkLoaderBlockEntity extends AEBaseBlockEntity implements ITickableTileEntity {
|
||||
|
||||
public ChunkLoaderTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public ChunkLoaderBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class CubeGeneratorBlock extends AEBaseTileBlock<CubeGeneratorTileEntity> {
|
||||
public class CubeGeneratorBlock extends AEBaseTileBlock<CubeGeneratorBlockEntity> {
|
||||
|
||||
public CubeGeneratorBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
@@ -39,8 +39,8 @@ public class CubeGeneratorBlock extends AEBaseTileBlock<CubeGeneratorTileEntity>
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
final CubeGeneratorTileEntity tcg = this.getTileEntity(w, pos);
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
final CubeGeneratorBlockEntity tcg = this.getBlockEntity(w, pos);
|
||||
if (tcg != null) {
|
||||
tcg.click(player);
|
||||
}
|
||||
|
||||
+9
-9
@@ -22,25 +22,25 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.DirectionalPlaceContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickableTileEntity {
|
||||
public class CubeGeneratorBlockEntity extends AEBaseBlockEntity implements ITickableTileEntity {
|
||||
|
||||
private int size = 3;
|
||||
private ItemStack is = ItemStack.EMPTY;
|
||||
private int countdown = 20 * 10;
|
||||
private PlayerEntity who = null;
|
||||
|
||||
public CubeGeneratorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public CubeGeneratorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickab
|
||||
|
||||
if (this.countdown % 20 == 0) {
|
||||
for (final PlayerEntity e : AppEng.proxy.getPlayers()) {
|
||||
e.sendMessage(new StringTextComponent("Spawning in... " + (this.countdown / 20)));
|
||||
e.sendMessage(new LiteralText("Spawning in... " + (this.countdown / 20)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickab
|
||||
for (int x = -half; x < half; x++) {
|
||||
for (int z = -half; z < half; z++) {
|
||||
final BlockPos p = this.pos.add(x, y - 1, z);
|
||||
ItemUseContext useContext = new DirectionalPlaceContext(this.world, p, side, this.is,
|
||||
ItemUsageContext useContext = new DirectionalPlaceContext(this.world, p, side, this.is,
|
||||
side.getOpposite());
|
||||
i.onItemUse(useContext);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickab
|
||||
if (hand.isEmpty()) {
|
||||
this.is = ItemStack.EMPTY;
|
||||
|
||||
if (player.isCrouching()) {
|
||||
if (player.isInSneakingPose()) {
|
||||
this.size--;
|
||||
} else {
|
||||
this.size++;
|
||||
@@ -102,7 +102,7 @@ public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickab
|
||||
this.size = 64;
|
||||
}
|
||||
|
||||
player.sendMessage(new StringTextComponent("Size: " + this.size));
|
||||
player.sendMessage(new LiteralText("Size: " + this.size));
|
||||
} else {
|
||||
this.countdown = 20 * 10;
|
||||
this.is = hand;
|
||||
@@ -24,12 +24,12 @@ import java.util.Set;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGridConnection;
|
||||
@@ -49,7 +49,7 @@ import appeng.me.Grid;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.parts.p2p.P2PTunnelPart;
|
||||
import appeng.tile.networking.ControllerTileEntity;
|
||||
import appeng.tile.networking.ControllerBlockEntity;
|
||||
|
||||
public class DebugCardItem extends AEBaseItem {
|
||||
|
||||
@@ -58,21 +58,21 @@ public class DebugCardItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (context.getWorld().isRemote()) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getWorld().isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
Direction side = context.getFace();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
Direction side = context.getSide();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (player.isCrouching()) {
|
||||
if (player.isInSneakingPose()) {
|
||||
int grids = 0;
|
||||
int totalNodes = 0;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class DebugCardItem extends AEBaseItem {
|
||||
this.outputMsg(player, "Grids: " + grids);
|
||||
this.outputMsg(player, "Total Nodes: " + totalNodes);
|
||||
} else {
|
||||
final BlockEntity te = world.getTileEntity(pos);
|
||||
final BlockEntity te = world.getBlockEntity(pos);
|
||||
|
||||
if (te instanceof IGridHost) {
|
||||
final GridNode node = (GridNode) ((IGridHost) te).getGridNode(AEPartLocation.fromFacing(side));
|
||||
@@ -108,7 +108,7 @@ public class DebugCardItem extends AEBaseItem {
|
||||
next = new HashSet<>();
|
||||
|
||||
for (final IGridNode n : current) {
|
||||
if (n.getMachine() instanceof ControllerTileEntity) {
|
||||
if (n.getMachine() instanceof ControllerBlockEntity) {
|
||||
break outer;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class DebugCardItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
private void outputMsg(final Entity player, final String string) {
|
||||
player.sendMessage(new StringTextComponent(string));
|
||||
player.sendMessage(new LiteralText(string));
|
||||
}
|
||||
|
||||
private String timeMeasurement(final long nanos) {
|
||||
|
||||
@@ -6,12 +6,12 @@ import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@@ -35,37 +35,37 @@ public class DebugPartPlacerItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
World world = context.getWorld();
|
||||
if (world.isRemote()) {
|
||||
if (world.isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
BlockPos pos = context.getPos();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (!player.abilities.isCreativeMode) {
|
||||
player.sendMessage(new StringTextComponent("Only usable in creative mode"));
|
||||
player.sendMessage(new LiteralText("Only usable in creative mode"));
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
BlockEntity te = world.getTileEntity(pos);
|
||||
BlockEntity te = world.getBlockEntity(pos);
|
||||
if (!(te instanceof IPartHost)) {
|
||||
player.sendMessage(new StringTextComponent("Right-click something that will accept parts"));
|
||||
player.sendMessage(new LiteralText("Right-click something that will accept parts"));
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
IPartHost center = (IPartHost) te;
|
||||
IPart cable = center.getPart(AEPartLocation.INTERNAL);
|
||||
if (cable == null) {
|
||||
player.sendMessage(new StringTextComponent("Clicked part host must have an INSIDE part"));
|
||||
player.sendMessage(new LiteralText("Clicked part host must have an INSIDE part"));
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
Direction face = context.getFace();
|
||||
Direction face = context.getSide();
|
||||
Vec3i offset = face.getDirectionVec();
|
||||
Direction[] perpendicularFaces = Arrays.stream(Direction.values()).filter(d -> d.getAxis() != face.getAxis())
|
||||
.toArray(Direction[]::new);
|
||||
@@ -85,7 +85,7 @@ public class DebugPartPlacerItem extends AEBaseItem {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockEntity t = world.getTileEntity(nextPos);
|
||||
BlockEntity t = world.getBlockEntity(nextPos);
|
||||
if (!(t instanceof IPartHost)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class EnergyGeneratorBlock extends AEBaseTileBlock<EnergyGeneratorTileEntity> {
|
||||
public class EnergyGeneratorBlock extends AEBaseTileBlock<EnergyGeneratorBlockEntity> {
|
||||
|
||||
public EnergyGeneratorBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
|
||||
+6
-6
@@ -32,16 +32,16 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class EnergyGeneratorTileEntity extends AEBaseTileEntity implements ITickableTileEntity, IEnergyStorage {
|
||||
public class EnergyGeneratorBlockEntity extends AEBaseBlockEntity implements ITickableTileEntity, IEnergyStorage {
|
||||
/**
|
||||
* The base energy injected each tick. Adjacent TileEnergyGenerators will
|
||||
* increase it to pow(base, #generators).
|
||||
*/
|
||||
private static final int BASE_ENERGY = 8;
|
||||
|
||||
public EnergyGeneratorTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public EnergyGeneratorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ public class EnergyGeneratorTileEntity extends AEBaseTileEntity implements ITick
|
||||
|
||||
int tier = 1;
|
||||
for (Direction facing : Direction.values()) {
|
||||
final BlockEntity te = world.getTileEntity(this.getPos().offset(facing));
|
||||
final BlockEntity te = world.getBlockEntity(this.getPos().offset(facing));
|
||||
|
||||
if (te instanceof EnergyGeneratorTileEntity) {
|
||||
if (te instanceof EnergyGeneratorBlockEntity) {
|
||||
tier++;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class EnergyGeneratorTileEntity extends AEBaseTileEntity implements ITick
|
||||
final int energyToInsert = IntMath.pow(BASE_ENERGY, tier);
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
final BlockEntity te = this.getWorld().getTileEntity(this.getPos().offset(facing));
|
||||
final BlockEntity te = this.getWorld().getBlockEntity(this.getPos().offset(facing));
|
||||
final LazyOptional<IEnergyStorage> cap = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
||||
|
||||
cap.ifPresent(consumer -> {
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -47,14 +47,14 @@ public class EraserItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (context.getWorld().isRemote()) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getWorld().isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
final PlayerEntity player = context.getPlayer();
|
||||
final World world = context.getWorld();
|
||||
final BlockPos pos = context.getPos();
|
||||
final BlockPos pos = context.getBlockPos();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
@@ -79,7 +79,7 @@ public class EraserItem extends AEBaseItem {
|
||||
if (contains) {
|
||||
blocks++;
|
||||
world.setBlockState(wc, Blocks.AIR.getDefaultState(), 2);
|
||||
world.destroyBlock(wc, false);
|
||||
world.breakBlock(wc, false);
|
||||
|
||||
if (isInsideBox(wc, pos)) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class ItemGenBlock extends AEBaseTileBlock<ItemGenTileEntity> {
|
||||
public class ItemGenBlock extends AEBaseTileBlock<ItemGenBlockEntity> {
|
||||
|
||||
public ItemGenBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
|
||||
+3
-3
@@ -36,15 +36,15 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import appeng.tile.AEBaseTileEntity;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class ItemGenTileEntity extends AEBaseTileEntity {
|
||||
public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
|
||||
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
|
||||
|
||||
private final ItemTransferable handler = new QueuedItemHandler();
|
||||
|
||||
public ItemGenTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public ItemGenBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
if (POSSIBLE_ITEMS.isEmpty()) {
|
||||
for (final Item mi : ForgeRegistries.ITEMS) {
|
||||
@@ -19,18 +19,18 @@
|
||||
package appeng.debug;
|
||||
|
||||
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.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.play.server.SChunkDataPacket;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MutableBoundingBox;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -52,12 +52,12 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
if (world.isRemote()) {
|
||||
return TypedActionResult.resultPass(player.getHeldItem(hand));
|
||||
if (world.isClient()) {
|
||||
return TypedActionResult.resultPass(player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
if (player.isSneaking()) {
|
||||
final ItemStack itemStack = player.getHeldItem(hand);
|
||||
final ItemStack itemStack = player.getStackInHand(hand);
|
||||
final CompoundTag tag = itemStack.getOrCreateTag();
|
||||
|
||||
if (tag.contains(MODE_TAG)) {
|
||||
@@ -69,7 +69,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
|
||||
CraterType craterType = CraterType.values()[tag.getByte(MODE_TAG)];
|
||||
|
||||
player.sendMessage(new StringTextComponent(craterType.name()));
|
||||
player.sendMessage(new LiteralText(craterType.name()));
|
||||
|
||||
return TypedActionResult.resultSuccess(itemStack);
|
||||
}
|
||||
@@ -78,14 +78,14 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (context.getWorld().isRemote()) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getWorld().isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
|
||||
ServerWorld world = (ServerWorld) context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
@@ -106,7 +106,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
pureCrater, false);
|
||||
|
||||
if (spawned == null) {
|
||||
player.sendMessage(new StringTextComponent("Un-suitable Location."));
|
||||
player.sendMessage(new LiteralText("Un-suitable Location."));
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
final MeteoritePlacer placer = new MeteoritePlacer(world, spawned, boundingBox);
|
||||
placer.place();
|
||||
|
||||
player.sendMessage(new StringTextComponent("Spawned at y=" + spawned.getPos().getY() + " range=" + range
|
||||
player.sendMessage(new LiteralText("Spawned at y=" + spawned.getPos().getY() + " range=" + range
|
||||
+ " biomeCategory=" + world.getBiome(pos).getCategory()));
|
||||
|
||||
// The placer will not send chunks to the player since it's used as part
|
||||
|
||||
@@ -25,13 +25,13 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class PhantomNodeBlock extends AEBaseTileBlock<PhantomNodeTileEntity> {
|
||||
public class PhantomNodeBlock extends AEBaseTileBlock<PhantomNodeBlockEntity> {
|
||||
|
||||
public PhantomNodeBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
@@ -39,8 +39,8 @@ public class PhantomNodeBlock extends AEBaseTileBlock<PhantomNodeTileEntity> {
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
final PhantomNodeTileEntity tpn = this.getTileEntity(w, pos);
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
final PhantomNodeBlockEntity tpn = this.getBlockEntity(w, pos);
|
||||
tpn.triggerCrashMode();
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
+3
-3
@@ -26,14 +26,14 @@ import net.minecraft.util.math.Direction;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.tile.grid.AENetworkTileEntity;
|
||||
import appeng.tile.grid.AENetworkBlockEntity;
|
||||
|
||||
public class PhantomNodeTileEntity extends AENetworkTileEntity {
|
||||
public class PhantomNodeBlockEntity extends AENetworkBlockEntity {
|
||||
|
||||
private AENetworkProxy proxy = null;
|
||||
private boolean crashMode = false;
|
||||
|
||||
public PhantomNodeTileEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
public PhantomNodeBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
@@ -49,15 +50,15 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (context.getWorld().isRemote()) {
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getWorld().isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
Direction side = context.getFace();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
Direction side = context.getSide();
|
||||
Hand hand = context.getHand();
|
||||
|
||||
if (player == null) {
|
||||
@@ -68,20 +69,20 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
if (player.isCrouching()) {
|
||||
if (world.getTileEntity(pos) instanceof IGridHost) {
|
||||
if (player.isInSneakingPose()) {
|
||||
if (world.getBlockEntity(pos) instanceof IGridHost) {
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
tag.putInt("x", x);
|
||||
tag.putInt("y", y);
|
||||
tag.putInt("z", z);
|
||||
tag.putInt("side", side.ordinal());
|
||||
tag.putInt("dimid", world.getDimension().getType().getId());
|
||||
player.getHeldItem(hand).setTag(tag);
|
||||
player.getStackInHand(hand).setTag(tag);
|
||||
} else {
|
||||
this.outputMsg(player, "This is not a Grid Tile.");
|
||||
}
|
||||
} else {
|
||||
final CompoundTag ish = player.getHeldItem(hand).getTag();
|
||||
final CompoundTag ish = player.getStackInHand(hand).getTag();
|
||||
if (ish != null) {
|
||||
final int src_x = ish.getInt("x");
|
||||
final int src_y = ish.getInt("y");
|
||||
@@ -90,7 +91,7 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
final int dimid = ish.getInt("dimid");
|
||||
final World src_w = world.getServer().getWorld(DimensionType.getById(dimid));
|
||||
|
||||
final BlockEntity te = src_w.getTileEntity(new BlockPos(src_x, src_y, src_z));
|
||||
final BlockEntity te = src_w.getBlockEntity(new BlockPos(src_x, src_y, src_z));
|
||||
if (te instanceof IGridHost) {
|
||||
final IGridHost gh = (IGridHost) te;
|
||||
final Direction sideOff = Direction.values()[src_side];
|
||||
@@ -104,9 +105,9 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
final DimensionalCoord min = sc.getMin();
|
||||
final DimensionalCoord max = sc.getMax();
|
||||
|
||||
x += currentSideOff.getXOffset();
|
||||
y += currentSideOff.getYOffset();
|
||||
z += currentSideOff.getZOffset();
|
||||
x += currentSideOff.getOffsetX();
|
||||
y += currentSideOff.getOffsetY();
|
||||
z += currentSideOff.getOffsetZ();
|
||||
|
||||
final int min_x = min.x;
|
||||
final int min_y = min.y;
|
||||
@@ -130,15 +131,16 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
final BlockState prev = world.getBlockState(d);
|
||||
|
||||
world.setBlockState(d, state);
|
||||
if (blk != null && blk.hasTileEntity(state)) {
|
||||
final BlockEntity ote = src_w.getTileEntity(p);
|
||||
final BlockEntity nte = blk.createTileEntity(state, world);
|
||||
if (blk instanceof BlockEntityProvider) {
|
||||
BlockEntityProvider blkEntityProvider = (BlockEntityProvider)blk;
|
||||
final BlockEntity ote = src_w.getBlockEntity(p);
|
||||
final BlockEntity nte = blkEntityProvider.createBlockEntity(world);
|
||||
final CompoundTag data = new CompoundTag();
|
||||
ote.write(data);
|
||||
nte.read(data.copy());
|
||||
world.setTileEntity(d, nte);
|
||||
}
|
||||
world.notifyBlockUpdate(d, prev, state, 3);
|
||||
world.updateListeners(d, prev, state, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,6 +164,6 @@ public class ReplicatorCardItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
private void outputMsg(final Entity player, final String string) {
|
||||
player.sendMessage(new StringTextComponent(string));
|
||||
player.sendMessage(new LiteralText(string));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user