recipe added
Der Block kann jetzt am Crafting table erstellt werden + useBlockCallback ist jetzt einfacher
This commit is contained in:
parent
6214c2c6b7
commit
e8fadaa2d5
|
@ -1,6 +1,11 @@
|
||||||
package modchest.block.custom;
|
package modchest.block.custom;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class suspiciousBlock extends Block {
|
public class suspiciousBlock extends Block {
|
||||||
|
|
||||||
|
@ -8,4 +13,25 @@ public class suspiciousBlock extends Block {
|
||||||
super(settings);
|
super(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public void onNeighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||||
|
if (this.isInContactWithWater(world, pos)) {
|
||||||
|
// Wenn Lava mit Wasser in Kontakt kommt, bestimmen wir, welcher Block entsteht.
|
||||||
|
Block blockToCreate = this.getBlockToCreate(world, pos);
|
||||||
|
world.setBlockState(pos, blockToCreate.getDefaultState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Block getBlockToCreate(World world, BlockPos pos) {
|
||||||
|
// Prüfen, ob die Lavaquelle stationär ist oder fließt.
|
||||||
|
boolean isSource = world.getBlockState(pos).getFluidState(). == 0;
|
||||||
|
if (isSource) {
|
||||||
|
return Blocks.OBSIDIAN;
|
||||||
|
} else {
|
||||||
|
return Blocks.COBBLESTONE;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package modchest.event;
|
package modchest.event;
|
||||||
|
|
||||||
import modchest.block.custom.suspiciousBlockMinusEins;
|
import modchest.block.custom.suspiciousBlock;
|
||||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
@ -17,111 +16,30 @@ public class useBlockCallback implements UseBlockCallback {
|
||||||
public ActionResult interact(PlayerEntity player, World world, Hand hand, BlockHitResult hitResult) {
|
public ActionResult interact(PlayerEntity player, World world, Hand hand, BlockHitResult hitResult) {
|
||||||
BlockPos pos = hitResult.getBlockPos();
|
BlockPos pos = hitResult.getBlockPos();
|
||||||
BlockState state = world.getBlockState(hitResult.getBlockPos());
|
BlockState state = world.getBlockState(hitResult.getBlockPos());
|
||||||
|
String hitResultString = world.getBlockState(hitResult.getBlockPos()).getBlock().toString();
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
||||||
player.getMainHandStack().decrement(1);
|
if (hitResultString.equals("Block{modchest:suspicious_block}") ||
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
hitResultString.equals("Block{modchest:suspicious_block_minus_eins}") ||
|
||||||
int stateId = suspiciousBlockMinusEins.getRawIdFromState(state);
|
hitResultString.equals("Block{modchest:suspicious_block_minus_zwei}") ||
|
||||||
BlockState stateSus = suspiciousBlockMinusEins.getStateFromRawId(stateId + 1);
|
hitResultString.equals("Block{modchest:suspicious_block_minus_zwei}") ||
|
||||||
// BlockState susState = hitResult.getClass().;
|
hitResultString.equals("Block{modchest:suspicious_block_minus_drei}") ||
|
||||||
world.setBlockState(pos, stateSus);
|
hitResultString.equals("Block{modchest:suspicious_block_minus_vier}") ||
|
||||||
|
hitResultString.equals("Block{modchest:suspicious_block_minus_fuenf}") ||
|
||||||
|
hitResultString.equals("Block{modchest:suspicious_block_minus_sechs}") ||
|
||||||
|
hitResultString.equals("Block{modchest:suspicious_block_minus_sieben}")) {
|
||||||
|
player.getMainHandStack().decrement(1); // sonst unendlich viel Schüsseln, auch nicht schlecht
|
||||||
|
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack());
|
||||||
|
world.setBlockState(pos, suspiciousBlock
|
||||||
|
.getStateFromRawId(suspiciousBlock.getRawIdFromState(state) + 1)); // sorgt dafür, dass
|
||||||
|
// der suspicious
|
||||||
|
// Block um eins
|
||||||
|
// kleiner wird wenn
|
||||||
|
// man ihn mit der
|
||||||
|
// Schüssel benutzt
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_eins}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId1 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus1 = suspiciousBlockMinusEins.getStateFromRawId(stateId1 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus1);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_zwei}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId2 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus2 = suspiciousBlockMinusEins.getStateFromRawId(stateId2 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus2);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_drei}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId3 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus3 = suspiciousBlockMinusEins.getStateFromRawId(stateId3 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus3);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_vier}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId4 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus4 = suspiciousBlockMinusEins.getStateFromRawId(stateId4 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus4);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_fuenf}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId5 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus5 = suspiciousBlockMinusEins.getStateFromRawId(stateId5 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus5);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_sechs}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
int stateId6 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
BlockState stateSus6 = suspiciousBlockMinusEins.getStateFromRawId(stateId6 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
world.setBlockState(pos, stateSus6);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockState(hitResult.getBlockPos()).getBlock().toString()
|
|
||||||
.equals("Block{modchest:suspicious_block_minus_sieben}")) {
|
|
||||||
if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); // bis hierhin ok
|
|
||||||
//int stateId7 = suspiciousBlockMinusEins.getRawIdFromState(state);
|
|
||||||
//BlockState stateSus7 = suspiciousBlockMinusEins.getStateFromRawId(stateId7 + 1);
|
|
||||||
// BlockState susState = hitResult.getClass().;
|
|
||||||
BlockState stateAir = Blocks.AIR.getDefaultState();
|
|
||||||
world.setBlockState(pos, stateAir);
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.getMainHandStack().decrement(1);
|
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"MMM",
|
||||||
|
"M#M",
|
||||||
|
"MMM"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"M":{
|
||||||
|
"item": "minecraft:honeycomb_block"
|
||||||
|
},
|
||||||
|
|
||||||
|
"#":{
|
||||||
|
"item": "minecraft:water_bucket"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"result": {
|
||||||
|
"item": "modchest:suspicious_block"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue