status effects added

Wenn man den Block benutzt kriegt man jetzt einen tollen Statuseffekt
This commit is contained in:
Paula 2024-07-14 12:56:48 +02:00
parent 8d79df62a3
commit 816f2bbcd0
3 changed files with 35 additions and 8 deletions

View File

@ -46,23 +46,28 @@ public class modBlocks {
modItemGroup.modchest); modItemGroup.modchest);
suspicious_block_minus_drei = registerBlock("suspicious_block_minus_drei", suspicious_block_minus_drei = registerBlock("suspicious_block_minus_drei",
new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()), new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()
.nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
suspicious_block_minus_vier = registerBlock("suspicious_block_minus_vier", suspicious_block_minus_vier = registerBlock("suspicious_block_minus_vier",
new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()), new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()
.nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
suspicious_block_minus_fuenf = registerBlock("suspicious_block_minus_fuenf", suspicious_block_minus_fuenf = registerBlock("suspicious_block_minus_fuenf",
new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()), new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()
.nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
suspicious_block_minus_sechs = registerBlock("suspicious_block_minus_sechs", suspicious_block_minus_sechs = registerBlock("suspicious_block_minus_sechs",
new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()), new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()
.nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
suspicious_block_minus_sieben = registerBlock("suspicious_block_minus_sieben", suspicious_block_minus_sieben = registerBlock("suspicious_block_minus_sieben",
new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()), new suspiciousBlock(FabricBlockSettings.of(Material.SPONGE).strength(1.0f).requiresTool()
.nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
} }

View File

@ -3,7 +3,11 @@ package modchest.event;
import modchest.block.custom.suspiciousBlocks.suspiciousBlock; import modchest.block.custom.suspiciousBlocks.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.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@ -17,7 +21,21 @@ public class useBlockCallback implements UseBlockCallback {
BlockPos pos = hitResult.getBlockPos(); BlockPos pos = hitResult.getBlockPos();
BlockState state = world.getBlockState(hitResult.getBlockPos()); BlockState state = world.getBlockState(hitResult.getBlockPos());
String hitResultString = state.getBlock().toString(); String hitResultString = state.getBlock().toString();
StatusEffect[] statusArray = {
StatusEffects.ABSORPTION, StatusEffects.BAD_OMEN, StatusEffects.BLINDNESS,
StatusEffects.CONDUIT_POWER, StatusEffects.DARKNESS, StatusEffects.DOLPHINS_GRACE,
StatusEffects.FIRE_RESISTANCE, StatusEffects.GLOWING, StatusEffects.HASTE, StatusEffects.HEALTH_BOOST,
StatusEffects.HERO_OF_THE_VILLAGE, StatusEffects.HUNGER, StatusEffects.INSTANT_DAMAGE,
StatusEffects.INSTANT_HEALTH, StatusEffects.INVISIBILITY, StatusEffects.JUMP_BOOST,
StatusEffects.LEVITATION, StatusEffects.LUCK, StatusEffects.MINING_FATIGUE, StatusEffects.NAUSEA,
StatusEffects.NIGHT_VISION, StatusEffects.POISON, StatusEffects.REGENERATION, StatusEffects.RESISTANCE,
StatusEffects.SATURATION, StatusEffects.SLOWNESS, StatusEffects.SLOW_FALLING, StatusEffects.SPEED,
StatusEffects.STRENGTH, StatusEffects.UNLUCK, StatusEffects.WATER_BREATHING, StatusEffects.WEAKNESS,
StatusEffects.WITHER};
int randomNumber = (int)(Math.random() * 33);
StatusEffectInstance effect = new StatusEffectInstance(statusArray[randomNumber]);
//Random random = new Random(statusArray.length);
if (player.getMainHandStack().getItem().equals(Items.BOWL)) { if (player.getMainHandStack().getItem().equals(Items.BOWL)) {
if (hitResultString.equals("Block{modchest:suspicious_block}") || if (hitResultString.equals("Block{modchest:suspicious_block}") ||
hitResultString.equals("Block{modchest:suspicious_block_minus_eins}") || hitResultString.equals("Block{modchest:suspicious_block_minus_eins}") ||
@ -29,7 +47,10 @@ public class useBlockCallback implements UseBlockCallback {
hitResultString.equals("Block{modchest:suspicious_block_minus_sechs}") || hitResultString.equals("Block{modchest:suspicious_block_minus_sechs}") ||
hitResultString.equals("Block{modchest:suspicious_block_minus_sieben}")) { hitResultString.equals("Block{modchest:suspicious_block_minus_sieben}")) {
player.getMainHandStack().decrement(1); // sonst unendlich viel Schüsseln, auch nicht schlecht player.getMainHandStack().decrement(1); // sonst unendlich viel Schüsseln, auch nicht schlecht
player.giveItemStack(Items.SUSPICIOUS_STEW.getDefaultStack()); ItemStack stewStack = Items.SUSPICIOUS_STEW.getDefaultStack();
player.giveItemStack(stewStack);
//player.addStatusEffect(StatusEffectInstance.class.cast(/*statusArray[randomNumber]*/StatusEffects.ABSORPTION));
player.addStatusEffect(effect);
world.setBlockState(pos, suspiciousBlock world.setBlockState(pos, suspiciousBlock
.getStateFromRawId(suspiciousBlock.getRawIdFromState(state) + 1)); // sorgt dafür, dass .getStateFromRawId(suspiciousBlock.getRawIdFromState(state) + 1)); // sorgt dafür, dass
// der suspicious // der suspicious
@ -42,4 +63,4 @@ public class useBlockCallback implements UseBlockCallback {
} }
return ActionResult.PASS; return ActionResult.PASS;
} }
} }

View File

@ -14,6 +14,7 @@
} }
}, },
"result": { "result": {
"item": "modchest:suspicious_block" "item": "modchest:suspicious_block",
"count": 8
} }
} }