Separate pedestals entities

This commit is contained in:
Aleksey 2020-11-04 22:14:54 +03:00
parent c3a7a59d78
commit 0dc7732092
9 changed files with 230 additions and 64 deletions

View file

@ -23,11 +23,12 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.Explosion;
import ru.betterend.blocks.basis.BlockPedestal; import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.EternalPedestalEntity;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import ru.betterend.util.EternalRitual; import ru.betterend.rituals.EternalRitual;
public class EternalPedestal extends BlockPedestal { public class EternalPedestal extends BlockPedestal {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
@ -42,8 +43,8 @@ public class EternalPedestal extends BlockPedestal {
ActionResult result = super.onUse(state, world, pos, player, hand, hit); ActionResult result = super.onUse(state, world, pos, player, hand, hit);
if (result.equals(ActionResult.SUCCESS)) { if (result.equals(ActionResult.SUCCESS)) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof PedestalBlockEntity) { if (blockEntity instanceof EternalPedestalEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
BlockState updatedState = world.getBlockState(pos); BlockState updatedState = world.getBlockState(pos);
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) { if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
if (pedestal.hasRitual()) { if (pedestal.hasRitual()) {
@ -103,8 +104,8 @@ public class EternalPedestal extends BlockPedestal {
} }
List<ItemStack> drop = Lists.newArrayList(); List<ItemStack> drop = Lists.newArrayList();
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
if (blockEntity != null && blockEntity instanceof PedestalBlockEntity) { if (blockEntity != null && blockEntity instanceof EternalPedestalEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
if (!pedestal.isEmpty()) { if (!pedestal.isEmpty()) {
drop.add(pedestal.getStack(0)); drop.add(pedestal.getStack(0));
} }
@ -117,4 +118,9 @@ public class EternalPedestal extends BlockPedestal {
super.appendProperties(stateManager); super.appendProperties(stateManager);
stateManager.add(ACTIVATED); stateManager.add(ACTIVATED);
} }
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new EternalPedestalEntity();
}
} }

View file

@ -0,0 +1,12 @@
package ru.betterend.blocks;
import net.minecraft.block.Block;
import ru.betterend.blocks.basis.BlockPedestal;
public class InfusionPedestal extends BlockPedestal {
public InfusionPedestal(Block parent) {
super(parent);
}
}

View file

@ -0,0 +1,49 @@
package ru.betterend.blocks.entities;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import ru.betterend.rituals.EternalRitual;
public class EternalPedestalEntity extends PedestalBlockEntity {
private EternalRitual linkedRitual;
public boolean hasRitual() {
return this.linkedRitual != null;
}
public void linkRitual(EternalRitual ritual) {
this.linkedRitual = ritual;
}
public EternalRitual getRitual() {
return this.linkedRitual;
}
@Override
public void setLocation(World world, BlockPos pos) {
super.setLocation(world, pos);
if (hasRitual()) {
this.linkedRitual.setWorld(world);
}
}
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
if (tag.contains("ritual")) {
this.linkedRitual = new EternalRitual(world);
this.linkedRitual.fromTag(tag.getCompound("ritual"));
}
}
@Override
public CompoundTag toTag(CompoundTag tag) {
if (this.hasRitual()) {
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
}
return super.toTag(tag);
}
}

View file

@ -0,0 +1,13 @@
package ru.betterend.blocks.entities;
import ru.betterend.rituals.InfusionRitual;
public class InfusionPedestalEntity extends PedestalBlockEntity {
private InfusionRitual activeRitual;
public boolean hasRitual() {
return this.activeRitual != null;
}
}

View file

@ -8,15 +8,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.util.Tickable; import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import ru.betterend.registry.EndBlockEntities; import ru.betterend.registry.EndBlockEntities;
import ru.betterend.util.EternalRitual;
public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable { public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
private ItemStack activeItem = ItemStack.EMPTY; private ItemStack activeItem = ItemStack.EMPTY;
private EternalRitual linkedRitual;
private final int maxAge = 314; private final int maxAge = 314;
private int age; private int age;
@ -24,18 +21,6 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
super(EndBlockEntities.PEDESTAL); super(EndBlockEntities.PEDESTAL);
} }
public boolean hasRitual() {
return this.linkedRitual != null;
}
public void linkRitual(EternalRitual ritual) {
this.linkedRitual = ritual;
}
public EternalRitual getRitual() {
return this.linkedRitual;
}
public int getAge() { public int getAge() {
return this.age; return this.age;
} }
@ -94,14 +79,6 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
return this.toTag(new CompoundTag()); return this.toTag(new CompoundTag());
} }
@Override
public void setLocation(World world, BlockPos pos) {
super.setLocation(world, pos);
if (hasRitual()) {
this.linkedRitual.setWorld(world);
}
}
@Override @Override
public void fromTag(BlockState state, CompoundTag tag) { public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag); super.fromTag(state, tag);
@ -109,18 +86,11 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
CompoundTag itemTag = tag.getCompound("active_item"); CompoundTag itemTag = tag.getCompound("active_item");
this.activeItem = ItemStack.fromTag(itemTag); this.activeItem = ItemStack.fromTag(itemTag);
} }
if (tag.contains("ritual")) {
this.linkedRitual = new EternalRitual(world);
this.linkedRitual.fromTag(tag.getCompound("ritual"));
}
} }
@Override @Override
public CompoundTag toTag(CompoundTag tag) { public CompoundTag toTag(CompoundTag tag) {
tag.put("active_item", activeItem.toTag(new CompoundTag())); tag.put("active_item", activeItem.toTag(new CompoundTag()));
if (this.hasRitual()) {
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
}
return super.toTag(tag); return super.toTag(tag);
} }

View file

@ -0,0 +1,55 @@
package ru.betterend.recipe.builders;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import ru.betterend.rituals.InfusionRitual;
public class InfusionRecipe implements Recipe<InfusionRitual> {
@Override
public boolean matches(InfusionRitual inv, World world) {
// TODO Auto-generated method stub
return false;
}
@Override
public ItemStack craft(InfusionRitual inv) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean fits(int width, int height) {
// TODO Auto-generated method stub
return false;
}
@Override
public ItemStack getOutput() {
// TODO Auto-generated method stub
return null;
}
@Override
public Identifier getId() {
// TODO Auto-generated method stub
return null;
}
@Override
public RecipeSerializer<?> getSerializer() {
// TODO Auto-generated method stub
return null;
}
@Override
public RecipeType<?> getType() {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -19,6 +19,7 @@ import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.blocks.entities.EChestBlockEntity; import ru.betterend.blocks.entities.EChestBlockEntity;
import ru.betterend.blocks.entities.ESignBlockEntity; import ru.betterend.blocks.entities.ESignBlockEntity;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import ru.betterend.blocks.entities.EternalPedestalEntity;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.PedestalBlockEntity;
public class EndBlockEntities { public class EndBlockEntities {
@ -26,6 +27,8 @@ public class EndBlockEntities {
BlockEntityType.Builder.create(EndStoneSmelterBlockEntity::new, EndBlocks.END_STONE_SMELTER)); BlockEntityType.Builder.create(EndStoneSmelterBlockEntity::new, EndBlocks.END_STONE_SMELTER));
public final static BlockEntityType<PedestalBlockEntity> PEDESTAL = registerBlockEntity("pedestal", public final static BlockEntityType<PedestalBlockEntity> PEDESTAL = registerBlockEntity("pedestal",
BlockEntityType.Builder.create(PedestalBlockEntity::new, getPedestals())); BlockEntityType.Builder.create(PedestalBlockEntity::new, getPedestals()));
public final static BlockEntityType<PedestalBlockEntity> ETERNAL_PEDESTAL = registerBlockEntity("eternal_pedestal",
BlockEntityType.Builder.create(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL));
public static final BlockEntityType<EChestBlockEntity> CHEST = registerBlockEntity("chest", public static final BlockEntityType<EChestBlockEntity> CHEST = registerBlockEntity("chest",
BlockEntityType.Builder.create(EChestBlockEntity::new, getChests())); BlockEntityType.Builder.create(EChestBlockEntity::new, getChests()));
public static final BlockEntityType<EBarrelBlockEntity> BARREL = registerBlockEntity("barrel", public static final BlockEntityType<EBarrelBlockEntity> BARREL = registerBlockEntity("barrel",

View file

@ -1,4 +1,4 @@
package ru.betterend.util; package ru.betterend.rituals;
import java.awt.Point; import java.awt.Point;
import java.util.Random; import java.util.Random;
@ -27,10 +27,11 @@ import net.minecraft.world.Heightmap;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.ConfiguredFeatures;
import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.EndPortalBlock; import ru.betterend.blocks.EndPortalBlock;
import ru.betterend.blocks.RunedFlavolite; import ru.betterend.blocks.RunedFlavolite;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.EternalPedestalEntity;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags; import ru.betterend.registry.EndTags;
@ -113,10 +114,10 @@ public class EternalRitual {
Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST; Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST;
boolean valid = true; boolean valid = true;
for (Point point : FRAME_MAP) { for (Point point : FRAME_MAP) {
BlockPos pos = framePos.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
valid &= state.getBlock() instanceof RunedFlavolite; valid &= state.getBlock() instanceof RunedFlavolite;
pos = framePos.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
state = world.getBlockState(pos); state = world.getBlockState(pos);
valid &= state.getBlock() instanceof RunedFlavolite; valid &= state.getBlock() instanceof RunedFlavolite;
} }
@ -163,12 +164,12 @@ public class EternalRitual {
Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST; Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST;
BlockState frame = FRAME.getDefaultState().with(ACTIVE, true); BlockState frame = FRAME.getDefaultState().with(ACTIVE, true);
FRAME_MAP.forEach(point -> { FRAME_MAP.forEach(point -> {
BlockPos pos = framePos.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.contains(ACTIVE) && !state.get(ACTIVE)) { if (state.contains(ACTIVE) && !state.get(ACTIVE)) {
world.setBlockState(pos, frame); world.setBlockState(pos, frame);
} }
pos = framePos.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
state = world.getBlockState(pos); state = world.getBlockState(pos);
if (state.contains(ACTIVE) && !state.get(ACTIVE)) { if (state.contains(ACTIVE) && !state.get(ACTIVE)) {
world.setBlockState(pos, frame); world.setBlockState(pos, frame);
@ -179,17 +180,14 @@ public class EternalRitual {
ParticleEffect effect = new BlockStateParticleEffect(ParticleTypes.BLOCK, portal); ParticleEffect effect = new BlockStateParticleEffect(ParticleTypes.BLOCK, portal);
ServerWorld serverWorld = (ServerWorld) world; ServerWorld serverWorld = (ServerWorld) world;
//double deltaX = portalAxis == Direction.Axis.X ? 0.5 : 0.1;
//double deltaZ = portalAxis == Direction.Axis.Z ? 0.5 : 0.1;
PORTAL_MAP.forEach(point -> { PORTAL_MAP.forEach(point -> {
BlockPos pos = center.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
if (!world.getBlockState(pos).isOf(PORTAL)) { if (!world.getBlockState(pos).isOf(PORTAL)) {
world.setBlockState(pos, portal); world.setBlockState(pos, portal);
serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1); serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1);
serverWorld.spawnParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3); serverWorld.spawnParticles(ParticleTypes.REVERSE_PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.3);
} }
pos = center.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
if (!world.getBlockState(pos).isOf(PORTAL)) { if (!world.getBlockState(pos).isOf(PORTAL)) {
world.setBlockState(pos, portal); world.setBlockState(pos, portal);
serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1); serverWorld.spawnParticles(effect, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.5, 0.5, 0.5, 0.1);
@ -209,23 +207,23 @@ public class EternalRitual {
BlockPos framePos = center.down(); BlockPos framePos = center.down();
Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST; Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST;
FRAME_MAP.forEach(point -> { FRAME_MAP.forEach(point -> {
BlockPos pos = framePos.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.isOf(FRAME) && state.get(ACTIVE)) { if (state.isOf(FRAME) && state.get(ACTIVE)) {
world.setBlockState(pos, state.with(ACTIVE, false)); world.setBlockState(pos, state.with(ACTIVE, false));
} }
pos = framePos.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
state = world.getBlockState(pos); state = world.getBlockState(pos);
if (state.isOf(FRAME) && state.get(ACTIVE)) { if (state.isOf(FRAME) && state.get(ACTIVE)) {
world.setBlockState(pos, state.with(ACTIVE, false)); world.setBlockState(pos, state.with(ACTIVE, false));
} }
}); });
PORTAL_MAP.forEach(point -> { PORTAL_MAP.forEach(point -> {
BlockPos pos = center.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
if (world.getBlockState(pos).isOf(PORTAL)) { if (world.getBlockState(pos).isOf(PORTAL)) {
world.removeBlock(pos, false); world.removeBlock(pos, false);
} }
pos = center.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
if (world.getBlockState(pos).isOf(PORTAL)) { if (world.getBlockState(pos).isOf(PORTAL)) {
world.removeBlock(pos, false); world.removeBlock(pos, false);
} }
@ -272,7 +270,7 @@ public class EternalRitual {
if (targetWorld.getRegistryKey() == World.END) { if (targetWorld.getRegistryKey() == World.END) {
ConfiguredFeatures.END_ISLAND.generate(targetWorld, targetWorld.getChunkManager().getChunkGenerator(), new Random(basePos.asLong()), basePos.down()); ConfiguredFeatures.END_ISLAND.generate(targetWorld, targetWorld.getChunkManager().getChunkGenerator(), new Random(basePos.asLong()), basePos.down());
} else { } else {
basePos.setY(targetWorld.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, basePos.getX(), basePos.getZ())); basePos.setY(targetWorld.getChunk(basePos).sampleHeightmap(Heightmap.Type.WORLD_SURFACE, basePos.getX(), basePos.getZ()) + 1);
} }
EternalRitual.generatePortal(targetWorld, basePos, portalAxis); EternalRitual.generatePortal(targetWorld, basePos, portalAxis);
if (portalAxis.equals(Direction.Axis.X)) { if (portalAxis.equals(Direction.Axis.X)) {
@ -327,16 +325,16 @@ public class EternalRitual {
Direction moveDir = Direction.Axis.X == axis ? Direction.EAST: Direction.NORTH; Direction moveDir = Direction.Axis.X == axis ? Direction.EAST: Direction.NORTH;
BlockState frame = FRAME.getDefaultState().with(ACTIVE, true); BlockState frame = FRAME.getDefaultState().with(ACTIVE, true);
FRAME_MAP.forEach(point -> { FRAME_MAP.forEach(point -> {
BlockPos pos = framePos.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = framePos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
world.setBlockState(pos, frame); world.setBlockState(pos, frame);
pos = framePos.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = framePos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
world.setBlockState(pos, frame); world.setBlockState(pos, frame);
}); });
BlockState portal = PORTAL.getDefaultState().with(EndPortalBlock.AXIS, axis); BlockState portal = PORTAL.getDefaultState().with(EndPortalBlock.AXIS, axis);
PORTAL_MAP.forEach(point -> { PORTAL_MAP.forEach(point -> {
BlockPos pos = center.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = center.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
world.setBlockState(pos, portal); world.setBlockState(pos, portal);
pos = center.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = center.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
world.setBlockState(pos, portal); world.setBlockState(pos, portal);
}); });
generateBase(world, framePos, moveDir); generateBase(world, framePos, moveDir);
@ -346,13 +344,13 @@ public class EternalRitual {
BlockState base = BASE.getDefaultState(); BlockState base = BASE.getDefaultState();
Direction moveY = moveX.rotateYClockwise(); Direction moveY = moveX.rotateYClockwise();
BASE_MAP.forEach(point -> { BASE_MAP.forEach(point -> {
BlockPos pos = center.offset(moveX, point.x).offset(moveY, point.y); BlockPos pos = center.mutableCopy().move(moveX, point.x).move(moveY, point.y);
world.setBlockState(pos, base); world.setBlockState(pos, base);
pos = center.offset(moveX, -point.x).offset(moveY, point.y); pos = center.mutableCopy().move(moveX, -point.x).move(moveY, point.y);
world.setBlockState(pos, base); world.setBlockState(pos, base);
pos = center.offset(moveX, point.x).offset(moveY, -point.y); pos = center.mutableCopy().move(moveX, point.x).move(moveY, -point.y);
world.setBlockState(pos, base); world.setBlockState(pos, base);
pos = center.offset(moveX, -point.x).offset(moveY, -point.y); pos = center.mutableCopy().move(moveX, -point.x).move(moveY, -point.y);
world.setBlockState(pos, base); world.setBlockState(pos, base);
}); });
} }
@ -361,9 +359,9 @@ public class EternalRitual {
Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST; Direction moveDir = Direction.Axis.X == axis ? Direction.NORTH: Direction.EAST;
for (BlockPos checkPos : BlockPos.iterate(center.offset(moveDir.rotateYClockwise()), center.offset(moveDir.rotateYCounterclockwise()))) { for (BlockPos checkPos : BlockPos.iterate(center.offset(moveDir.rotateYClockwise()), center.offset(moveDir.rotateYCounterclockwise()))) {
for (Point point : PORTAL_MAP) { for (Point point : PORTAL_MAP) {
BlockPos pos = checkPos.offset(moveDir, point.x).offset(Direction.UP, point.y); BlockPos pos = checkPos.mutableCopy().move(moveDir, point.x).move(Direction.UP, point.y);
if (!world.getBlockState(pos).isAir()) return false; if (!world.getBlockState(pos).isAir()) return false;
pos = checkPos.offset(moveDir, -point.x).offset(Direction.UP, point.y); pos = checkPos.mutableCopy().move(moveDir, -point.x).move(Direction.UP, point.y);
if (!world.getBlockState(pos).isAir()) return false; if (!world.getBlockState(pos).isAir()) return false;
} }
} }
@ -452,7 +450,7 @@ public class EternalRitual {
private boolean isActive(BlockPos pos) { private boolean isActive(BlockPos pos) {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.isOf(PEDESTAL)) { if (state.isOf(PEDESTAL)) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) world.getBlockEntity(pos); EternalPedestalEntity pedestal = (EternalPedestalEntity) world.getBlockEntity(pos);
if (!pedestal.hasRitual()) { if (!pedestal.hasRitual()) {
pedestal.linkRitual(this); pedestal.linkRitual(this);
} }

View file

@ -0,0 +1,60 @@
package ru.betterend.rituals;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Tickable;
public class InfusionRitual implements Tickable, Inventory {
@Override
public void tick() {
// TODO
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
@Override
public int size() {
return 9;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public ItemStack getStack(int slot) {
return null;
}
@Override
public ItemStack removeStack(int slot, int amount) {
return null;
}
@Override
public ItemStack removeStack(int slot) {
return null;
}
@Override
public void setStack(int slot, ItemStack stack) {
// TODO
}
@Override
public void markDirty() {
// TODO
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
return false;
}
}