Simplified Biome registration.
Fixed Fabric Block lighting and ability to not replace itself.
This commit is contained in:
parent
930a96e88b
commit
b572d731b4
5 changed files with 90 additions and 63 deletions
|
@ -52,10 +52,12 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
|
||||||
putCutout(ModBlocks.QUARTZ_DIMENSIONAL_DOOR);
|
putCutout(ModBlocks.QUARTZ_DIMENSIONAL_DOOR);
|
||||||
putCutout(ModBlocks.QUARTZ_DOOR);
|
putCutout(ModBlocks.QUARTZ_DOOR);
|
||||||
|
|
||||||
|
|
||||||
setupFluidRendering(ModFluids.ETERNAL_FLUID, ModFluids.FLOWING_ETERNAL_FLUID, new Identifier("dimdoors:eternal_fluid"));
|
setupFluidRendering(ModFluids.ETERNAL_FLUID, ModFluids.FLOWING_ETERNAL_FLUID, new Identifier("dimdoors:eternal_fluid"));
|
||||||
|
|
||||||
OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0)));
|
OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0)));
|
||||||
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider());
|
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider());
|
||||||
|
OpenWorlds.registerCloudRenderer(ModDimensions.LIMBO_TYPE, (minecraftClient, matrixStack, v, v1, v2, v3) -> {});
|
||||||
|
|
||||||
ClientSidePacketRegistry.INSTANCE.register(DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, MonolithEntity::spawnParticles);
|
ClientSidePacketRegistry.INSTANCE.register(DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, MonolithEntity::spawnParticles);
|
||||||
|
|
||||||
|
|
49
src/main/java/org/dimdev/dimdoors/block/FabricBlock.java
Normal file
49
src/main/java/org/dimdev/dimdoors/block/FabricBlock.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package org.dimdev.dimdoors.block;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsageContext;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.DyeColor;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
|
|
||||||
|
class FabricBlock extends Block {
|
||||||
|
FabricBlock(DyeColor color) {
|
||||||
|
super(FabricBlockSettings.of(Material.STONE, color).lightLevel(15));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"deprecation"})
|
||||||
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
ItemStack heldStack = hand == Hand.MAIN_HAND ? player.getMainHandStack() : player.getOffHandStack();
|
||||||
|
Block heldBlock = Block.getBlockFromItem(heldStack.getItem());
|
||||||
|
|
||||||
|
if (world.canPlayerModifyAt(player, pos) &&
|
||||||
|
player.canPlaceOn(pos, hit.getSide(), heldStack) &&
|
||||||
|
heldBlock.getDefaultState().isFullCube(world, pos) &&
|
||||||
|
!heldBlock.hasBlockEntity() &&
|
||||||
|
heldBlock != this &&
|
||||||
|
!player.isSneaking() &&
|
||||||
|
!(heldBlock instanceof FabricBlock)
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (!player.isCreative()) {
|
||||||
|
heldStack.decrement(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
world.setBlockState(pos, heldBlock.getPlacementState(new ItemPlacementContext(new ItemUsageContext(player, hand, hit))));
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
return ActionResult.PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,22 +28,22 @@ public final class ModBlocks {
|
||||||
public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).dropsNothing()));
|
public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).dropsNothing()));
|
||||||
public static final Block DETACHED_RIFT = register("dimdoors:detached_rift", new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).nonOpaque()));
|
public static final Block DETACHED_RIFT = register("dimdoors:detached_rift", new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).nonOpaque()));
|
||||||
|
|
||||||
public static final Block WHITE_FABRIC = registerFabric("dimdoors:white_fabric");
|
public static final Block WHITE_FABRIC = registerFabric("dimdoors:white_fabric", DyeColor.WHITE);
|
||||||
public static final Block ORANGE_FABRIC = registerFabric("dimdoors:orange_fabric");
|
public static final Block ORANGE_FABRIC = registerFabric("dimdoors:orange_fabric", DyeColor.ORANGE);
|
||||||
public static final Block MAGENTA_FABRIC = registerFabric("dimdoors:magenta_fabric");
|
public static final Block MAGENTA_FABRIC = registerFabric("dimdoors:magenta_fabric", DyeColor.MAGENTA);
|
||||||
public static final Block LIGHT_BLUE_FABRIC = registerFabric("dimdoors:light_blue_fabric");
|
public static final Block LIGHT_BLUE_FABRIC = registerFabric("dimdoors:light_blue_fabric", DyeColor.LIGHT_BLUE);
|
||||||
public static final Block YELLOW_FABRIC = registerFabric("dimdoors:yellow_fabric");
|
public static final Block YELLOW_FABRIC = registerFabric("dimdoors:yellow_fabric", DyeColor.YELLOW);
|
||||||
public static final Block LIME_FABRIC = registerFabric("dimdoors:lime_fabric");
|
public static final Block LIME_FABRIC = registerFabric("dimdoors:lime_fabric", DyeColor.LIME);
|
||||||
public static final Block PINK_FABRIC = registerFabric("dimdoors:pink_fabric");
|
public static final Block PINK_FABRIC = registerFabric("dimdoors:pink_fabric", DyeColor.PINK);
|
||||||
public static final Block GRAY_FABRIC = registerFabric("dimdoors:gray_fabric");
|
public static final Block GRAY_FABRIC = registerFabric("dimdoors:gray_fabric", DyeColor.GRAY);
|
||||||
public static final Block LIGHT_GRAY_FABRIC = registerFabric("dimdoors:light_gray_fabric");
|
public static final Block LIGHT_GRAY_FABRIC = registerFabric("dimdoors:light_gray_fabric", DyeColor.LIGHT_GRAY);
|
||||||
public static final Block CYAN_FABRIC = registerFabric("dimdoors:cyan_fabric");
|
public static final Block CYAN_FABRIC = registerFabric("dimdoors:cyan_fabric", DyeColor.CYAN);
|
||||||
public static final Block PURPLE_FABRIC = registerFabric("dimdoors:purple_fabric");
|
public static final Block PURPLE_FABRIC = registerFabric("dimdoors:purple_fabric", DyeColor.PURPLE);
|
||||||
public static final Block BLUE_FABRIC = registerFabric("dimdoors:blue_fabric");
|
public static final Block BLUE_FABRIC = registerFabric("dimdoors:blue_fabric", DyeColor.BLUE);
|
||||||
public static final Block BROWN_FABRIC = registerFabric("dimdoors:brown_fabric");
|
public static final Block BROWN_FABRIC = registerFabric("dimdoors:brown_fabric", DyeColor.BROWN);
|
||||||
public static final Block GREEN_FABRIC = registerFabric("dimdoors:green_fabric");
|
public static final Block GREEN_FABRIC = registerFabric("dimdoors:green_fabric", DyeColor.GREEN);
|
||||||
public static final Block RED_FABRIC = registerFabric("dimdoors:red_fabric");
|
public static final Block RED_FABRIC = registerFabric("dimdoors:red_fabric", DyeColor.RED);
|
||||||
public static final Block BLACK_FABRIC = registerFabric("dimdoors:black_fabric");
|
public static final Block BLACK_FABRIC = registerFabric("dimdoors:black_fabric", DyeColor.BLACK);
|
||||||
|
|
||||||
public static final Block WHITE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:white_ancient_fabric", DyeColor.WHITE);
|
public static final Block WHITE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:white_ancient_fabric", DyeColor.WHITE);
|
||||||
public static final Block ORANGE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:orange_ancient_fabric", DyeColor.ORANGE);
|
public static final Block ORANGE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:orange_ancient_fabric", DyeColor.ORANGE);
|
||||||
|
@ -62,8 +62,8 @@ public final class ModBlocks {
|
||||||
public static final Block RED_ANCIENT_FABRIC = registerAncientFabric("dimdoors:red_ancient_fabric", DyeColor.RED);
|
public static final Block RED_ANCIENT_FABRIC = registerAncientFabric("dimdoors:red_ancient_fabric", DyeColor.RED);
|
||||||
public static final Block BLACK_ANCIENT_FABRIC = registerAncientFabric("dimdoors:black_ancient_fabric", DyeColor.BLACK);
|
public static final Block BLACK_ANCIENT_FABRIC = registerAncientFabric("dimdoors:black_ancient_fabric", DyeColor.BLACK);
|
||||||
|
|
||||||
public static final Block ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.RED)));
|
public static final Block ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.RED).lightLevel(15)));
|
||||||
public static final Block UNRAVELLED_FABRIC = register("dimdoors:unravelled_fabric", new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.BLACK)));
|
public static final Block UNRAVELLED_FABRIC = register("dimdoors:unravelled_fabric", new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.BLACK).lightLevel(15)));
|
||||||
|
|
||||||
public static final Block MARKING_PLATE = register("dimdoors:marking_plate", new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK)));
|
public static final Block MARKING_PLATE = register("dimdoors:marking_plate", new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK)));
|
||||||
|
|
||||||
|
@ -75,33 +75,8 @@ public final class ModBlocks {
|
||||||
return register(id, new Block(FabricBlockSettings.of(Material.STONE, color).strength(-1.0F, 3600000.0F).dropsNothing()));
|
return register(id, new Block(FabricBlockSettings.of(Material.STONE, color).strength(-1.0F, 3600000.0F).dropsNothing()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block registerFabric(String id) {
|
private static Block registerFabric(String id, DyeColor color) {
|
||||||
return register(id, new Block(FabricBlockSettings.of(Material.STONE, DyeColor.WHITE)) {
|
return register(id, new FabricBlock(color));
|
||||||
@Override
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
|
||||||
ItemStack heldStack = hand == Hand.MAIN_HAND ? player.getMainHandStack() : player.getOffHandStack();
|
|
||||||
Block heldBlock = Block.getBlockFromItem(heldStack.getItem());
|
|
||||||
|
|
||||||
if (world.canPlayerModifyAt(player, pos) &&
|
|
||||||
player.canPlaceOn(pos, hit.getSide(), heldStack) &&
|
|
||||||
heldBlock.getDefaultState().isFullCube(world, pos) &&
|
|
||||||
!heldBlock.hasBlockEntity() &&
|
|
||||||
heldBlock != this &&
|
|
||||||
!player.isSneaking() &&
|
|
||||||
ModDimensions.isDimDoorsPocketDimension(world)) {
|
|
||||||
|
|
||||||
if (!player.isCreative()) {
|
|
||||||
heldStack.decrement(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
world.setBlockState(pos, heldBlock.getPlacementState(new ItemPlacementContext(new ItemUsageContext(player, hand, hit))));
|
|
||||||
return ActionResult.SUCCESS;
|
|
||||||
} else {
|
|
||||||
return ActionResult.PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|
|
@ -33,13 +33,17 @@ public class MonolithTask extends Goal {
|
||||||
this.targetPredicate = (new TargetPredicate()).setBaseMaxDistance(range).includeTeammates().includeInvulnerable().ignoreEntityTargetRules().setPredicate(EXCEPT_SPECTATOR::test);
|
this.targetPredicate = (new TargetPredicate()).setBaseMaxDistance(range).includeTeammates().includeInvulnerable().ignoreEntityTargetRules().setPredicate(EXCEPT_SPECTATOR::test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PlayerEntity getTarget() {
|
||||||
|
PlayerEntity playerEntity = this.mob.world.getClosestPlayer(this.targetPredicate, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
|
||||||
|
return playerEntity != null && mob.canSee(playerEntity) ? playerEntity : null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canStart() {
|
public boolean canStart() {
|
||||||
this.target = this.mob.world.getClosestPlayer(this.targetPredicate, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
|
return (this.target = getTarget()) != null;
|
||||||
return this.target != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldContinue() {
|
public boolean shouldContinue() {
|
||||||
return this.mob.squaredDistanceTo(this.target) > (double)(this.range * this.range);
|
return (this.target = getTarget()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
@ -50,7 +54,7 @@ public class MonolithTask extends Goal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
boolean visibility = target != null && mob.canSee(mob);
|
boolean visibility = target != null;
|
||||||
mob.updateAggroLevel(target, visibility);
|
mob.updateAggroLevel(target, visibility);
|
||||||
|
|
||||||
// Change orientation and face a player if one is in range
|
// Change orientation and face a player if one is in range
|
||||||
|
@ -69,7 +73,6 @@ public class MonolithTask extends Goal {
|
||||||
ServerSidePacketRegistry.INSTANCE.sendToPlayer(target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data);
|
ServerSidePacketRegistry.INSTANCE.sendToPlayer(target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibility) {
|
|
||||||
// Only spawn particles on the client side and outside Limbo
|
// Only spawn particles on the client side and outside Limbo
|
||||||
/*(world.isClient && isDangerous()) {
|
/*(world.isClient && isDangerous()) {
|
||||||
target.spawnParticles(player);
|
target.spawnParticles(player);
|
||||||
|
@ -85,4 +88,3 @@ public class MonolithTask extends Goal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ public final class ModBiomes {
|
||||||
public static final Biome DANGEROUS_BLACK_VOID = register(new Identifier("dimdoors:dangerous_black_void"), new BlankBiome(false, true));
|
public static final Biome DANGEROUS_BLACK_VOID = register(new Identifier("dimdoors:dangerous_black_void"), new BlankBiome(false, true));
|
||||||
|
|
||||||
private static Biome register(Identifier id, Biome biome) {
|
private static Biome register(Identifier id, Biome biome) {
|
||||||
Registry.register(Registry.BIOME, id, biome);
|
return Registry.register(Registry.BIOME, id, biome);
|
||||||
return biome;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|
Loading…
Reference in a new issue