Merge pull request #722 from fxmorin/master
Added Rule `lightningKillsDrops`
This commit is contained in:
2 files changed
+20
No files matched your search
@@ -857,4 +857,11 @@ public class CarpetSettings
|
||||
validate = Validator.NONNEGATIVE_NUMBER.class
|
||||
)
|
||||
public static double structureBlockOutlineDistance = 96d;
|
||||
|
||||
@Rule(
|
||||
desc = "Lightning kills the items that drop when lightning kills an entity",
|
||||
extra = {"Setting to true will prevent lightning from killing drops", "Fixes (https://bugs.mojang.com/browse/MC-195640)."},
|
||||
category = {BUGFIX}
|
||||
)
|
||||
public static boolean lightningKillsDropsFix = false;
|
||||
}
|
||||
@@ -7,8 +7,10 @@ import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -29,6 +31,17 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(ServerWorld world, LightningEntity lightning) {
|
||||
if (CarpetSettings.lightningKillsDropsFix) {
|
||||
if (this.age > 8) { //Only kill item if its older then 8 ticks
|
||||
super.onStruckByLightning(world, lightning);
|
||||
}
|
||||
} else {
|
||||
super.onStruckByLightning(world, lightning);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAgeCM() {
|
||||
return this.age;
|
||||
|
||||
Reference in new issue
Block a user