Activation function
This commit is contained in:
parent
c9aacbff2b
commit
3e9195b20b
7 changed files with 38 additions and 4 deletions
|
@ -43,7 +43,10 @@ public class InfusionPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
ActionResult result = ActionResult.FAIL;
|
||||||
|
if (hand != null) {
|
||||||
|
result = super.onUse(state, world, pos, player, hand, hit);
|
||||||
|
}
|
||||||
if (result == ActionResult.SUCCESS) {
|
if (result == ActionResult.SUCCESS) {
|
||||||
if (pedestal != null) {
|
if (pedestal != null) {
|
||||||
if (pedestal.hasRitual()) {
|
if (pedestal.hasRitual()) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,6 +30,7 @@ import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
@ -38,9 +40,11 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.blocks.BlockProperties.PedestalState;
|
import ru.betterend.blocks.BlockProperties.PedestalState;
|
||||||
|
import ru.betterend.blocks.InfusionPedestal;
|
||||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvider {
|
public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvider {
|
||||||
|
@ -110,6 +114,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
|
||||||
ItemStack itemStack = player.getStackInHand(hand);
|
ItemStack itemStack = player.getStackInHand(hand);
|
||||||
if (itemStack.isEmpty()) return ActionResult.CONSUME;
|
if (itemStack.isEmpty()) return ActionResult.CONSUME;
|
||||||
pedestal.setStack(0, itemStack.split(1));
|
pedestal.setStack(0, itemStack.split(1));
|
||||||
|
activate(world, pos, player, hand, hit);
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemStack = pedestal.getStack(0);
|
ItemStack itemStack = pedestal.getStack(0);
|
||||||
|
@ -123,6 +128,21 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void activate(World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
Mutable mut = new Mutable();
|
||||||
|
Point[] points = InfusionRitual.getMap();
|
||||||
|
for (Point p: points) {
|
||||||
|
mut.set(pos).move(p.x, 0, p.y);
|
||||||
|
BlockState state = world.getBlockState(mut);
|
||||||
|
if (state.getBlock() instanceof InfusionPedestal) {
|
||||||
|
ActionResult result = state.getBlock().onUse(state, world, mut, player, null, hit);
|
||||||
|
if (result == ActionResult.SUCCESS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockState getPlacementState(ItemPlacementContext context) {
|
public BlockState getPlacementState(ItemPlacementContext context) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import ru.betterend.particle.InfusionParticleType;
|
||||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||||
|
|
||||||
public class InfusionRitual implements Inventory {
|
public class InfusionRitual implements Inventory {
|
||||||
private static Point[] pedestalsMap = new Point[] {
|
private static final Point[] PEDESTALS_MAP = new Point[] {
|
||||||
new Point(0, 3), new Point(2, 2), new Point(3, 0), new Point(2, -2),
|
new Point(0, 3), new Point(2, 2), new Point(3, 0), new Point(2, -2),
|
||||||
new Point(0, -3), new Point(-2, -2), new Point(-3, 0), new Point(-2, 2)
|
new Point(0, -3), new Point(-2, -2), new Point(-3, 0), new Point(-2, 2)
|
||||||
};
|
};
|
||||||
|
@ -40,6 +40,10 @@ public class InfusionRitual implements Inventory {
|
||||||
this.configure();
|
this.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Point[] getMap() {
|
||||||
|
return PEDESTALS_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
public void configure() {
|
public void configure() {
|
||||||
if (world == null || world.isClient || worldPos == null) return;
|
if (world == null || world.isClient || worldPos == null) return;
|
||||||
BlockEntity inputEntity = world.getBlockEntity(worldPos);
|
BlockEntity inputEntity = world.getBlockEntity(worldPos);
|
||||||
|
@ -47,7 +51,7 @@ public class InfusionRitual implements Inventory {
|
||||||
this.input = (InfusionPedestalEntity) inputEntity;
|
this.input = (InfusionPedestalEntity) inputEntity;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Point point : pedestalsMap) {
|
for(Point point : PEDESTALS_MAP) {
|
||||||
BlockPos.Mutable checkPos = worldPos.mutableCopy().move(Direction.EAST, point.x).move(Direction.NORTH, point.y);
|
BlockPos.Mutable checkPos = worldPos.mutableCopy().move(Direction.EAST, point.x).move(Direction.NORTH, point.y);
|
||||||
BlockEntity catalystEntity = world.getBlockEntity(checkPos);
|
BlockEntity catalystEntity = world.getBlockEntity(checkPos);
|
||||||
if (catalystEntity instanceof PedestalBlockEntity) {
|
if (catalystEntity instanceof PedestalBlockEntity) {
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
"layers": [
|
"layers": [
|
||||||
{
|
{
|
||||||
"vertexSource": "canvas:shaders/material/default.vert",
|
"vertexSource": "canvas:shaders/material/default.vert",
|
||||||
"fragmentSource": "betterend:shaders/material/glow_green.frag"
|
"fragmentSource": "betterend:shaders/material/glow_green.frag",
|
||||||
|
"disableAo": true,
|
||||||
|
"disableDiffuse": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"__comment": "Box1",
|
"__comment": "Box1",
|
||||||
"from": [ 6, 0, 6 ],
|
"from": [ 6, 0, 6 ],
|
||||||
"to": [ 10, 1, 10 ],
|
"to": [ 10, 1, 10 ],
|
||||||
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },
|
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },
|
||||||
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },
|
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"__comment": "Box1",
|
"__comment": "Box1",
|
||||||
"from": [ 6, 15, 6 ],
|
"from": [ 6, 15, 6 ],
|
||||||
"to": [ 10, 16, 10 ],
|
"to": [ 10, 16, 10 ],
|
||||||
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },
|
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },
|
||||||
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },
|
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"__comment": "Box3",
|
"__comment": "Box3",
|
||||||
"from": [ 7, 3, 0 ],
|
"from": [ 7, 3, 0 ],
|
||||||
"to": [ 9, 5, 3 ],
|
"to": [ 9, 5, 3 ],
|
||||||
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 0, 8, 2, 11 ], "texture": "#texture" },
|
"down": { "uv": [ 0, 8, 2, 11 ], "texture": "#texture" },
|
||||||
"up": { "uv": [ 0, 11, 2, 8 ], "texture": "#texture" },
|
"up": { "uv": [ 0, 11, 2, 8 ], "texture": "#texture" },
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
"__comment": "Box4",
|
"__comment": "Box4",
|
||||||
"from": [ 3, 6, 1 ],
|
"from": [ 3, 6, 1 ],
|
||||||
"to": [ 5, 9, 3 ],
|
"to": [ 5, 9, 3 ],
|
||||||
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
||||||
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
"__comment": "Box4",
|
"__comment": "Box4",
|
||||||
"from": [ 11, 6, 1 ],
|
"from": [ 11, 6, 1 ],
|
||||||
"to": [ 13, 9, 3 ],
|
"to": [ 13, 9, 3 ],
|
||||||
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
||||||
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue