Added zap fence and zap fence gate

This commit is contained in:
Sollace 2024-02-08 19:56:41 +00:00
parent 400bc19d08
commit 5ed68fca7f
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
38 changed files with 682 additions and 74 deletions

View file

@ -22,6 +22,8 @@ import com.minelittlepony.unicopia.block.cloud.SoggyCloudSlabBlock;
import com.minelittlepony.unicopia.block.cloud.SoggyCloudStairsBlock;
import com.minelittlepony.unicopia.block.cloud.UnstableCloudBlock;
import com.minelittlepony.unicopia.block.zap.BaseZapAppleLeavesBlock;
import com.minelittlepony.unicopia.block.zap.ElectrifiedFenceBlock;
import com.minelittlepony.unicopia.block.zap.ElectrifiedFenceGateBlock;
import com.minelittlepony.unicopia.block.zap.ZapAppleLeavesBlock;
import com.minelittlepony.unicopia.block.zap.ZapAppleLeavesPlaceholderBlock;
import com.minelittlepony.unicopia.block.zap.ZapAppleLogBlock;
@ -67,10 +69,10 @@ public interface UBlocks {
Block FROSTED_OBSIDIAN = register("frosted_obsidian", new FrostedObsidianBlock(FabricBlockSettings.copy(Blocks.OBSIDIAN).ticksRandomly()));
Block ZAP_LOG = register("zap_log", new ZapAppleLogBlock(Blocks.OAK_LOG, UMapColors.ZAP_LOG_END, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block ZAP_WOOD = register("zap_wood", new ZapAppleLogBlock(Blocks.OAK_WOOD, UMapColors.ZAP_LOG_SIDE, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block STRIPPED_ZAP_LOG = register("stripped_zap_log", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_LOG, UMapColors.ZAP_LOG_END, UMapColors.STRIPPED_ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block STRIPPED_ZAP_WOOD = register("stripped_zap_wood", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_WOOD, UMapColors.STRIPPED_ZAP_LOG_SIDE, UMapColors.STRIPPED_ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block ZAP_LOG = register("zap_log", new ZapAppleLogBlock(Blocks.OAK_LOG.getDefaultState(), UMapColors.ZAP_LOG_END, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block ZAP_WOOD = register("zap_wood", new ZapAppleLogBlock(Blocks.OAK_WOOD.getDefaultState(), UMapColors.ZAP_LOG_SIDE, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block STRIPPED_ZAP_LOG = register("stripped_zap_log", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_LOG.getDefaultState(), UMapColors.ZAP_LOG_END, UMapColors.STRIPPED_ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block STRIPPED_ZAP_WOOD = register("stripped_zap_wood", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_WOOD.getDefaultState(), UMapColors.STRIPPED_ZAP_LOG_SIDE, UMapColors.STRIPPED_ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_LOG = register("waxed_zap_log", BlockConstructionUtils.createLogBlock(UMapColors.ZAP_LOG_END, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_WOOD = register("waxed_zap_wood", BlockConstructionUtils.createLogBlock(UMapColors.ZAP_LOG_SIDE, UMapColors.ZAP_LOG_SIDE), ItemGroups.BUILDING_BLOCKS);
@ -80,10 +82,14 @@ public interface UBlocks {
Block ZAP_PLANKS = register("zap_planks", new ZapBlock(Settings.create().mapColor(UMapColors.ZAP_PLANKS).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block ZAP_STAIRS = register("zap_stairs", new ZapStairsBlock(ZAP_PLANKS.getDefaultState(), Settings.copy(ZAP_PLANKS).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block ZAP_SLAB = register("zap_slab", new ZapSlabBlock(Settings.create().mapColor(ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block ZAP_FENCE = register("zap_fence", new ElectrifiedFenceBlock(Settings.create().mapColor(ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block ZAP_FENCE_GATE = register("zap_fence_gate", new ElectrifiedFenceGateBlock(Settings.create().mapColor(ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL), UWoodTypes.ZAP), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_PLANKS = register("waxed_zap_planks", new Block(Settings.create().mapColor(UMapColors.ZAP_PLANKS).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_STAIRS = register("waxed_zap_stairs", new StairsBlock(WAXED_ZAP_PLANKS.getDefaultState(), Settings.copy(WAXED_ZAP_PLANKS).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_SLAB = register("waxed_zap_slab", new ZapSlabBlock(Settings.create().mapColor(WAXED_ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_SLAB = register("waxed_zap_slab", new SlabBlock(Settings.create().mapColor(WAXED_ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_FENCE = register("waxed_zap_fence", new FenceBlock(Settings.create().mapColor(WAXED_ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS);
Block WAXED_ZAP_FENCE_GATE = register("waxed_zap_fence_gate", new FenceGateBlock(Settings.create().mapColor(WAXED_ZAP_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL), UWoodTypes.ZAP), ItemGroups.BUILDING_BLOCKS);
Block ZAP_LEAVES = register("zap_leaves", new ZapAppleLeavesBlock(), ItemGroups.NATURAL);
Block FLOWERING_ZAP_LEAVES = register("flowering_zap_leaves", new BaseZapAppleLeavesBlock(), ItemGroups.NATURAL);
@ -103,7 +109,7 @@ public interface UBlocks {
Block PALM_FENCE_GATE = register("palm_fence_gate", new FenceGateBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL), UWoodTypes.PALM), ItemGroups.BUILDING_BLOCKS);
Block PALM_DOOR = register("palm_door", new DoorBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).instrument(Instrument.BASS).strength(3.0f).nonOpaque().burnable().pistonBehavior(PistonBehavior.DESTROY), UWoodTypes.PALM.setType()), ItemGroups.FUNCTIONAL);
Block PALM_TRAPDOOR = register("palm_trapdoor", new TrapdoorBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).instrument(Instrument.BASS).strength(3).nonOpaque().allowsSpawning(BlockConstructionUtils::never).burnable(), UWoodTypes.PALM.setType()), ItemGroups.FUNCTIONAL);
Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), BlockSetType.OAK), ItemGroups.BUILDING_BLOCKS);
Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), UWoodTypes.PALM.setType()), ItemGroups.BUILDING_BLOCKS);
Block PALM_BUTTON = register("palm_button", BlockConstructionUtils.woodenButton(), ItemGroups.BUILDING_BLOCKS);
Block PALM_SIGN = register("palm_sign", new SignBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).solid().instrument(Instrument.BASS).noCollision().strength(1).burnable().sounds(BlockSoundGroup.WOOD), UWoodTypes.PALM), ItemGroups.FUNCTIONAL);
Block PALM_WALL_SIGN = register("palm_wall_sign", new WallSignBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).solid().instrument(Instrument.BASS).noCollision().strength(1).dropsLike(PALM_SIGN).burnable(), UWoodTypes.PALM));
@ -295,6 +301,8 @@ public interface UBlocks {
OxidizableBlocksRegistry.registerWaxableBlockPair(ZAP_PLANKS, WAXED_ZAP_PLANKS);
OxidizableBlocksRegistry.registerWaxableBlockPair(ZAP_STAIRS, WAXED_ZAP_STAIRS);
OxidizableBlocksRegistry.registerWaxableBlockPair(ZAP_SLAB, WAXED_ZAP_SLAB);
OxidizableBlocksRegistry.registerWaxableBlockPair(ZAP_FENCE, WAXED_ZAP_FENCE);
OxidizableBlocksRegistry.registerWaxableBlockPair(ZAP_FENCE_GATE, WAXED_ZAP_FENCE_GATE);
Collections.addAll(TRANSLUCENT_BLOCKS, WEATHER_VANE, CHITIN_SPIKES, PLUNDER_VINE, PLUNDER_VINE_BUD, CLAM_SHELL, SCALLOP_SHELL, TURRET_SHELL, CURING_JOKE, SPECTRAL_FIRE);
TintedBlock.REGISTRY.add(PALM_LEAVES);
@ -303,14 +311,22 @@ public interface UBlocks {
FlammableBlockRegistry.getDefaultInstance().add(SOUR_APPLE_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(GOLDEN_OAK_LEAVES, 60, 120);
FlammableBlockRegistry.getDefaultInstance().add(MANGO_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(PALM_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(PALM_LOG, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(PALM_WOOD, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(GOLDEN_OAK_LOG, 15, 15);
FlammableBlockRegistry.getDefaultInstance().add(PALM_PLANKS, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_SLAB, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_FENCE_GATE, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_FENCE, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_STAIRS, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_LOG, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(STRIPPED_PALM_LOG, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(STRIPPED_PALM_WOOD, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(PALM_PLANKS, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(PALM_WOOD, 5, 5);
FlammableBlockRegistry.getDefaultInstance().add(PALM_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(BANANAS, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(CURING_JOKE, 60, 100);
UBlockEntities.bootstrap();
EdibleBlock.bootstrap();

View file

@ -15,6 +15,7 @@ import net.minecraft.util.Identifier;
public interface UWoodTypes {
WoodType PALM = register("palm");
WoodType ZAP = register("zap");
WoodType GOLDEN_OAK = register("golden_oak");
RegistryKey<TerraformBoatType> PALM_BOAT_TYPE = TerraformBoatTypeRegistry.createKey(Unicopia.id("palm"));

View file

@ -16,7 +16,7 @@ import net.minecraft.util.math.*;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.*;
public class BaseZapAppleLeavesBlock extends LeavesBlock implements TintedBlock, ZapStagedBlock {
public class BaseZapAppleLeavesBlock extends LeavesBlock implements TintedBlock, ZapStagedBlock, ElectrifiedBlock {
public BaseZapAppleLeavesBlock() {
super(Settings.create()
@ -80,7 +80,7 @@ public class BaseZapAppleLeavesBlock extends LeavesBlock implements TintedBlock,
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
ZapBlock.triggerLightning(state, world, pos, player);
triggerLightning(state, world, pos);
}
@Override

View file

@ -0,0 +1,83 @@
package com.minelittlepony.unicopia.block.zap;
import java.util.Optional;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
public interface ElectrifiedBlock {
default void spawnElectricalParticles(World world, BlockPos pos, Random random) {
world.addParticle(new LightningBoltParticleEffect(true, 10, 1, 0.6F, Optional.empty()),
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
0, 0, 0
);
}
default float getBlockBreakingDelta(float delta, PlayerEntity player) {
if (Pony.of(player).getCompositeRace().canUseEarth()) {
delta *= 50;
}
return MathHelper.clamp(delta, 0, 0.9F);
}
default void triggerLightning(BlockState state, World world, BlockPos pos) {
Vec3d center = pos.toCenterPos();
if (world instanceof ServerWorld serverWorld) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world);
world.getOtherEntities(null, Box.from(center).expand(7)).forEach(entity -> {
shockEntity(serverWorld, center, lightning, entity);
});
}
world.emitGameEvent(GameEvent.LIGHTNING_STRIKE, pos, GameEvent.Emitter.of(state));
ParticleUtils.spawnParticle(world, LightningBoltParticleEffect.DEFAULT, center, Vec3d.ZERO);
}
default void triggerLightning(BlockState state, World world, BlockPos pos, LivingEntity entity, boolean knockBack) {
Vec3d center = pos.toCenterPos();
if (world instanceof ServerWorld serverWorld) {
shockEntity(serverWorld, center, EntityType.LIGHTNING_BOLT.create(world), entity);
}
if (knockBack) {
Vec3d offset = center.subtract(entity.getPos());
entity.takeKnockback(0.8, offset.x, offset.z);
}
world.emitGameEvent(GameEvent.LIGHTNING_STRIKE, pos, GameEvent.Emitter.of(state));
ParticleUtils.spawnParticle(world, LightningBoltParticleEffect.DEFAULT, center, Vec3d.ZERO);
}
private static void shockEntity(ServerWorld serverWorld, Vec3d center, LightningEntity lightning, Entity entity) {
if (entity instanceof ItemEntity) {
return;
}
float dist = (float)entity.getPos().distanceTo(center);
if (dist < 4) {
entity.onStruckByLightning(serverWorld, EntityType.LIGHTNING_BOLT.create(serverWorld));
} else {
float damage = 3 / dist;
if (damage > 1) {
entity.damage(entity.getDamageSources().lightningBolt(), damage);
}
}
}
}

View file

@ -0,0 +1,43 @@
package com.minelittlepony.unicopia.block.zap;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class ElectrifiedFenceBlock extends FenceBlock implements ElectrifiedBlock {
public ElectrifiedFenceBlock(Settings settings) {
super(settings);
}
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);
spawnElectricalParticles(world, pos, random);
}
@Deprecated
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
triggerLightning(state, world, pos);
}
@Deprecated
@Override
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
}
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity l && l.hurtTime == 0 && l.canTakeDamage()) {
triggerLightning(state, world, pos, l, true);
}
}
}

View file

@ -0,0 +1,45 @@
package com.minelittlepony.unicopia.block.zap;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.WoodType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class ElectrifiedFenceGateBlock extends FenceGateBlock implements ElectrifiedBlock {
public ElectrifiedFenceGateBlock(Settings settings, WoodType type) {
super(settings, type);
}
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);
if (!state.get(OPEN)) {
spawnElectricalParticles(world, pos, random);
}
}
@Deprecated
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
triggerLightning(state, world, pos);
}
@Deprecated
@Override
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
}
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (!state.get(OPEN) && entity instanceof LivingEntity l && l.hurtTime == 0 && l.canTakeDamage()) {
triggerLightning(state, world, pos, l, true);
}
}
}

View file

@ -1,7 +1,5 @@
package com.minelittlepony.unicopia.block.zap;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.block.*;
import net.minecraft.block.enums.Instrument;
import net.minecraft.entity.player.PlayerEntity;
@ -13,12 +11,12 @@ import net.minecraft.util.math.*;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class ZapAppleLogBlock extends PillarBlock {
public class ZapAppleLogBlock extends PillarBlock implements ElectrifiedBlock {
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
private final Block artifialModelBlock;
private final BlockState artifialModelBlock;
public ZapAppleLogBlock(Block artifialModelBlock, MapColor topMapColor, MapColor sideMapColor) {
public ZapAppleLogBlock(BlockState artifialModelBlock, MapColor topMapColor, MapColor sideMapColor) {
super(AbstractBlock.Settings.create().mapColor(
state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor
)
@ -44,22 +42,16 @@ public class ZapAppleLogBlock extends PillarBlock {
@Deprecated
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
ZapBlock.triggerLightning(state, world, pos, player);
triggerLightning(state, world, pos);
}
@Deprecated
@Override
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
if (!state.get(NATURAL)) {
return artifialModelBlock.calcBlockBreakingDelta(artifialModelBlock.getDefaultState(), player, world, pos);
return artifialModelBlock.calcBlockBreakingDelta(player, world, pos);
}
float delta = super.calcBlockBreakingDelta(state, player, world, pos);
if (Pony.of(player).getCompositeRace().canUseEarth()) {
delta *= 50;
}
return MathHelper.clamp(delta, 0, 0.9F);
return getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
}
}

View file

@ -1,20 +1,12 @@
package com.minelittlepony.unicopia.block.zap;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.*;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
public class ZapBlock extends Block {
public class ZapBlock extends Block implements ElectrifiedBlock {
public ZapBlock(Settings settings) {
super(settings);
}
@ -22,7 +14,7 @@ public class ZapBlock extends Block {
@Deprecated
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
triggerLightning(state, world, pos, player);
triggerLightning(state, world, pos);
}
@Deprecated
@ -30,35 +22,4 @@ public class ZapBlock extends Block {
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
}
public static float getBlockBreakingDelta(float delta, PlayerEntity player) {
if (Pony.of(player).getCompositeRace().canUseEarth()) {
delta *= 50;
}
return MathHelper.clamp(delta, 0, 0.9F);
}
public static void triggerLightning(BlockState state, World world, BlockPos pos, PlayerEntity player) {
if (world instanceof ServerWorld serverWorld) {
Vec3d center = Vec3d.ofCenter(pos);
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world);
world.getOtherEntities(null, Box.from(center).expand(7)).forEach(other -> {
if (other instanceof ItemEntity) {
return;
}
float dist = (float)other.getPos().distanceTo(center);
if (dist < 4) {
other.onStruckByLightning(serverWorld, lightning);
} else {
float damage = 3 / dist;
if (damage > 1) {
other.damage(world.getDamageSources().lightningBolt(), damage);
}
}
});
}
world.emitGameEvent(GameEvent.LIGHTNING_STRIKE, pos, GameEvent.Emitter.of(state));
ParticleUtils.spawnParticle(world, LightningBoltParticleEffect.DEFAULT, Vec3d.ofCenter(pos), Vec3d.ZERO);
}
}

View file

@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class ZapSlabBlock extends SlabBlock {
public class ZapSlabBlock extends SlabBlock implements ElectrifiedBlock {
public ZapSlabBlock(Settings settings) {
super(settings);
}
@ -15,12 +15,12 @@ public class ZapSlabBlock extends SlabBlock {
@Deprecated
@Override
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
ZapBlock.triggerLightning(state, world, pos, player);
triggerLightning(state, world, pos);
}
@Deprecated
@Override
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return ZapBlock.getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
return getBlockBreakingDelta(super.calcBlockBreakingDelta(state, player, world, pos), player);
}
}

View file

@ -0,0 +1,48 @@
{
"multipart": [
{
"apply": {
"model": "unicopia:block/zap_fence_post"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true
},
"when": {
"north": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 90
},
"when": {
"east": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 180
},
"when": {
"south": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 270
},
"when": {
"west": "true"
}
}
]
}

View file

@ -0,0 +1,80 @@
{
"variants": {
"facing=east,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 270
},
"facing=north,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 180
},
"facing=south,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true
},
"facing=south,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true
},
"facing=south,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true
},
"facing=south,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true
},
"facing=west,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 90
}
}
}

View file

@ -0,0 +1,48 @@
{
"multipart": [
{
"apply": {
"model": "unicopia:block/zap_fence_post"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true
},
"when": {
"north": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 90
},
"when": {
"east": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 180
},
"when": {
"south": "true"
}
},
{
"apply": {
"model": "unicopia:block/zap_fence_side",
"uvlock": true,
"y": 270
},
"when": {
"west": "true"
}
}
]
}

View file

@ -0,0 +1,80 @@
{
"variants": {
"facing=east,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 270
},
"facing=east,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 270
},
"facing=north,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 180
},
"facing=north,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 180
},
"facing=south,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true
},
"facing=south,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true
},
"facing=south,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true
},
"facing=south,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true
},
"facing=west,in_wall=false,open=false": {
"model": "unicopia:block/zap_fence_gate",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=false,open=true": {
"model": "unicopia:block/zap_fence_gate_open",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=true,open=false": {
"model": "unicopia:block/zap_fence_gate_wall",
"uvlock": true,
"y": 90
},
"facing=west,in_wall=true,open=true": {
"model": "unicopia:block/zap_fence_gate_wall_open",
"uvlock": true,
"y": 90
}
}
}

View file

@ -235,6 +235,8 @@
"block.unicopia.zap_planks": "Zap Apple Planks",
"block.unicopia.zap_stairs": "Zap Apple Stairs",
"block.unicopia.zap_slab": "Zap Apple Slab",
"block.unicopia.zap_fence": "Zap Apple Fence",
"block.unicopia.zap_fence_gate": "Zap Apple Fence Gate",
"block.unicopia.waxed_zap_log": "Waxed Zap Apple Log",
"block.unicopia.waxed_zap_wood": "Waxed Zap Apple Wood",
"block.unicopia.waxed_stripped_zap_log": "Waxed Stripped Zap Apple Log",
@ -242,6 +244,8 @@
"block.unicopia.waxed_zap_planks": "Waxed Zap Apple Planks",
"block.unicopia.waxed_zap_stairs": "Waxed Zap Apple Stairs",
"block.unicopia.waxed_zap_slab": "Waxed Zap Apple Slab",
"block.unicopia.waxed_zap_fence": "Waxed Zap Apple Fence",
"block.unicopia.waxed_zap_fence_gate": "Waxed Zap Apple Fence Gate",
"block.unicopia.zap_leaves": "Zap Apple Leaves",
"block.unicopia.flowering_zap_leaves": "Flowering Zap Apple Leaves",
"block.unicopia.zap_apple": "Zap Apple",

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_open",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_wall",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_wall_open",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_inventory",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_post",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_side",
"textures": {
"texture": "unicopia:block/zap_planks"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/zap_fence_inventory"
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/zap_fence_gate"
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/zap_fence_inventory"
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/zap_fence_gate"
}

View file

@ -1,6 +1,8 @@
{
"replace": false,
"values": [
"unicopia:palm_fence_gate"
"unicopia:palm_fence_gate",
"unicopia:zap_fence_gate",
"unicopia:waxed_zap_fence_gate"
]
}

View file

@ -1,6 +1,8 @@
{
"replace": false,
"values": [
"unicopia:palm_fence"
"unicopia:palm_fence",
"unicopia:zap_fence",
"unicopia:waxed_zap_fence"
]
}

View file

@ -1,6 +1,8 @@
{
"replace": false,
"values": [
"unicopia:palm_fence_gate"
"unicopia:palm_fence_gate",
"unicopia:zap_fence_gate",
"unicopia:waxed_zap_fence_gate"
]
}

View file

@ -1,6 +1,8 @@
{
"replace": false,
"values": [
"unicopia:palm_fence"
"unicopia:palm_fence",
"unicopia:zap_fence",
"unicopia:waxed_zap_fence"
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:waxed_zap_fence"
}
],
"rolls": 1.0
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:waxed_zap_fence_gate"
}
],
"rolls": 1.0
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:zap_fence"
}
],
"rolls": 1.0
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:zap_fence_gate"
}
],
"rolls": 1.0
}
]
}

View file

@ -0,0 +1,8 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "unicopia:zap_fence" },
{ "item": "minecraft:honeycomb" }
],
"result": { "item": "unicopia:waxed_zap_fence" }
}

View file

@ -0,0 +1,8 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "unicopia:zap_fence_gate" },
{ "item": "minecraft:honeycomb" }
],
"result": { "item": "unicopia:waxed_zap_fence_gate" }
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"group": "wooden_fence",
"key": {
"#": {
"item": "minecraft:stick"
},
"W": {
"item": "unicopia:zap_planks"
}
},
"pattern": [
"W#W",
"W#W"
],
"result": {
"count": 3,
"item": "unicopia:zap_fence"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"group": "wooden_fence_gate",
"key": {
"#": {
"item": "minecraft:stick"
},
"W": {
"item": "unicopia:zap_planks"
}
},
"pattern": [
"#W#",
"#W#"
],
"result": {
"item": "unicopia:zap_fence_gate"
}
}

View file

@ -10,10 +10,20 @@
"unicopia:zap_wood",
"unicopia:stripped_zap_log",
"unicopia:stripped_zap_wood",
"unicopia:zap_planks",
"unicopia:zap_stairs",
"unicopia:zap_slab",
"unicopia:zap_fence",
"unicopia:zap_fence_gate",
"unicopia:waxed_zap_log",
"unicopia:waxed_zap_wood",
"unicopia:waxed_stripped_zap_log",
"unicopia:waxed_stripped_zap_wood",
"unicopia:waxed_zap_planks",
"unicopia:waxed_zap_stairs",
"unicopia:waxed_zap_slab",
"unicopia:waxed_zap_fence",
"unicopia:waxed_zap_fence_gate",
"unicopia:candied_apple",
"unicopia:stable_door",
"unicopia:dark_oak_stable_door",