WIP: eternal portals
This commit is contained in:
parent
29ea99ae11
commit
74403c297a
4 changed files with 75 additions and 4 deletions
56
src/main/java/ru/betterend/blocks/EternalPedestal.java
Normal file
56
src/main/java/ru/betterend/blocks/EternalPedestal.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.loot.context.LootContext;
|
||||||
|
import net.minecraft.state.StateManager;
|
||||||
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.explosion.Explosion;
|
||||||
|
|
||||||
|
import ru.betterend.blocks.basis.BlockSlab;
|
||||||
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
|
||||||
|
public class EternalPedestal extends BlockSlab {
|
||||||
|
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
|
||||||
|
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
|
||||||
|
|
||||||
|
public EternalPedestal() {
|
||||||
|
super(BlockRegistry.FLAVOLITE_RUNED_ETERNAL);
|
||||||
|
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false).with(HAS_ITEM, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||||
|
return 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getBlastResistance() {
|
||||||
|
return Blocks.BEDROCK.getBlastResistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||||
|
super.appendProperties(stateManager);
|
||||||
|
stateManager.add(ACTIVATED, HAS_ITEM);
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ public class RunedFlavolite extends BlockBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
|
super.onBreak(world, pos, state, player);
|
||||||
BlockPos bottom = PortalFrameHelper.findBottomCorner((World) world, pos, this);
|
BlockPos bottom = PortalFrameHelper.findBottomCorner((World) world, pos, this);
|
||||||
BlockPos top = PortalFrameHelper.findTopCorner((World) world, pos, this);
|
BlockPos top = PortalFrameHelper.findTopCorner((World) world, pos, this);
|
||||||
if (bottom == null || top == null) return;
|
if (bottom == null || top == null) return;
|
||||||
|
@ -43,6 +44,5 @@ public class RunedFlavolite extends BlockBase {
|
||||||
world.removeBlock(position, false);
|
world.removeBlock(position, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onBreak(world, pos, state, player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package ru.betterend.item;
|
package ru.betterend.item;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.entity.decoration.EndCrystalEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemUsageContext;
|
import net.minecraft.item.ItemUsageContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import ru.betterend.blocks.EternalPedestal;
|
||||||
import ru.betterend.blocks.RunedFlavolite;
|
import ru.betterend.blocks.RunedFlavolite;
|
||||||
import ru.betterend.registry.ItemRegistry;
|
import ru.betterend.registry.ItemRegistry;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.PortalFrameHelper;
|
import ru.betterend.util.PortalFrameHelper;
|
||||||
|
|
||||||
public class EternalCrystal extends Item {
|
public class EternalCrystal extends Item {
|
||||||
|
@ -21,9 +24,19 @@ public class EternalCrystal extends Item {
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
BlockPos usedPos = context.getBlockPos();
|
BlockPos usedPos = context.getBlockPos();
|
||||||
BlockState usedBlock = world.getBlockState(usedPos);
|
BlockState usedBlock = world.getBlockState(usedPos);
|
||||||
if (world instanceof ServerWorld && (usedBlock.getBlock() instanceof RunedFlavolite) && !usedBlock.get(RunedFlavolite.ACTIVATED)) {
|
if (world instanceof ServerWorld) {
|
||||||
PortalFrameHelper.checkPortalFrame((ServerWorld) world, usedPos, usedBlock.getBlock());
|
if (usedBlock.getBlock() instanceof RunedFlavolite && !usedBlock.get(RunedFlavolite.ACTIVATED)) {
|
||||||
|
if (PortalFrameHelper.checkPortalFrame((ServerWorld) world, usedPos, usedBlock.getBlock())) {
|
||||||
|
return ActionResult.PASS;
|
||||||
|
}
|
||||||
|
} else if (usedBlock.getBlock() instanceof EternalPedestal && !usedBlock.get(EternalPedestal.HAS_ITEM)) {
|
||||||
|
BlockPos upPos = usedPos.up();
|
||||||
|
EndCrystalEntity endCrystalEntity = new EndCrystalEntity(world, upPos.getX() + 0.5D, upPos.getY(), upPos.getZ() + 0.5D);
|
||||||
|
endCrystalEntity.setShowBottom(false);
|
||||||
|
world.spawnEntity(endCrystalEntity);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, usedPos, usedBlock.with(EternalPedestal.HAS_ITEM, true).with(EternalPedestal.ACTIVATED, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import ru.betterend.blocks.BlockUmbrellaMossTall;
|
||||||
import ru.betterend.blocks.EndPortalBlock;
|
import ru.betterend.blocks.EndPortalBlock;
|
||||||
import ru.betterend.blocks.EndStoneSmelter;
|
import ru.betterend.blocks.EndStoneSmelter;
|
||||||
import ru.betterend.blocks.EnderBlock;
|
import ru.betterend.blocks.EnderBlock;
|
||||||
|
import ru.betterend.blocks.EternalPedestal;
|
||||||
import ru.betterend.blocks.EternalRunedFlavolite;
|
import ru.betterend.blocks.EternalRunedFlavolite;
|
||||||
import ru.betterend.blocks.RunedFlavolite;
|
import ru.betterend.blocks.RunedFlavolite;
|
||||||
import ru.betterend.blocks.TerminiteBlock;
|
import ru.betterend.blocks.TerminiteBlock;
|
||||||
|
@ -117,6 +118,7 @@ public class BlockRegistry {
|
||||||
|
|
||||||
// Blocks With Entity //
|
// Blocks With Entity //
|
||||||
public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter());
|
public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter());
|
||||||
|
public static final Block ETERNAL_PEDESTAL = registerBlock("eternal_pedestal", new EternalPedestal());
|
||||||
|
|
||||||
//Technical
|
//Technical
|
||||||
public static final Block END_PORTAL_BLOCK = registerBlock("end_portal_block", new EndPortalBlock());
|
public static final Block END_PORTAL_BLOCK = registerBlock("end_portal_block", new EndPortalBlock());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue