Different item keys (WIP)

This commit is contained in:
paulevsGitch 2021-02-19 18:24:44 +03:00
parent 269821dee8
commit 2fabb39f41
4 changed files with 54 additions and 22 deletions

View file

@ -87,6 +87,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
MinecraftServer server = ((ServerWorld) world).getServer();
ServerWorld destination = isOverworld ? server.getWorld(World.END) : EndPortals.getWorld(server, state.get(PORTAL));
BlockPos exitPos = this.findExitPos(destination, pos, entity);
System.out.println(exitPos);
if (exitPos == null) return;
if (entity instanceof ServerPlayerEntity) {
ServerPlayerEntity player = (ServerPlayerEntity) entity;
@ -124,7 +125,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
Registry<DimensionType> registry = world.getRegistryManager().getDimensionTypes();
double mult = Objects.requireNonNull(registry.get(DimensionType.THE_END_ID)).getCoordinateScale();
BlockPos.Mutable basePos;
if (world.getRegistryKey().equals(World.OVERWORLD)) {
if (!world.getRegistryKey().equals(World.END)) {
basePos = pos.mutableCopy().set(pos.getX() / mult, pos.getY(), pos.getZ() / mult);
} else {
basePos = pos.mutableCopy().set(pos.getX() * mult, pos.getY(), pos.getZ() * mult);

View file

@ -9,13 +9,16 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
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.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
@ -23,7 +26,7 @@ import net.minecraft.world.explosion.Explosion;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.EternalPedestalEntity;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndPortals;
import ru.betterend.rituals.EternalRitual;
public class EternalPedestal extends PedestalBlock {
@ -43,12 +46,15 @@ public class EternalPedestal extends PedestalBlock {
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
if (pedestal.hasRitual()) {
EternalRitual ritual = pedestal.getRitual();
ritual.removePortal();
Item item = pedestal.getStack(0).getItem();
int dim = EndPortals.getPortalState(Registry.ITEM.getId(item));
ritual.removePortal(dim);
}
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
} else {
ItemStack itemStack = pedestal.getStack(0);
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
Identifier id = Registry.ITEM.getId(itemStack.getItem());
if (EndPortals.isAvailableItem(id)) {
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
if (pedestal.hasRitual()) {
pedestal.getRitual().checkStructure();