status effects added
Wenn man den Block benutzt kriegt man jetzt einen tollen Statuseffekt
This commit is contained in:
parent
8d79df62a3
commit
816f2bbcd0
|
@ -46,23 +46,28 @@ public class modBlocks {
|
|||
modItemGroup.modchest);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package modchest.event;
|
|||
import modchest.block.custom.suspiciousBlocks.suspiciousBlock;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
|
@ -17,7 +21,21 @@ public class useBlockCallback implements UseBlockCallback {
|
|||
BlockPos pos = hitResult.getBlockPos();
|
||||
BlockState state = world.getBlockState(hitResult.getBlockPos());
|
||||
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 (hitResultString.equals("Block{modchest:suspicious_block}") ||
|
||||
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_sieben}")) {
|
||||
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
|
||||
.getStateFromRawId(suspiciousBlock.getRawIdFromState(state) + 1)); // sorgt dafür, dass
|
||||
// der suspicious
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "modchest:suspicious_block"
|
||||
"item": "modchest:suspicious_block",
|
||||
"count": 8
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue