diff --git a/needsported/AuxMaterial.java b/needsported/AuxMaterial.java deleted file mode 100644 index a140a76531..0000000000 --- a/needsported/AuxMaterial.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.westerosblocks.needsported; - -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; - -public class AuxMaterial { - public static final AuxMaterial AIR = new AuxMaterial(); - public static final AuxMaterial STONE = new AuxMaterial(); - public static final AuxMaterial GRASS = new AuxMaterial(); - public static final AuxMaterial DIRT = new AuxMaterial(); - public static final AuxMaterial WOOD = new AuxMaterial(); - public static final AuxMaterial METAL = new AuxMaterial(); - public static final AuxMaterial WATER = new AuxMaterial(); - public static final AuxMaterial LAVA = new AuxMaterial(); - public static final AuxMaterial LEAVES = new AuxMaterial(); - public static final AuxMaterial PLANT = new AuxMaterial(); - public static final AuxMaterial SPONGE = new AuxMaterial(); - public static final AuxMaterial CLOTH_DECORATION = new AuxMaterial(); - public static final AuxMaterial FIRE = new AuxMaterial(); - public static final AuxMaterial SAND = new AuxMaterial(); - public static final AuxMaterial GLASS = new AuxMaterial(); - public static final AuxMaterial EXPLOSIVE = new AuxMaterial(); - public static final AuxMaterial ICE = new AuxMaterial(); - public static final AuxMaterial SNOW = new AuxMaterial(); - public static final AuxMaterial CACTUS = new AuxMaterial(); - public static final AuxMaterial CLAY = new AuxMaterial(); - public static final AuxMaterial PORTAL = new AuxMaterial(); - public static final AuxMaterial CAKE = new AuxMaterial(); - public static final AuxMaterial WEB = new AuxMaterial(); - public static final AuxMaterial PISTON = new AuxMaterial(); - public static final AuxMaterial DECORATION = new AuxMaterial(); - - public static AuxMaterial getMaterial(BlockState blockState) { - System.out.println("Material requested for block " + blockState); - return null; - } - - public static AuxMaterial getMaterial(BlockBehaviour.Properties props, WesterosBlockDef def) { - return null; - } -} diff --git a/needsported/ClientSetup.java b/needsported/ClientSetup.java deleted file mode 100644 index e58c2e43b3..0000000000 --- a/needsported/ClientSetup.java +++ /dev/null @@ -1,44 +0,0 @@ -//package com.westerosblocks.needsported; -// -//import net.minecraft.client.Minecraft; -//import net.minecraft.server.packs.resources.PreparableReloadListener; -//import net.minecraft.server.packs.resources.ResourceManager; -//import net.minecraft.util.profiling.ProfilerFiller; -//import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; -//import net.neoforged.bus.api.SubscribeEvent; -//import net.neoforged.api.distmarker.Dist; -//import net.neoforged.api.distmarker.OnlyIn; -// -//import java.util.concurrent.CompletableFuture; -//import java.util.concurrent.Executor; -// -//public class ClientSetup { -// -// @SubscribeEvent -// @OnlyIn(Dist.CLIENT) -// public static void onRegisterClientReloadListeners(RegisterClientReloadListenersEvent event) { -// event.registerReloadListener(new WesterosResourceReloadListener()); -// } -// -// @OnlyIn(Dist.CLIENT) -// private static class WesterosResourceReloadListener implements PreparableReloadListener { -// @Override -// public CompletableFuture reload(PreparationBarrier stage, ResourceManager resourceManager, -// ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, -// Executor backgroundExecutor, Executor gameExecutor) { -// return CompletableFuture.supplyAsync(() -> { -// WesterosBlocks.log.info("Handling resource reload"); -// return null; -// }, backgroundExecutor).thenCompose(stage::wait).thenAcceptAsync((p_10792_) -> { -// WesterosBlockDef.reloadColorHandler(resourceManager); -// WesterosBlocks.log.info("Handling resource reload completed"); -// }, gameExecutor); -// } -// } -// -// @OnlyIn(Dist.CLIENT) -// public static void initRenderRegistry() { -// ResourceManager resourceManager = Minecraft.getInstance().getResourceManager(); -// WesterosBlockDef.reloadColorHandler(resourceManager); -// } -//} \ No newline at end of file diff --git a/needsported/Config.java b/needsported/Config.java deleted file mode 100644 index 15b77ff8e6..0000000000 --- a/needsported/Config.java +++ /dev/null @@ -1,62 +0,0 @@ -//package com.westerosblocks.needsported; -// -//// An example config class. This is not required, but it's a good idea to have one to keep your config organized. -//// Demonstrates how to use Neo's config APIs -//@EventBusSubscriber(modid = WesterosBlocks.MOD_ID, bus = EventBusSubscriber.Bus.MOD) -//public class Config -//{ -// private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); -// -// private static final ModConfigSpec.BooleanValue SNOW_IN_TAIGA = BUILDER -// .translation("westerosblocks.configuration.snowInTaiga").comment("Enable snow in taiga biome") -// .define("snowInTaiga", false); -// -// private static final ModConfigSpec.BooleanValue BLOCK_DEV_MODE = BUILDER -// .translation("westerosblocks.configuration.blockDevMode").comment("Block development mode") -// .define("blockDevMode", false); -// -// private static final ModConfigSpec.IntValue AUTO_RESTORE_TIME = BUILDER -// .translation("westerosblocks.configuration.autoRestoreTime").comment("Number of seconds before auto-restore") -// .defineInRange("autoRestoreTime", 30, 5, 300); -// -// private static final ModConfigSpec.BooleanValue AUTO_RESTORE_ALL_HALF_DOORS = BUILDER -// .translation("westerosblocks.configuration.autoRestoreAllHalfDoors").comment("Auto restore all half-door blocks") -// .define("autoRestoreAllHalfDoors", false); -// -// private static final ModConfigSpec.BooleanValue DOOR_SURVIVE_ANY = BUILDER -// .translation("westerosblocks.configuration.doorSurviveAny").comment("Allow door to survive on any surface") -// .define("doorSurviveAny", false); -// -// private static final ModConfigSpec.BooleanValue DOOR_NO_CONNECT = BUILDER -// .translation("westerosblocks.configuration.doorNoConnect").comment("Avoid doors connecting to walls/panes/etc") -// .define("doorNoConnect", false); -// -// private static final ModConfigSpec.IntValue SEA_LEVEL_OVERRIDE = BUILDER -// .translation("westerosblocks.configuration.seaLevelOverride").comment("Override sea level (default for Westeros=33, 0=disable override)") -// .defineInRange("seaLevelOverride", 30, 5, 300); -// -// -// static final ModConfigSpec SPEC = BUILDER.build(); -// -// public static boolean snowInTaiga; -// public static boolean blockDevMode; -// public static int autoRestoreTime; -// public static boolean autoRestoreAllHalfDoors; -// public static boolean doorSurviveAny; -// public static boolean doorNoConnect; -// public static int seaLevelOverride; -// -// -// -// @SubscribeEvent -// static void onLoad(final ModConfigEvent event) -// { -// snowInTaiga = SNOW_IN_TAIGA.get(); -// blockDevMode = BLOCK_DEV_MODE.get(); -// autoRestoreTime = AUTO_RESTORE_TIME.get(); -// autoRestoreAllHalfDoors = AUTO_RESTORE_ALL_HALF_DOORS.get(); -// doorSurviveAny = DOOR_SURVIVE_ANY.get(); -// doorNoConnect = DOOR_NO_CONNECT.get(); -// seaLevelOverride = SEA_LEVEL_OVERRIDE.get(); -// } -//} diff --git a/needsported/WesterosBlockColorMap.java b/needsported/WesterosBlockColorMap.java deleted file mode 100644 index bc07804546..0000000000 --- a/needsported/WesterosBlockColorMap.java +++ /dev/null @@ -1,7 +0,0 @@ -//package com.westerosblocks.needsported; -// -//public class WesterosBlockColorMap { -// public String[] blockNames; -// public String colorMult; -//}; -// diff --git a/needsported/WesterosBlockConfig.java b/needsported/WesterosBlockConfig.java deleted file mode 100644 index eb41a8a100..0000000000 --- a/needsported/WesterosBlockConfig.java +++ /dev/null @@ -1,10 +0,0 @@ -//package com.westerosblocks.needsported; -// -//// Top level container for WesterosBlocks.json parsed data -//public class WesterosBlockConfig { -// public WesterosBlockSetDef[] blockSets; -// public WesterosBlockDef[] blocks; -// public WesterosBlockColorMap[] colorMaps; -// public WesterosItemMenuOverrides[] menuOverrides; -// public WesterosBlockTags[] blockTags; -//} diff --git a/needsported/WesterosBlockDef.java b/needsported/WesterosBlockDef.java deleted file mode 100644 index c89830c9ef..0000000000 --- a/needsported/WesterosBlockDef.java +++ /dev/null @@ -1,1417 +0,0 @@ -//package com.westerosblocks.needsported; -// -//import java.util.ArrayList; -//import java.util.Arrays; -//import java.util.Collection; -//import java.util.Collections; -//import java.util.HashMap; -//import java.util.HashSet; -//import java.util.List; -//import java.util.Map; -//import java.util.Optional; -//import java.util.Set; -// -//import com.google.common.collect.ImmutableList; -//import com.google.common.collect.ImmutableMap; -//import com.google.common.collect.Maps; -// -//import com.westerosblocks.needsported.blocks.*; -//import net.minecraft.block.BlockState; -//import net.minecraft.block.entity.BlockEntity; -//import net.minecraft.block.entity.BlockEntityType; -//import net.minecraft.client.color.block.BlockColors; -//import net.minecraft.item.BlockItem; -//import net.minecraft.item.ItemStack; -//import net.minecraft.particle.ParticleType; -//import net.minecraft.particle.ParticleTypes; -//import net.minecraft.resource.ResourceManager; -//import net.minecraft.sound.SoundEvent; -//import net.minecraft.state.property.Property; -//import net.minecraft.util.math.BlockPos; -//import net.minecraft.util.shape.VoxelShape; -//import net.minecraft.world.biome.Biome; -//import net.minecraft.world.biome.ColorResolver; - -// -// Template for block configuration data (populated using GSON) -// -// public class WesterosBlockDef extends WesterosBlockStateRecord { -// private static final float DEF_FLOAT = -999.0F; -// public static final int DEF_INT = -999; -// -// public static final String LAYER_SENSITIVE = "layerSensitive"; -// -// public String blockName; // Locally unique block name -// public String blockType = "solid"; // Block type ('solid', 'liquid', 'plant', 'log', 'stairs', etc) -// public float hardness = DEF_FLOAT; // Block hardness -// public String stepSound = null; // Step sound (powder, wood, gravel, grass, stone, metal, glass, cloth, sand, -// // snow, ladder, anvil) -// public String material = null; // Generic material (ai, grass, ground, wood, rock, iron, anvil, water, lava, -// // leaves, plants, vine, sponge, etc) -// public float resistance = DEF_FLOAT; // Explosion resistance -// public int lightOpacity = DEF_INT; // Light opacity -// public List harvestLevel = null; // List of harvest levels -// public int fireSpreadSpeed = 0; // Fire spread speed -// public int flamability = 0; // Flamability -// public String creativeTab = null; // Creative tab for items -// public List customTags = null; // If block should add any custom tags -// -// public String type = ""; // Type field (used for plant types or other block type specific values) -// -// public boolean alphaRender = false; // If true, do render on pass 2 (for alpha blending) -// public Boolean ambientOcclusion = null; // Set ambient occlusion (default is true) -// public boolean nonOpaque = false; // If true, does not block visibility of shared faces (solid blocks) and doesn't -// // allow torches -// // ('solid', 'sound', 'sand', 'soulsand' blocks) -// public String label; // Label for item associated with block -// public String itemTexture = null; // Item texture, if any -// public int itemTextureIndex = 0; // Index of texture for item icon -// public List soundList = null; // List of custom sound names or sound IDs (for 'sound' blocks) -// -// public List stack = null; // List of elements for a stack, first is bottom-most (for *-stack) -// -// public List states = null; -// -// private StateProperty stateProp = null; -// -// public String connectBy = "block"; // Connection logic - by block, material - only for CTM-like blocks - -// public String legacyBlockID = null; -// public List legacyBlockIDList = null; - -// public boolean isConnectMatch(BlockState bs1, BlockState bs2) { -// if (this.connectBy.equals("material")) { -// return AuxMaterial.getMaterial(bs1) == AuxMaterial.getMaterial(bs2); -// } else { -// return bs1.getBlock() == bs2.getBlock(); -// } -// } - -// public static class RandomTextureSet { -// public List textures = null; // List of textures (for single texture set) -// public Integer weight = null; // Weight for texture set (default = 1) -// -// // Get number of base textures -// public int getTextureCount() { -// if (textures != null) { -// return textures.size(); -// } -// return 0; -// } -// -// public String getTextureByIndex(int idx) { -// int cnt = getTextureCount(); -// if (cnt > 0) { -// if (idx >= cnt) { -// idx = cnt - 1; -// } -// return textures.get(idx); -// } -// return null; -// } -// -// }; - -// public static class StackElement { -// public List textures = null; // List of textures -// public BoundingBox boundingBox = null; // Bounding box -// public List cuboids = null; // List of cuboids composing block (for 'cuboid', and others) -// public List collisionBoxes = null; // For 'solid', used for raytrace (arrow shots) -// public List randomTextures = null; // On supported blocks (solid, leaves, slabs, stairs), -// // defines sets of textures used for additional random models -// // If randomTextures is used, textures is ignored -// -// public String getTextureByIndex(int idx) { -// if ((textures != null) && (textures.size() > 0)) { -// if (idx >= textures.size()) { -// idx = textures.size() - 1; -// } -// return textures.get(idx); -// } -// return null; -// } -// -// // Get number of random texture sets -// public int getRandomTextureSetCount() { -// if ((randomTextures != null) && (randomTextures.size() > 0)) { -// return randomTextures.size(); -// } -// return 0; -// } -// -// // Get given random texture set -// public RandomTextureSet getRandomTextureSet(int setnum) { -// if ((randomTextures != null) && (randomTextures.size() > 0)) { -// if (setnum >= randomTextures.size()) { -// setnum = randomTextures.size() - 1; -// } -// return randomTextures.get(setnum); -// } -// return null; -// } -// -// }; - -// public static class HarvestLevel { -// public String tool; -// public int level; -// } - -// public static class BoundingBox { -// public float xMin = 0.0F; -// public float xMax = 1.0F; -// public float yMin = 0.0F; -// public float yMax = 1.0F; -// public float zMin = 0.0F; -// public float zMax = 1.0F; -// -// public BoundingBox() { -// } -// -// public BoundingBox(float x0, float y0, float z0, float x1, float y1, float z1) { -// this.xMin = x0; -// this.xMax = x1; -// this.yMin = y0; -// this.yMax = y1; -// this.zMin = z0; -// this.zMax = z1; -// } -// -// private transient VoxelShape aabb = null; -// -// public VoxelShape getAABB() { -// if (aabb == null) { -// aabb = Shapes.box(xMin, yMin, zMin, xMax, yMax, zMax); -// } -// return aabb; -// } -// } - -// public static class Vector { -// float x, y, z; -// -// private void rotate(int xcnt, int ycnt, int zcnt) { -// double xx, yy, zz; -// xx = x - 0.5F; -// yy = y - 0.5F; -// zz = z - 0.5F; // Shoft to center of block -// /* Do X rotation */ -// double rot = Math.toRadians(xcnt); -// double nval = zz * Math.sin(rot) + yy * Math.cos(rot); -// zz = zz * Math.cos(rot) - yy * Math.sin(rot); -// yy = nval; -// /* Do Y rotation */ -// rot = Math.toRadians(ycnt); -// nval = xx * Math.cos(rot) - zz * Math.sin(rot); -// zz = xx * Math.sin(rot) + zz * Math.cos(rot); -// xx = nval; -// /* Do Z rotation */ -// rot = Math.toRadians(zcnt); -// nval = yy * Math.sin(rot) + xx * Math.cos(rot); -// yy = yy * Math.cos(rot) - xx * Math.sin(rot); -// xx = nval; -// x = (float) xx + 0.5F; -// y = (float) yy + 0.5F; -// z = (float) zz + 0.5F; // Shoft back to corner -// // Clip value -// if (x > 1.0F) -// x = 1.0F; -// if (y > 1.0F) -// y = 1.0F; -// if (z > 1.0F) -// z = 1.0F; -// if (x < 0.0F) -// x = 0.0F; -// if (y < 0.0F) -// y = 0.0F; -// if (z < 0.0F) -// z = 0.0F; -// } -// -// } - -// public static enum CuboidRotation { -// NONE(0, 0, 0, new int[]{0, 1, 2, 3, 4, 5}, new int[]{0, 0, 0, 0, 0, 0}), -// ROTY90(0, 90, 0, new int[]{0, 1, 4, 5, 3, 2}, new int[]{270, 90, 0, 0, 0, 0}), -// ROTY180(0, 180, 0, new int[]{0, 1, 3, 2, 5, 4}, new int[]{180, 180, 0, 0, 0, 0}), -// ROTY270(0, 270, 0, new int[]{0, 1, 5, 4, 2, 3}, new int[]{90, 270, 0, 0, 0, 0}), -// ROTZ90(0, 0, 90, new int[]{5, 4, 2, 3, 0, 1}, new int[]{270, 90, 270, 90, 90, 90}), -// ROTZ270(0, 0, 270, new int[]{4, 5, 2, 3, 1, 0}, new int[]{90, 270, 90, 270, 270, 270}); -// -// final int xrot, yrot, zrot; -// final int txtidx[]; -// final int txtrot[]; -// -// CuboidRotation(int xr, int yr, int zr, int[] txt_idx, int[] txt_rot) { -// xrot = xr; -// yrot = yr; -// zrot = zr; -// txtidx = txt_idx; -// txtrot = txt_rot; -// } -// -// public int getRotY() { -// return yrot; -// } -// } - - // Shape for normal cuboid (box) -// public static final String SHAPE_BOX = "box"; - // Shape for crossed squares (plant-style) (texture is index 0 in list) -// public static final String SHAPE_CROSSED = "crossed"; - -// public static class Cuboid extends BoundingBox { -// public int[] sideTextures = null; -// public int[] sideRotations = {0, 0, 0, 0, 0, 0}; -// public String shape = SHAPE_BOX; // "box" = normal cuboid, "crossed" = plant-style crossed (texture 0) -// public boolean[] noTint; -// -// public Cuboid rotateCuboid(CuboidRotation rot) { -// Cuboid c = new Cuboid(); -// Vector v0 = new Vector(); -// Vector v1 = new Vector(); -// v0.x = xMin; -// v0.y = yMin; -// v0.z = zMin; -// v1.x = xMax; -// v1.y = yMax; -// v1.z = zMax; -// // Rotate corners -// v0.rotate(rot.xrot, rot.yrot, rot.zrot); -// v1.rotate(rot.xrot, rot.yrot, rot.zrot); -// // Compute net min/max -// c.xMin = Math.min(v0.x, v1.x); -// c.xMax = Math.max(v0.x, v1.x); -// c.yMin = Math.min(v0.y, v1.y); -// c.yMax = Math.max(v0.y, v1.y); -// c.zMin = Math.min(v0.z, v1.z); -// c.zMax = Math.max(v0.z, v1.z); -// if (this.sideTextures != null) { -// c.sideTextures = new int[rot.txtidx.length]; -// int cnt = this.sideTextures.length; -// for (int i = 0; i < c.sideTextures.length; i++) { -// int newidx = rot.txtidx[i]; -// if (newidx < cnt) { -// c.sideTextures[i] = this.sideTextures[newidx]; -// } else { -// c.sideTextures[i] = this.sideTextures[cnt - 1]; -// } -// } -// } else { -// c.sideTextures = rot.txtidx; -// } -// c.sideRotations = rot.txtrot; -// c.shape = this.shape; -// return c; -// } -// -// public Cuboid() { -// } -// -// public Cuboid(float x0, float y0, float z0, float x1, float y1, float z1) { -// this(x0, y0, z0, x1, y1, z1, null, null); -// } -// -// public Cuboid(float x0, float y0, float z0, float x1, float y1, float z1, int[] sidetextures) { -// this(x0, y0, z0, x1, y1, z1, sidetextures, null); -// } -// -// public Cuboid(float x0, float y0, float z0, float x1, float y1, float z1, int[] sidetextures, boolean noTint[]) { -// this.xMin = x0; -// this.xMax = x1; -// this.yMin = y0; -// this.yMax = y1; -// this.zMin = z0; -// this.zMax = z1; -// this.sideTextures = sidetextures; -// this.noTint = noTint; -// } -// } - -// public static class Particle { -// public float x = 0.5F, y = 0.5F, z = 0.5F; // Default position of effect -// public float vx = 0.0F, vy = 0.0F, vz = 0.0F; // Default velocity of effect -// public float xrand = 0.0F, yrand = 0.0F, zrand = 0.0F; // Default random position of effect (-rand to +rand) -// public float vxrand = 0.0F, vyrand = 0.0F, vzrand = 0.0F; // Default random velocity of effect (-rand to +rand) -// public float chance = 1.0F; -// public String particle; -// } - - // Base color multiplier (fixed) -// public static abstract class ColorMultHandler { -// ColorMultHandler() { -// } -// -// @OnlyIn(Dist.CLIENT) -// public int getItemColor(ItemStack stack, int tintIndex) { -// BlockColors blockColors = Minecraft.getInstance().getBlockColors(); -// BlockState BlockState = ((BlockItem) stack.getItem()).getBlock().defaultBlockState(); -// return blockColors.getColor(BlockState, null, null, tintIndex); -// } -// -// @OnlyIn(Dist.CLIENT) -// public abstract int getColor(BlockState arg0, BlockAndTintGetter arg1, BlockPos arg2, int arg3); -// -// public abstract int getColor(Biome biome, double x, double z); -// } - - // Fixed color multiplier (fixed) -// public static class FixedColorMultHandler extends ColorMultHandler { -// protected int fixedMult; -// -// FixedColorMultHandler(int mult) { -// fixedMult = mult; -// } -// -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter arg1, BlockPos arg2, int arg3) { -// return fixedMult; -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return fixedMult; -// } -// } - - // Foliage color multiplier -// public static class FoliageColorMultHandler extends ColorMultHandler { -// FoliageColorMultHandler() { -// } -// -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// if (world != null && pos != null) -// return BiomeColors.getAverageFoliageColor(world, pos); -// else -// return FoliageColor.getDefaultColor(); -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return biome.getFoliageColor(); -// } -// -// } - - // Grass color multiplier -// public static class GrassColorMultHandler extends ColorMultHandler { -// GrassColorMultHandler() { -// } -// -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// if (world != null && pos != null) -// return BiomeColors.getAverageGrassColor(world, pos); -// else -// return GrassColor.get(0.5D, 1.0D); -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return biome.getGrassColor(x, z); -// } -// -// } - - // Water color multiplier -// public static class WaterColorMultHandler extends ColorMultHandler { -// WaterColorMultHandler() { -// } -// -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// return BiomeColors.getAverageWaterColor(world, pos) | 0xFF000000; -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return biome.getWaterColor(); -// } -// } - -// public static class PineColorMultHandler extends ColorMultHandler { -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// return FoliageColor.getEvergreenColor(); -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return FoliageColor.getEvergreenColor(); -// } -// } - -// public static class BirchColorMultHandler extends ColorMultHandler { -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// return FoliageColor.getBirchColor(); -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return FoliageColor.getBirchColor(); -// } -// } - -// public static class BasicColorMultHandler extends ColorMultHandler { -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState arg0, BlockAndTintGetter world, BlockPos pos, int arg3) { -// return FoliageColor.getDefaultColor(); -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return FoliageColor.getDefaultColor(); -// } -// } - - -// public WesterosBlockStateRecord getStackElementByIndex(int idx) { -// if ((stack != null) && (stack.size() > 0)) { -// if (idx >= stack.size()) { -// idx = stack.size() - 1; -// } -// return stack.get(idx); -// } -// return null; -// } - - // Custom color multiplier -// public static class CustomColorMultHandler extends ColorMultHandler implements ColorResolver { -// private final List colorBuffers; -// private final List rnames; -// private boolean brokenCustomRenderer = false; -// -// CustomColorMultHandler(String rname, String blockName) { -// this(Collections.singletonList(rname), blockName); -// } -// -// CustomColorMultHandler(List rnames, String blockName) { -// super(); -// this.colorBuffers = new ArrayList(); -// this.rnames = rnames; -// for (String rname : rnames) { -// colorBuffers.add(new int[65536]); -// } -// } -// -// public int calculateColor(LevelReader rdr, BlockPos pos, int txtindx) { -// int red = 0; -// int green = 0; -// int blue = 0; -// -// for (int xx = -1; xx <= 1; ++xx) { -// for (int zz = -1; zz <= 1; ++zz) { -// BlockPos bp = pos.offset(xx, 0, zz); -// Biome biome = rdr.getBiome(bp).value(); -// int mult = getColor(biome.getBaseTemperature(), biome.getModifiedClimateSettings().downfall(), txtindx); -// red += (mult & 0xFF0000) >> 16; -// green += (mult & 0x00FF00) >> 8; -// blue += (mult & 0x0000FF); -// } -// } -// return (((red / 9) & 0xFF) << 16) | (((green / 9) & 0xFF) << 8) | ((blue / 9) & 0xFF); -// } -// -// @Override -// @OnlyIn(Dist.CLIENT) -// public int getColor(BlockState state, BlockAndTintGetter world, BlockPos pos, int txtindx) { -// if ((world != null) && (pos != null)) { -// LevelReader rdr = null; -// -// if (world instanceof RenderChunkRegion) { -// // TODO: idk if using Minecraft.getInstance is correct -//// rdr = ((RenderChunkRegion)world).level; -// rdr = Minecraft.getInstance().level; -// } else if (world instanceof LevelReader) { -// rdr = (LevelReader) world; -// } -// if (rdr != null) { -// return calculateColor(rdr, pos, txtindx); -// } -// // Workaround to attempt to support custom renderers such as Optifine or Embeddium -// else { -// if (!brokenCustomRenderer) { -// // First try to access non-thread-safe level reader from minecraft client instance... -// try { -// rdr = Minecraft.getInstance().level; -// return calculateColor(rdr, pos, txtindx); -// } catch (Exception x) { -// // If fails, try to use color resolver method... -// try { -// return world.getBlockTint(pos, this); -// } catch (Exception y) { -// // If both fail, biome colors will be broken, but should not explode. -// brokenCustomRenderer = true; -// } -// } -// } -// } -// } -// return getColor(null, 0.5D, 1.0D, txtindx); -// } -// -// private int getColor(double tmp, double hum, int txtindx) { -// tmp = Mth.clamp(tmp, 0.0F, 1.0F); -// hum = Mth.clamp(hum, 0.0F, 1.0F); -// hum *= tmp; -// int i = (int) ((1.0D - tmp) * 255.0D); -// int j = (int) ((1.0D - hum) * 255.0D); -// return colorBuffers.get(txtindx)[j << 8 | i]; -// } -// -// @Override -// public int getColor(Biome biome, double x, double z) { -// return getColor(biome, x, z, 0); -// } -// -// public int getColor(Biome biome, double x, double z, int txtindx) { -// float hum = 1.0F; -// float tmp = 0.5F; -// if (biome != null) { -// hum = biome.getModifiedClimateSettings().downfall(); -// tmp = biome.getBaseTemperature(); -// } -// tmp = Mth.clamp(tmp, 0.0F, 1.0F); -// hum = Mth.clamp(hum, 0.0F, 1.0F); -// hum *= tmp; -// int i = (int) ((1.0D - tmp) * 255.0D); -// int j = (int) ((1.0D - hum) * 255.0D); -// return colorBuffers.get(txtindx)[j << 8 | i]; -// } -// -// @OnlyIn(Dist.CLIENT) -// public void loadColorMaps(ResourceManager resMgr) { -// int txtindx = 0; -// for (String resName : rnames) { -// if (resName.indexOf(':') < 0) -// resName = WesterosBlocks.MOD_ID + ":" + resName; -// if (resName.endsWith(".png") == false) -// resName += ".png"; -// try { -// -// colorBuffers.set(txtindx, LegacyStuffWrapper.getPixels(resMgr, ResourceLocation.parse(resName))); -// WesterosBlocks.log.debug(String.format("Loaded color resource '%s'", resName)); -// } catch (Exception e) { -// WesterosBlocks.log.error(String.format("Invalid color resource '%s'", resName), e); -// Arrays.fill(colorBuffers.get(txtindx), 0xFFFFFF); -// } -// txtindx++; -// } -// } -// } - -// public String getType() { -// return this.type; -// } - -// private transient Map parsedType; - -// public Map getMappedType() { -// if (parsedType == null) { -// parsedType = new HashMap(); -// String[] toks = type.split(","); -// for (String tok : toks) { -// String[] flds = tok.split(":"); -// if (flds.length < 2) -// continue; -// parsedType.put(flds[0], flds[1]); -// } -// } -// return parsedType; -// } - -// public String getTypeValue(String key, String defval) { -// String v = getMappedType().get(key); -// if (v == null) v = defval; -// return v; -// } - -// public String getTypeValue(String key) { -// return getTypeValue(key, ""); -// } - -// private transient boolean hasCollisionBoxes = false; -// -// private static final Map materialTable = new HashMap(); -// private static final Map stepSoundTable = new HashMap(); -// private static final Map tabTable = new HashMap<>(); -// private static final Map typeTable = new HashMap(); -// private static final Map colorMultTable = new HashMap(); -// private static final Map> particles = new HashMap>(); - -// private transient boolean didInit = false; -// -// public void doInit() { -// if (didInit) -// return; -// // If no states, just use base as the one state -// if (this.states == null) { -// this.states = Collections.singletonList(this); -// } -// if (this.ambientOcclusion == null) { -// this.ambientOcclusion = true; // Default to true -// } -// // If overlay textures, set nonOpaque to true -// if (this.overlayTextures != null) { -// this.nonOpaque = true; -// } -// for (WesterosBlockStateRecord rec : this.states) { -// // if states array, allow attributes to be inherited from base def if not specified -// if (rec.boundingBox == null) rec.boundingBox = this.boundingBox; -// if (rec.cuboids == null) rec.cuboids = this.cuboids; -// if (rec.collisionBoxes == null) rec.collisionBoxes = this.collisionBoxes; -// if (rec.supportBoxes == null) rec.supportBoxes = this.supportBoxes; -// if (rec.textures == null) rec.textures = this.textures; -// if (rec.randomTextures == null) rec.randomTextures = this.randomTextures; -// if (rec.overlayTextures == null) rec.overlayTextures = this.overlayTextures; -// if (rec.colorMult.equals("#FFFFFF")) rec.colorMult = this.colorMult; -// if (rec.colorMults == null) rec.colorMults = this.colorMults; -// rec.doStateRecordInit(); -// -// // If any state has overlay textures, set nonOpaque to true -// if (rec.overlayTextures != null) { -// this.nonOpaque = true; -// } -// } -// // If stacks, process these too -// if (this.stack != null) { -// for (WesterosBlockStateRecord se : this.stack) { -// se.doStateRecordInit(); -// } -// } -// if (this.states.size() > 1) { -// ArrayList ids = new ArrayList(); -// for (int i = 0; i < states.size(); i++) { -// WesterosBlockStateRecord rec = states.get(i); -// if (rec.stateID == null) rec.stateID = String.format("state%d", i); -// ids.add(rec.stateID); -// } -// stateProp = new StateProperty(ids); -// } -// -// didInit = true; -// } - -// private static Map perfCounts = new HashMap(); - -// public Block createBlock(RegisterEvent.RegisterHelper helper) { -// try { -// doInit(); // Prime the block model -// } catch (Exception x) { -// WesterosBlocks.log.error("Exception during doInit: blockName=" + this.blockName); -// throw x; -// } -// long[] pc = perfCounts.get(blockType); -// if (pc == null) { -// pc = new long[2]; -// perfCounts.put(blockType, pc); -// } -// WesterosBlockFactory bf = typeTable.get(blockType); -// if (bf == null) { -// WesterosBlocks.log.error(String.format("Invalid blockType '%s' in block '%s'", blockType, blockName)); -// return null; -// } -// long start = System.currentTimeMillis(); -// Block blk = bf.buildBlockClass(this, helper); -// long end = System.currentTimeMillis(); -// pc[0]++; -// pc[1] += (end - start); -// -// return blk; -// } - -// public static void dumpBlockPerf() { -// WesterosBlocks.log.info("Block create perf"); -// for (String blktype : perfCounts.keySet()) { -// long[] pc = perfCounts.get(blktype); -// WesterosBlocks.log.info(String.format("type %s: %d count, %d total ms, %d ms/call", blktype, pc[0], pc[1], pc[1] / pc[0])); -// } -// } - - // TODO: we can use render_type in the model file itself instead https://docs.neoforged.net/docs/resources/client/models/#render-types -// public Block registerRenderType(Block block, boolean isSolid, boolean isTransparent) { -// if (FMLEnvironment.dist == Dist.CLIENT) { -// if (this.alphaRender) { -// ItemBlockRenderTypes.setRenderLayer(block, RenderType.translucent()); -// } else if (!isSolid) { -// ItemBlockRenderTypes.setRenderLayer(block, RenderType.cutout()); -// } else if (isTransparent) { -// ItemBlockRenderTypes.setRenderLayer(block, RenderType.cutoutMipped()); -// } -// } -// return block; -// } -// -// public BlockBehaviour.Properties makeProperties() { -// return makeAndCopyProperties(null); -// } -// -// private static boolean never(BlockState p_50806_, BlockGetter p_50807_, BlockPos p_50808_) { -// return false; -// } -// -// public BlockBehaviour.Properties makeAndCopyProperties(Block blk) { -// BlockBehaviour.Properties props; -// if (blk != null) { -// props = BlockBehaviour.Properties.ofFullCopy(blk); -// } else { -// AuxMaterial mat = getMaterial(); -// props = BlockBehaviour.Properties.of(); // TODO - material color? -// } -// if (hardness >= 0.0F) { -// if (resistance >= 0.0) -// props = props.strength(hardness, resistance); -// else -// props = props.strength(hardness); -// } -// if (stepSound != null) { -// props = props.sound(getSoundType()); -// } -// // See if any nonzero light levels -// if (this.stateProp != null) { -// Map llmap = null; -// for (int i = 0; i < this.states.size(); i++) { -// WesterosBlockStateRecord sr = this.states.get(i); -// if (sr.lightValue > 0.0F) { -// if (llmap == null) llmap = new HashMap(); -// llmap.put(sr.stateID, (int) (16.0 * sr.lightValue)); -// } -// if (llmap != null) { -// final Map final_llmap = llmap; -// props = props.lightLevel((state) -> -// final_llmap.getOrDefault(state.getValue(this.stateProp), 0)); -// } -// } -// } else { -// float ll = this.states.get(0).lightValue; -// if (ll > 0.0F) { -// props = props.lightLevel((state) -> (int) (16.0 * ll)); -// } -// } -// if (lightValue > 0.0F) { -// props = props.lightLevel((state) -> (int) (16.0 * lightValue)); -// } -// if ((!ambientOcclusion) || (nonOpaque)) { // If no ambient occlusion -// props = props.noOcclusion(); -// props = props.isViewBlocking(WesterosBlockDef::never); -// } -// return props; -// } - - /** - * Returns this WesterosBlockDef's default Material - */ -// public AuxMaterial getMaterial() { -// AuxMaterial m = materialTable.get(material); -// if (m == null) { -// WesterosBlocks.log.warn(String.format("Invalid material '%s' in block '%s'", material, blockName)); -// return AuxMaterial.STONE; -// } -// return m; -// } - - /** - * Returns this WesterosBlockDef's default SoundType - * - * @return this WesterosBlockDef's default SoundType - */ -// public SoundType getSoundType() { -// SoundType ss = stepSoundTable.get(stepSound); -// if (ss == null) { -// WesterosBlocks.log.warn(String.format("Invalid step sound '%s' in block '%s'", stepSound, blockName)); -// return SoundType.STONE; -// } -// return ss; -// } - -// public CreativeModeTab getCreativeTab() { -// CreativeModeTab ct = tabTable.get(creativeTab); -// if (ct == null) { -// WesterosBlocks.log.warn(String.format("Invalid tab name '%s' in block '%s'", creativeTab, blockName)); -// // TODO -//// ct = WesterosBlocksCreativeTab.tabWesterosMisc; -// } -// return ct; -// } - -// public boolean hasCollisionBoxes() { -// return hasCollisionBoxes; -// } - -// public String getBlockName() { -// return this.blockName; -// } - -// public static void addCreativeTab(String name, CreativeModeTab tab) { -// tabTable.put(name, tab); -// } - -// public static boolean sanityCheck(WesterosBlockDef[] defs) { -// HashSet names = new HashSet(); -// // Make sure block IDs and names are unique -// for (WesterosBlockDef def : defs) { -// if (def == null) -// continue; -// if (def.blockName == null) { -// WesterosBlocks.log.error("Block definition is missing blockName"); -// return false; -// } -// if (names.add(def.blockName) == false) { // If alreay defined -// WesterosBlocks.log.error(String.format("Block '%s' - blockName duplicated", def.blockName)); -// return false; -// } -// } -// WesterosBlocks.log.info("WesterosBlocks.json passed sanity check"); -// return true; -// } - - // Return true if defs strictly subsumes validation (i.e., it preserves every block name, as well as - // every state-related attribute for each block); otherwise false. -// public static boolean compareBlockDefs(WesterosBlockDef[] defs, WesterosBlockDef[] validation) { -// Map defmap = defsToMap(defs); -// boolean error = false; -// for (WesterosBlockDef val : validation) { -// if (!defmap.containsKey(val.blockName)) { -// WesterosBlocks.log.warn(String.format("validation: blockName '%s' missing", val.blockName)); -// error = true; -// continue; -// } -// -// WesterosBlockDef def = defmap.get(val.blockName); -// if (!def.blockType.equals(val.blockType)) { -// // allow for solid subtypes to be recast -// if (!def.blockType.matches("solid|sand|soulsand") && !def.blockType.matches("solid|sand|soulsand")) { -// WesterosBlocks.log.warn(String.format("validation: blockName '%s' has different blockType attribute", val.blockName)); -// error = true; -// continue; -// } -// } -// -// String[] valTypeAttrs = val.type.split(","); -// for (String typeAttr : valTypeAttrs) { -// if (!def.type.contains(typeAttr)) { -// WesterosBlocks.log.warn(String.format("validation: blockName '%s' is missing type attribute '%s'", val.blockName, typeAttr)); -// error = true; -// continue; -// } -// } -// -// boolean substateError = false; -// if (val.stack != null) { -// if (def.stack == null || def.stack.size() != val.stack.size()) -// substateError = true; -// else { -// for (int i = 0; i < val.stack.size(); i++) { -// if (!def.stack.get(i).equals(val.stack.get(i))) -// substateError = true; -// } -// } -// } -// if (val.states != null) { -// if (def.states == null || def.states.size() != val.states.size()) -// substateError = true; -// else { -// for (int i = 0; i < val.states.size(); i++) { -// if (!def.states.get(i).equals(val.states.get(i))) -// substateError = true; -// } -// } -// } -// if (substateError) { -// WesterosBlocks.log.warn(String.format("validation: blockName '%s' has different stack or state lists", val.blockName)); -// error = true; -// continue; -// } -// } -// return !error; -// } -// -// public static Map defsToMap(WesterosBlockDef[] defs) { -// Map map = new HashMap(); -// for (WesterosBlockDef def : defs) { -// map.put(def.blockName, def); -// } -// return map; -// } - -// public static void initialize() { -// materialTable.put("air", AuxMaterial.AIR); -// materialTable.put("grass", AuxMaterial.GRASS); -// materialTable.put("ground", AuxMaterial.DIRT); -// materialTable.put("wood", AuxMaterial.WOOD); -// materialTable.put("rock", AuxMaterial.STONE); -// materialTable.put("iron", AuxMaterial.METAL); -// materialTable.put("anvil", AuxMaterial.METAL); -// materialTable.put("water", AuxMaterial.WATER); -// materialTable.put("lava", AuxMaterial.LAVA); -// materialTable.put("leaves", AuxMaterial.LEAVES); -// materialTable.put("plants", AuxMaterial.PLANT); -// materialTable.put("vine", AuxMaterial.PLANT); -// materialTable.put("sponge", AuxMaterial.SPONGE); -// materialTable.put("cloth", AuxMaterial.CLOTH_DECORATION); -// materialTable.put("fire", AuxMaterial.FIRE); -// materialTable.put("sand", AuxMaterial.SAND); -// materialTable.put("glass", AuxMaterial.GLASS); -// materialTable.put("tnt", AuxMaterial.EXPLOSIVE); -// materialTable.put("coral", AuxMaterial.STONE); -// materialTable.put("ice", AuxMaterial.ICE); -// materialTable.put("snow", AuxMaterial.SNOW); -// materialTable.put("craftedSnow", AuxMaterial.SNOW); -// materialTable.put("cactus", AuxMaterial.CACTUS); -// materialTable.put("clay", AuxMaterial.CLAY); -// materialTable.put("portal", AuxMaterial.PORTAL); -// materialTable.put("cake", AuxMaterial.CAKE); -// materialTable.put("web", AuxMaterial.WEB); -// materialTable.put("piston", AuxMaterial.PISTON); -// materialTable.put("decoration", AuxMaterial.DECORATION); -// -// stepSoundTable.put("powder", SoundType.SAND); -// stepSoundTable.put("wood", SoundType.WOOD); -// stepSoundTable.put("gravel", SoundType.GRAVEL); -// stepSoundTable.put("grass", SoundType.GRASS); -// stepSoundTable.put("stone", SoundType.STONE); -// stepSoundTable.put("metal", SoundType.METAL); -// stepSoundTable.put("glass", SoundType.GLASS); -// stepSoundTable.put("cloth", SoundType.WOOL); -// stepSoundTable.put("sand", SoundType.SAND); -// stepSoundTable.put("snow", SoundType.SNOW); -// stepSoundTable.put("ladder", SoundType.LADDER); -// stepSoundTable.put("anvil", SoundType.ANVIL); -// stepSoundTable.put("plant", SoundType.CROP); -// stepSoundTable.put("slime", SoundType.FUNGUS); -// // Tab table -// tabTable.put("buildingBlocks", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.BUILDING_BLOCKS)); -// //tabTable.put("decorations", CreativeModeTabs.DECORATIONS); -// tabTable.put("redstone", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.REDSTONE_BLOCKS)); -// //tabTable.put("transportation", CreativeModeTabs.TRANSPORTATION); -// //tabTable.put("misc", CreativeModeTabs.MISC); -// tabTable.put("food", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.FOOD_AND_DRINKS)); -// tabTable.put("tools", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.TOOLS_AND_UTILITIES)); -// tabTable.put("combat", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.COMBAT)); -// //tabTable.put("brewing", CreativeModeTabs.BREWING); -// tabTable.put("materials", BuiltInRegistries.CREATIVE_MODE_TAB.getOrThrow(CreativeModeTabs.INGREDIENTS)); -// -// // Standard block types -// typeTable.put("solid", new WCSolidBlock.Factory()); -// typeTable.put("stair", new WCStairBlock.Factory()); -// typeTable.put("log", new WCLogBlock.Factory()); -// typeTable.put("plant", new WCPlantBlock.Factory()); -// typeTable.put("crop", new WCCropBlock.Factory()); -// typeTable.put("slab", new WCSlabBlock.Factory()); -// typeTable.put("wall", new WCWallBlock.Factory()); -// typeTable.put("fence", new WCFenceBlock.Factory()); -// typeTable.put("web", new WCWebBlock.Factory()); -// typeTable.put("torch", new WCTorchBlock.Factory()); -// typeTable.put("fan", new WCFanBlock.Factory()); -// typeTable.put("ladder", new WCLadderBlock.Factory()); -// typeTable.put("cuboid", new WCCuboidBlock.Factory()); -// typeTable.put("cuboid-nsew", new WCCuboidNSEWBlock.Factory()); -// typeTable.put("cuboid-16way", new WCCuboid16WayBlock.Factory()); -// typeTable.put("cuboid-ne", new WCCuboidNEBlock.Factory()); -// typeTable.put("cuboid-nsewud", new WCCuboidNSEWUDBlock.Factory()); -// typeTable.put("cuboid-nsew-stack", new WCCuboidNSEWStackBlock.Factory()); -// typeTable.put("door", new WCDoorBlock.Factory()); -// typeTable.put("fire", new WCFireBlock.Factory()); -// typeTable.put("leaves", new WCLeavesBlock.Factory()); -// typeTable.put("pane", new WCPaneBlock.Factory()); -// typeTable.put("layer", new WCLayerBlock.Factory()); -// typeTable.put("soulsand", new WCSoulSandBlock.Factory()); -// typeTable.put("rail", new WCRailBlock.Factory()); -// typeTable.put("cake", new WCCakeBlock.Factory()); -// typeTable.put("bed", new WCBedBlock.Factory()); -// typeTable.put("sand", new WCSandBlock.Factory()); -// typeTable.put("halfdoor", new WCHalfDoorBlock.Factory()); -// typeTable.put("furnace", new WCFurnaceBlock.Factory()); -// typeTable.put("sound", new WCSoundBlock.Factory()); -// typeTable.put("trapdoor", new WCTrapDoorBlock.Factory()); -// typeTable.put("beacon", new WCBeaconBlock.Factory()); -// typeTable.put("vines", new WCVinesBlock.Factory()); -// typeTable.put("flowerpot", new WCFlowerPotBlock.Factory()); -// typeTable.put("fencegate", new WCFenceGateBlock.Factory()); -// -// // Standard color multipliers -// colorMultTable.put("#FFFFFF", new FixedColorMultHandler(0xFFFFFF)); -// colorMultTable.put("water", new WaterColorMultHandler()); -// colorMultTable.put("foliage", new FoliageColorMultHandler()); -// colorMultTable.put("grass", new GrassColorMultHandler()); -// colorMultTable.put("pine", new PineColorMultHandler()); -// colorMultTable.put("birch", new BirchColorMultHandler()); -// colorMultTable.put("basic", new BasicColorMultHandler()); -// colorMultTable.put("lily", new FixedColorMultHandler(2129968)); -// -// // Valid particle values -// particles.put("hugeexplosion", ParticleTypes.EXPLOSION); -// particles.put("largeexplode", ParticleTypes.EXPLOSION); -// particles.put("fireworksSpark", ParticleTypes.FIREWORK); -// particles.put("bubble", ParticleTypes.BUBBLE); -// particles.put("suspended", ParticleTypes.UNDERWATER); -// particles.put("depthsuspend", ParticleTypes.UNDERWATER); -// //particles.put("townaura", ParticleTypes.BARRIER); -// particles.put("crit", ParticleTypes.CRIT); -// particles.put("magicCrit", ParticleTypes.CRIT); -// particles.put("smoke", ParticleTypes.SMOKE); -// particles.put("mobSpell", ParticleTypes.ENCHANT); -// particles.put("mobSpellAmbient", ParticleTypes.ENCHANT); -// particles.put("spell", ParticleTypes.ENCHANT); -// particles.put("instantSpell", ParticleTypes.INSTANT_EFFECT); -// particles.put("witchMagic", ParticleTypes.WITCH); -// particles.put("note", ParticleTypes.NOTE); -// particles.put("portal", ParticleTypes.PORTAL); -// particles.put("enchantmenttable", ParticleTypes.POOF); -// particles.put("explode", ParticleTypes.EXPLOSION); -// particles.put("flame", ParticleTypes.FLAME); -// particles.put("lava", ParticleTypes.LAVA); -// particles.put("splash", ParticleTypes.SPLASH); -// particles.put("largesmoke", ParticleTypes.LARGE_SMOKE); -// particles.put("cloud", ParticleTypes.CLOUD); -// particles.put("snowballpoof", ParticleTypes.POOF); -// particles.put("dripWater", ParticleTypes.DRIPPING_WATER); -// particles.put("dripLava", ParticleTypes.DRIPPING_LAVA); -// particles.put("snowshovel", ParticleTypes.ITEM_SNOWBALL); -// particles.put("slime", ParticleTypes.ITEM_SLIME); -// particles.put("heart", ParticleTypes.HEART); -// particles.put("angryVillager", ParticleTypes.ANGRY_VILLAGER); -// particles.put("happyVillager", ParticleTypes.HAPPY_VILLAGER); -// } - - // Force reload of color handlers -// public static void reloadColorHandler(ResourceManager pResourceManager) { -// Set hndids = new HashSet(colorMultTable.keySet()); -// for (String hndid : hndids) { -// ColorMultHandler prev = colorMultTable.get(hndid); -// // Only reload those from resources -// if (prev instanceof CustomColorMultHandler) { -// ((CustomColorMultHandler) prev).loadColorMaps(pResourceManager); -// } -// } -// } - - // Get color muliplier -// public static ColorMultHandler getColorHandler(String hnd, String blockName) { -// String hndid = hnd.toLowerCase(); -// ColorMultHandler cmh = colorMultTable.get(hndid); -// if (cmh == null) { -// // See if color code -// if ((hndid.length() == 7) && (hndid.charAt(0) == '#')) { -// try { -// cmh = new FixedColorMultHandler(Integer.parseInt(hndid.substring(1), 16)); -// colorMultTable.put(hndid, cmh); -// } catch (NumberFormatException nfx) { -// } -// } -// // See if resource -// else { -// int idx = hnd.indexOf(':'); -// if (idx < 0) { -// hnd = WesterosBlocks.MOD_ID + ":" + hnd; -// hndid = hnd.toLowerCase(); -// } -// cmh = colorMultTable.get(hndid); -// if (cmh == null) { -// cmh = new CustomColorMultHandler(hnd, blockName); -// colorMultTable.put(hndid, cmh); -// } -// } -// } -// -// return cmh; -// } -// -// public static ColorMultHandler getColorHandler(List hnd, String blockName) { -// String hndid = String.join("_", hnd).toLowerCase(); -// ColorMultHandler cmh = colorMultTable.get(hndid); -// if (cmh == null) { -// for (int i = 0; i < hnd.size(); i++) { -// int idx = hnd.get(i).indexOf(':'); -// if (idx < 0) { -// hnd.set(i, WesterosBlocks.MOD_ID + ":" + hnd.get(i)); -// } -// } -// hndid = String.join("_", hnd).toLowerCase(); -// cmh = colorMultTable.get(hndid); -// if (cmh == null) { -// cmh = new CustomColorMultHandler(hnd, blockName); -// colorMultTable.put(hndid, cmh); -// } -// } -// -// return cmh; -// } - -// public String getBlockColorMapResource() { -// String res = null; -// String blockColor = colorMult; -// if (blockColor == null && colorMults != null && colorMults.size() >= 1) { -// blockColor = colorMults.get(0); -// } -// if ((blockColor != null) && (blockColor.startsWith("#") == false)) { -// String tok[] = blockColor.split(":"); -// if (tok.length == 1) { -// if (tok[0].startsWith("textures/")) -// tok[0] = tok[0].substring(9); -// res = WesterosBlocks.MOD_ID + ":" + tok[0]; -// } else { -// if (tok[1].startsWith("textures/")) -// tok[1] = tok[1].substring(9); -// res = tok[0] + ":" + tok[1]; -// } -// } -// return res; -// } - -// private static class BlockEntityRec { -// ArrayList blocks = new ArrayList(); -// BlockEntityType regobj; -// } -// -// private static HashMap te_rec = new HashMap(); -// -// public static final DeferredRegister> TILE_ENTITY_TYPES = -// DeferredRegister.create(BuiltInRegistries.BLOCK_ENTITY_TYPE, WesterosBlocks.MOD_ID); -// -// public void registerBlockItem(String blockName, Block block) { -// WesterosBlocks.ITEMS.register(blockName, () -> new BlockItem(block, new Item.Properties())); -// } -// -// public static void registerBlockEntity(String name, BlockEntityType.BlockEntitySupplier BlockEntitySupplier, Block blk) { -// BlockEntityRec rec = (BlockEntityRec) te_rec.get(name); -// if (rec == null) { -// rec = new BlockEntityRec(); -// te_rec.put(name, rec); -// final BlockEntityRec frec = rec; -// // TODO -//// rec.regobj = TILE_ENTITY_TYPES.register(name, () -> BlockEntityType.Builder.of(BlockEntitySupplier, frec.blocks.toArray(new Block[frec.blocks.size()])).build(null)); -// } -// rec.blocks.add(blk); -// } -// -// public static BlockEntityType getBlockEntityType(String name) { -// BlockEntityRec rec = te_rec.get(name); -// if (rec != null) -// return rec.regobj; -// return null; -// } - -// public static ColorMultHandler getStateColorHandler(WesterosBlockStateRecord rec, String blockName) { -// if (rec.colorMults != null) { -// return getColorHandler(rec.colorMults, blockName); -// } else { -// return getColorHandler(rec.colorMult, blockName); -// } -// } - - // Handle registration of tint handling and other client rendering -// @OnlyIn(Dist.CLIENT) -// public void registerBlockColorHandler(Block blk, RegisterColorHandlersEvent.Block event) { -// if (this.isTinted()) { -// if (this.stateProp != null) { -// final Map cmmap = new HashMap(); -// for (WesterosBlockStateRecord rec : this.states) { -// ColorMultHandler handler = getStateColorHandler(rec, this.blockName); -// cmmap.put(rec.stateID, handler); -// } -// event.register((BlockState state, BlockAndTintGetter world, BlockPos pos, int txtindx) -> -// cmmap.get(state.getValue(this.stateProp)).getColor(state, world, pos, txtindx), blk); -// final ColorMultHandler itemHandler = cmmap.get(this.states.get(0).stateID); -// } else { -// ColorMultHandler handler = getStateColorHandler(this, this.blockName); -// -// event.register((BlockState state, BlockAndTintGetter world, BlockPos pos, int txtindx) -> handler -// .getColor(state, world, pos, txtindx), blk); -// } -// } -// } -// -// // Handle registration of tint handling and other client rendering -// @OnlyIn(Dist.CLIENT) -// public static void registerVanillaBlockColorHandler(String blockName, Block blk, String colorMult, RegisterColorHandlersEvent.Block event) { -// ColorMultHandler handler = getColorHandler(colorMult, blockName); -// event.register((BlockState state, BlockAndTintGetter world, BlockPos pos, int txtindx) -> handler -// .getColor(state, world, pos, txtindx), blk); -// // If water shader, override global one too -// if (blockName.equals("minecraft:water") && (handler instanceof CustomColorMultHandler)) { -// final CustomColorMultHandler cchandler = (CustomColorMultHandler) handler; // crappy java lambda limitation workaround -// // TODO: biome modifiers maybe -//// BiomeColors.WATER_COLOR_RESOLVER = (Biome b, double tmp, double hum) -> cchandler.getColor(b, tmp, hum); -// } -// } -// -// // Handle registration of tint handling and other client rendering -// @OnlyIn(Dist.CLIENT) -// public void registerItemColorHandler(Block blk, RegisterColorHandlersEvent.Item event) { -// if (this.isTinted()) { -// if (this.stateProp != null) { -// final Map cmmap = new HashMap(); -// for (WesterosBlockStateRecord rec : this.states) { -// ColorMultHandler handler = getStateColorHandler(rec, this.blockName); -// cmmap.put(rec.stateID, handler); -// } -// final ColorMultHandler itemHandler = cmmap.get(this.states.get(0).stateID); -// event.register((ItemStack stack, int tintIndex) -> itemHandler.getItemColor(stack, tintIndex), blk); -// } else { -// ColorMultHandler handler = getStateColorHandler(this, this.blockName); -// event.register((ItemStack stack, int tintIndex) -> handler.getItemColor(stack, tintIndex), blk); -// } -// } -// } -// -// // Handle registration of tint handling and other client rendering -// @OnlyIn(Dist.CLIENT) -// public static void registerVanillaItemColorHandler(String blockName, Block blk, String colorMult, RegisterColorHandlersEvent.Item event) { -// ColorMultHandler handler = getColorHandler(colorMult, blockName); -// event.register((ItemStack stack, int tintIndex) -> handler.getItemColor(stack, tintIndex), blk); -// } - -// public void registerSoundEvents(RegisterEvent.RegisterHelper helper) { -// if (this.soundList != null) { -// for (String snd : this.soundList) { -// WesterosBlocks.registerSound(snd, helpear); -// } -// } -// } - - // Get customized collision box for default solid block -// public VoxelShape makeCollisionBoxShape() { -// if (collisionBoxes == null) { -// return Shapes.block(); // Default to solid block -// } -// VoxelShape s = Shapes.empty(); -// for (BoundingBox b : collisionBoxes) { -// s = Shapes.or(s, b.getAABB()); -// } -// return s; -// } - -// public String getLegacyBlockName() { -// if (legacyBlockID == null) return null; -// String v = legacyBlockID; -// int sqoff = v.indexOf('['); -// if (sqoff >= 0) { -// v = v.substring(0, sqoff); -// } -// String[] tok = v.split(":"); -// if ((tok.length > 2) || (tok[0].equals("minecraft"))) { -// return tok[0] + ":" + tok[1]; -// } -// return "westerosblocks:" + tok[0]; -// } -// -// public Map getLegacyBlockMap() { -// if (legacyBlockID == null) return null; -// Map mval = new HashMap(); -// if (legacyBlockID.indexOf('[') >= 0) { -// String p = legacyBlockID; -// int st = p.indexOf('['); -// int en = p.indexOf(']'); -// p = p.substring(st + 1, en); -// String[] ptoks = p.split(","); // Split at commas, if any -// for (String pair : ptoks) { -// String[] av = pair.split("="); -// if (av.length > 1) { -// mval.put(av[0], av[1]); -// } else { -// mval.put("variant", av[0]); -// } -// } -// return mval; -// } -// String[] tok = legacyBlockID.split(":"); -// if ((tok.length == 2) && tok[0].equals("minecraft")) return null; -// if (tok.length >= 2) { -// String v = tok[tok.length - 1]; -// if (v.indexOf('=') < 0) { -// if (!v.equals("default")) { -// mval.put("variant", v); -// } -// } else { -// String[] stok = v.split(","); -// for (String sv : stok) { -// String[] vtok = sv.split("="); -// if (vtok.length > 1) -// mval.put(vtok[0], vtok[1]); -// } -// } -// return mval; -// } -// return null; -// } - -// public static class StateProperty extends Property { -// public final ImmutableList values; -// public final ImmutableMap valMap; -// public final String defValue; -// -// public StateProperty(List stateIDs) { -// super("state", String.class); -// Map map = Maps.newHashMap(); -// List vals = new ArrayList(); -// int len = stateIDs.size(); -// for (int i = 0; i < len; i++) { -// String s = stateIDs.get(i); -// map.put(s, s); -// vals.add(s); -// } -// this.values = ImmutableList.copyOf(vals); -// this.valMap = ImmutableMap.copyOf(map); -// this.defValue = stateIDs.get(0); -// } -// -// @Override -// public Collection getPossibleValues() { -// return this.values; -// } -// -// @Override -// public boolean equals(Object obj) { -// if (this == obj) { -// return true; -// } else if (obj instanceof StateProperty && super.equals(obj)) { -// StateProperty stateproperty = (StateProperty) obj; -// return this.values.equals(stateproperty.values); -// } else { -// return false; -// } -// } -// -// @Override -// public int generateHashCode() { -// return 31 * super.generateHashCode() + this.values.hashCode(); -// } -// -// @Override -// public Optional getValue(String key) { -// String val = this.valMap.get(key); -// return (val != null) ? Optional.of(val) : Optional.empty(); -// } -// -// @Override -// public String getName(String val) { -// return val; -// } -// -// public int getIndex(String val) { -// int v = this.values.indexOf(val); -// return (v >= 0) ? v : 0; -// } -// } -// -// // Build 'state' property for the -// public StateProperty buildStateProperty() { -// return stateProp; -// } -// -// // Get default state ID -// public String getDefaultStateID() { -// if (this.states == null) return null; -// return this.states.get(0).stateID; -// } -//} diff --git a/needsported/WesterosBlockFactory.java b/needsported/WesterosBlockFactory.java deleted file mode 100644 index 82e780e20f..0000000000 --- a/needsported/WesterosBlockFactory.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.westerosblocks.needsported; - -import net.minecraft.world.level.block.Block; -import net.neoforged.neoforge.registries.RegisterEvent; - -// Abstract factory class : each custom block type needs to have one -public abstract class WesterosBlockFactory { - /* Build instance of given block type and given blknum within factory (replace for factories needing more than one block def) - * - * @param def - definition loaded for block - * @returns block based on definition - */ - public abstract Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper); -} diff --git a/needsported/WesterosBlockLifecycle.java b/needsported/WesterosBlockLifecycle.java deleted file mode 100644 index a9dead5369..0000000000 --- a/needsported/WesterosBlockLifecycle.java +++ /dev/null @@ -1,14 +0,0 @@ -//package com.westerosblocks.needsported; -// -//// Used to define the interfaces for properly priming one of our custom block definitions -//// Block definitions must also have constructor with WesterosBlockDef as parameter -//public interface WesterosBlockLifecycle { -// /** -// * Get definition for block -// */ -// public WesterosBlockDef getWBDefinition(); -// /** -// * Get block tags for block -// */ -// public String[] getBlockTags(); -//} diff --git a/needsported/WesterosBlockSetDef.java b/needsported/WesterosBlockSetDef.java deleted file mode 100644 index 4c9af93e1a..0000000000 --- a/needsported/WesterosBlockSetDef.java +++ /dev/null @@ -1,454 +0,0 @@ -//package com.westerosblocks.needsported; -// -//import java.util.List; -//import java.util.Map; -//import java.util.Arrays; -//import java.util.HashMap; -//import java.util.LinkedList; -//import java.util.ArrayList; -//import java.io.File; -//import java.io.FileWriter; -//import java.io.IOException; -//import java.nio.file.Path; -// -//import com.google.gson.Gson; -//import com.google.gson.GsonBuilder; -// -//import com.westeroscraft.westerosblocks.WesterosBlockDef.HarvestLevel; -//import com.westeroscraft.westerosblocks.WesterosBlockDef.RandomTextureSet; -// -//// -//// Template for block set configuration data (populated using GSON) -//// -//public class WesterosBlockSetDef { -// private static final float DEF_FLOAT = -999.0F; -// public static final int DEF_INT = -999; -// -// public static final List DEFAULT_VARIANTS = Arrays.asList("solid", "stairs", "slab", "wall", "fence", "hopper"); -// public static final List SUPPORTED_VARIANTS = Arrays.asList("solid", "stairs", "slab", "wall", "fence", "hopper", "tip", -// "carpet", "fence_gate", "half_door", "cover", "hollow_hopper", -// "log", "directional", "layer", "pane", "sand", "path", -// "window_frame", "window_frame_mullion", -// "arrow_slit", "arrow_slit_window", "arrow_slit_ornate"); -// public static final Map VARIANT_TYPES = new HashMap(); -// static { // For any variant not listed here, it is assumed that the type is the same as the variant string -// VARIANT_TYPES.put("stairs", "stair"); -// VARIANT_TYPES.put("hopper", "cuboid"); -// VARIANT_TYPES.put("tip", "cuboid"); -// VARIANT_TYPES.put("carpet", "cuboid"); -// VARIANT_TYPES.put("fence_gate", "fencegate"); -// VARIANT_TYPES.put("half_door", "cuboid-nsew"); -// VARIANT_TYPES.put("cover", "rail"); -// VARIANT_TYPES.put("hollow_hopper", "cuboid"); -// VARIANT_TYPES.put("directional", "cuboid-nsew"); -// VARIANT_TYPES.put("path", "cuboid"); -// VARIANT_TYPES.put("window_frame", "solid"); -// VARIANT_TYPES.put("window_frame_mullion", "solid"); -// VARIANT_TYPES.put("arrow_slit", "solid"); -// VARIANT_TYPES.put("arrow_slit_window", "solid"); -// VARIANT_TYPES.put("arrow_slit_ornate", "solid"); -// } -// public static final Map VARIANT_TEXTURES = new HashMap(); -// static { -// VARIANT_TEXTURES.put("solid", new String[]{ "bottom", "top", "west", "east", "south", "north" }); -// VARIANT_TEXTURES.put("stairs", new String[]{ "bottom", "top", "sides" }); -// VARIANT_TEXTURES.put("slab", new String[]{ "bottom", "top", "sides" }); -// VARIANT_TEXTURES.put("wall", new String[]{ "bottom", "top", "sides" }); -// VARIANT_TEXTURES.put("fence", new String[]{ "bottom", "top", "sides" }); -// VARIANT_TEXTURES.put("hopper", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("tip", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("carpet", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("fence_gate", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("half_door", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("cover", new String[]{ "cover" }); -// VARIANT_TEXTURES.put("hollow_hopper", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("log", new String[]{ "bottom", "top", "sides" }); -// VARIANT_TEXTURES.put("directional", new String[]{ "bottom", "top", "west", "east", "south", "north" }); -// VARIANT_TEXTURES.put("layer", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("pane", new String[]{ "sides", "top" }); -// VARIANT_TEXTURES.put("sand", new String[]{ "bottom", "top", "west", "east", "south", "north" }); -// VARIANT_TEXTURES.put("path", new String[]{ "sides" }); -// VARIANT_TEXTURES.put("window_frame", new String[]{ "window-topbottom", "window-topbottom", "window-frame" }); -// VARIANT_TEXTURES.put("window_frame_mullion", new String[]{ "window-topbottom", "window-topbottom", "window-frame-mullion" }); -// VARIANT_TEXTURES.put("arrow_slit", new String[]{ "window-topbottom", "window-topbottom", "arrow-slit" }); -// VARIANT_TEXTURES.put("arrow_slit_window", new String[]{ "window-topbottom", "window-topbottom", "arrow-slit-window" }); -// VARIANT_TEXTURES.put("arrow_slit_ornate", new String[]{ "window-topbottom", "window-topbottom", "arrow-slit-ornate" }); -// } -// -// public String baseBlockName; // Unique name to be used as a base for all the generated block names -// public String baseLabel = null; // Base label associated with blocks in set -// public List variants = null; // List of supported variants to create (solid, stair, slab, wall, fence, hopper) -// // By default, all of the above variants will be created -// -// public Map altNames = null; // Alternative names to use for particular variants (optional) -// public Map altLabels = null; // Alternative labels to use for particular variants (optional) -// -// public float hardness = DEF_FLOAT; // Block hardness -// public String stepSound = null; // Step sound (powder, wood, gravel, grass, stone, metal, glass, cloth, sand, -// // snow, ladder, anvil) -// public String material = null; // Generic material (ai, grass, ground, wood, rock, iron, anvil, water, lava, -// // leaves, plants, vine, sponge, etc) -// public float resistance = DEF_FLOAT; // Explosion resistance -// public int lightOpacity = DEF_INT; // Light opacity -// public List harvestLevel = null; // List of harvest levels -// public int fireSpreadSpeed = 0; // Fire spread speed -// public int flamability = 0; // Flamability -// public String creativeTab = null; // Creative tab for items -// -// public List customTags = null; // If block should add any custom tags -// public Map> altCustomTags = null; // Allows idiosyncratic tags for particular variants -// -// public Map types = null; // Map of type attributes for each variant -// -// public boolean alphaRender = false; // If true, do render on pass 2 (for alpha blending) -// public Boolean ambientOcclusion = null; // Set ambient occlusion (default is true) -// public boolean nonOpaque = false; // If true, does not block visibility of shared faces (solid blocks) and doesn't allow torches -// -// public Map> altTextures = null; // Allows idiosyncratic textures for particular variants -// public Map> altRandomTextures = null; // Allows idiosyncratic randomTextures for particular variants -// public Map> altOverlayTextures = null; // Allows idiosyncratic overlayTextures for particular variants -// -// public Map textures = null; // Map of textures to use for each variant (for single texture set) -// public List randomTextures = null; // Defines sets of textures used for additional random models, -// // for each variant (if supported) -// public Map overlayTextures = null; // Map of overlay textures (for types supporting overlays) -// -// public float lightValue = 0.0F; // Emitted light level (0.0-1.0) -// public String colorMult = "#FFFFFF"; // Color multiplier ("#rrggbb' for fixed value, 'foliage', 'grass', 'water') -// -// public List states = null; -// -// -// public static class RandomTextureMap { -// public Map textures = null; // List of textures (for single texture set) -// public Integer weight = null; // Weight for texture set (default = 1) -// }; -// -// // Used for sets that support multiple blockstates -// public static class StateRecord { -// public String stateID = null; -// public String excludeVariants = null; -// public float lightValue = 0.0F; -// public String colorMult = "#FFFFFF"; -// -// public Map> altTextures = null; -// public Map> altRandomTextures = null; -// public Map> altOverlayTextures = null; -// -// public Map textures = null; -// public List randomTextures = null; -// public Map overlayTextures = null; -// } -// -// -// public List generateBlockDefs() { -// List blockDefs = new LinkedList(); -// -// this.types = preprocessVariantMap(this.types); -// this.altCustomTags = preprocessVariantMap(this.altCustomTags); -// this.altTextures = preprocessVariantMap(this.altTextures); -// this.altRandomTextures = preprocessVariantMap(this.altRandomTextures); -// this.altOverlayTextures = preprocessVariantMap(this.altOverlayTextures); -// -// for (String variant : WesterosBlockSetDef.SUPPORTED_VARIANTS) { -// if (this.variants != null && !variants.contains(variant)) -// continue; -// else if (this.variants == null && !WesterosBlockSetDef.DEFAULT_VARIANTS.contains(variant)) -// continue; -// -// WesterosBlockDef variantDef = new WesterosBlockDef(); -// -// // Automatically derive name for variant (or use alt name if provided) -// String suffix = (variant.equals("solid")) ? "" : variant; -// if (this.altNames != null && this.altNames.containsKey(variant)) { -// variantDef.blockName = this.altNames.get(variant); -// } -// else { -// variantDef.blockName = this.baseBlockName; -// if (!suffix.isEmpty()) -// variantDef.blockName += "_" + suffix; -// } -// -// // Automatically derive label for variant (or use alt label if provided) -// if (this.altLabels != null && this.altLabels.containsKey(variant)) { -// variantDef.label = this.altLabels.get(variant); -// } -// else if (this.baseLabel != null) { -// String suffix_label = (suffix.isEmpty()) ? "" : WesterosBlockSetDef.generateLabel(suffix); -// variantDef.label = this.baseLabel + " " + suffix_label; -// } -// else { -// variantDef.label = WesterosBlockSetDef.generateLabel(variantDef.blockName); -// } -// -// // Set blocktype for variant -// String blockType = WesterosBlockSetDef.VARIANT_TYPES.get(variant); -// if (blockType == null) -// blockType = variant; -// variantDef.blockType = blockType; -// -// // Copy general block definition properties to variant -// variantDef.hardness = this.hardness; -// variantDef.stepSound = this.stepSound; -// variantDef.material = this.material; -// variantDef.resistance = this.resistance; -// variantDef.lightOpacity = this.lightOpacity; -// variantDef.harvestLevel = this.harvestLevel; -// variantDef.fireSpreadSpeed = this.fireSpreadSpeed; -// variantDef.flamability = this.flamability; -// variantDef.creativeTab = this.creativeTab; -// variantDef.alphaRender = this.alphaRender; -// variantDef.ambientOcclusion = this.ambientOcclusion; -// variantDef.nonOpaque = this.nonOpaque; -// -// if (this.altCustomTags != null && this.altCustomTags.containsKey(variant)) { -// List tags = altCustomTags.get(variant); -// variantDef.customTags = (!tags.isEmpty()) ? tags : null; -// } -// else -// variantDef.customTags = this.customTags; -// -// // Copy type attribute for variant -// if (this.types != null && this.types.containsKey(variant)) { -// variantDef.type = this.types.get(variant); -// } -// else { -// // Enforce defaults for particular blocktypes -// if (variant.matches("stairs|wall|fence|pane")) -// variantDef.type = "unconnect:false"; -// else if (variant.contains("arrow_slit") || variant.contains("window_frame")) -// variantDef.type = "connectstate:true"; -// else if (variant.equals("cover")) -// variantDef.type = "allow-unsupported"; -// else -// variantDef.type = ""; -// } -// -// // Copy general block state record properties to variant -// variantDef.lightValue = this.lightValue; -// variantDef.colorMult = this.colorMult; -// -// // Process blocktypes with special attributes -// if (variant.equals("hopper")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0.3755f, 0f, 0.3755f, 0.6245f, 0.275f, 0.6245f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0.25f, 0.275f, 0.25f, 0.75f, 0.625f, 0.75f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0.625f, 0f, 1f, 1f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.equals("tip")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0.3755f, 0.625f, 0.3755f, 0.6245f, 1f, 0.6245f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0.25f, 0.275f, 0.25f, 0.75f, 0.625f, 0.75f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 0.275f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.equals("carpet")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 0.0625f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }) -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.equals("half_door")) { -// variantDef.boundingBox = new WesterosBlockDef.BoundingBox(0f, 0f, 0f, 0.1875f, 1f, 1f); -// } -// else if (variant.equals("hollow_hopper")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0.3755f, 0.16f, 0.3755f, 0.6245f, 0.275f, 0.6245f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0.25f, 0.275f, 0.25f, 0.75f, 0.625f, 0.75f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0.625f, 0f, 1f, 0.65f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0.625f, 0f, 0.125f, 1f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0.875f, 0.625f, 0f, 1f, 1f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0.625f, 0f, 1f, 1f, 0.125f, new int[] { 0, 0, 0, 0, 0, 0 }), -// new WesterosBlockDef.Cuboid(0f, 0.625f, 0.875f, 1f, 1f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }), -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.equals("directional")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 1f, 1f) -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.equals("path")) { -// WesterosBlockDef.Cuboid[] cuboids = { -// new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 0.9375f, 1f, new int[] { 0, 0, 0, 0, 0, 0 }) -// }; -// variantDef.cuboids = Arrays.asList(cuboids); -// } -// else if (variant.contains("arrow_slit") || variant.contains("window_frame")) { -// variantDef.nonOpaque = true; -// variantDef.lightOpacity = 0; -// WesterosBlockDef.BoundingBox[] collisionBoxes = { -// new WesterosBlockDef.BoundingBox(0f, 0f, 0f, 0.2f, 1f, 0.2f), -// new WesterosBlockDef.BoundingBox(0.8f, 0f, 0f, 1f, 1f, 0.2f), -// new WesterosBlockDef.BoundingBox(0f, 0f, 0.8f, 0.2f, 1f, 1f), -// new WesterosBlockDef.BoundingBox(0.8f, 0f, 0.8f, 1f, 1f, 1f) -// }; -// variantDef.collisionBoxes = Arrays.asList(collisionBoxes); -// WesterosBlockDef.BoundingBox[] supportBoxes = { -// new WesterosBlockDef.BoundingBox(0f, 0f, 0f, 1f, 1f, 1f) -// }; -// variantDef.supportBoxes = Arrays.asList(supportBoxes); -// } -// -// // If a variant has an alt texture list defined, use it, otherwise create texture lists for this variant type -// variantDef.textures = pickVariantTextures(this.textures, this.altTextures, variant); -// variantDef.randomTextures = pickVariantRandomTextures(this.randomTextures, this.altRandomTextures, variant); -// variantDef.overlayTextures = pickVariantTextures(this.overlayTextures, this.altOverlayTextures, variant); -// -// // If block set has multistate, create list of states for each variant -// if (this.states != null) { -// List states = new ArrayList(); -// for (StateRecord sr : this.states) { -// if (sr.excludeVariants == null || !sr.excludeVariants.contains(variant)) { -// WesterosBlockStateRecord newsr = new WesterosBlockStateRecord(); -// newsr.stateID = sr.stateID; -// newsr.lightValue = sr.lightValue; -// newsr.colorMult = sr.colorMult; -// newsr.textures = pickVariantTextures(sr.textures, sr.altTextures, variant); -// newsr.randomTextures = pickVariantRandomTextures(sr.randomTextures, sr.altRandomTextures, variant); -// newsr.overlayTextures = pickVariantTextures(sr.overlayTextures, sr.altOverlayTextures, variant); -// states.add(newsr); -// } -// } -// // Make sure states list is not empty or singleton after exclusions -// variantDef.states = (states.size() > 1) ? states : null; -// } -// // By default, turn on toggleOnUse if block set has multistate -// if (variantDef.states != null && (this.types == null || !this.types.containsKey(variant))) { -// variantDef.type = (variantDef.type == null || variantDef.type.equals("")) ? "toggleOnUse" : variantDef.type+",toggleOnUse"; -// } -// -// blockDefs.add(variantDef); -// } -// -// return blockDefs; -// } -// -// public static List pickVariantTextures(Map textures, Map> altTextures, String variant) { -// if (altTextures != null && altTextures.containsKey(variant)) -// return altTextures.get(variant); -// else -// return getTexturesForVariant(preprocessTextureMap(textures), variant); -// } -// -// public static List pickVariantRandomTextures(List randomTextures, Map> altRandomTextures, String variant) { -// if (altRandomTextures != null && altRandomTextures.containsKey(variant)) -// return altRandomTextures.get(variant); -// else -// return getRandomTexturesForVariant(preprocessRandomTextureMaps(randomTextures), variant); -// } -// -// // Allow for multiple variants to be provided in one map entry, separated by commas -// public static Map preprocessVariantMap(Map map) { -// if (map == null) -// return null; -// -// Map newMap = new HashMap(); -// for (Map.Entry entry : map.entrySet()) { -// String key = entry.getKey(); -// T value = entry.getValue(); -// if (!key.contains(",")) -// newMap.put(key, value); -// else { -// String[] variants = key.split(","); -// for (String variant : variants) -// newMap.put(variant, value); -// } -// } -// return newMap; -// } -// -// public static String generateLabel(String name) { -// if (name.isEmpty() || name.equals("_")) -// return ""; -// -// String[] words = name.split("_"); -// String label = ""; -// for (String word : words) { -// String wordCap = word.substring(0,1).toUpperCase() + word.substring(1); -// label += wordCap + " "; -// } -// return label.trim(); -// } -// -// public static Map preprocessTextureMap(Map textureMap) { -// if (textureMap == null) -// return null; -// -// if (textureMap.containsKey("all")) { -// textureMap.put("bottom", textureMap.get("all")); -// textureMap.put("top", textureMap.get("all")); -// textureMap.put("sides", textureMap.get("all")); -// } -// -// if (!textureMap.containsKey("west") && textureMap.containsKey("sides")) -// textureMap.put("west", textureMap.get("sides")); -// if (!textureMap.containsKey("east") && textureMap.containsKey("sides")) -// textureMap.put("east", textureMap.get("sides")); -// if (!textureMap.containsKey("south") && textureMap.containsKey("sides")) -// textureMap.put("south", textureMap.get("sides")); -// if (!textureMap.containsKey("north") && textureMap.containsKey("sides")) -// textureMap.put("north", textureMap.get("sides")); -// -// // fallback if "sides" not explicitly specified -// if (!textureMap.containsKey("sides") && textureMap.containsKey("bottom")) -// textureMap.put("sides", textureMap.get("bottom")); -// -// // other variant-specific fallback rules -// // if (!textureMap.containsKey("window-topbottom") && textureMap.containsKey("bottom")) -// // textureMap.put("window-topbottom", textureMap.get("bottom")); -// if (!textureMap.containsKey("window-topbottom")) -// textureMap.put("window-topbottom", "transparent"); -// -// if (!textureMap.containsKey("cover") && textureMap.containsKey("sides")) -// textureMap.put("cover", textureMap.get("sides")); -// -// return textureMap; -// } -// -// public static List preprocessRandomTextureMaps(List randomTextureMaps) { -// if (randomTextureMaps == null) -// return null; -// -// for (int i = 0; i < randomTextureMaps.size(); i++) { -// RandomTextureMap updated = randomTextureMaps.get(i); -// updated.textures = preprocessTextureMap(updated.textures); -// randomTextureMaps.set(i, updated); -// } -// return randomTextureMaps; -// } -// -// public static List getTexturesForVariant(Map textureMap, String variant) { -// if (textureMap == null) -// return null; -// -// List textureList = new LinkedList(); -// -// for (String texture : WesterosBlockSetDef.VARIANT_TEXTURES.get(variant)) { -// if (textureMap.containsKey(texture)) textureList.add(textureMap.get(texture)); -// } -// -// return (!textureList.isEmpty()) ? textureList : null; -// } -// -// public static List getRandomTexturesForVariant(List randomTextureMaps, String variant) { -// if (randomTextureMaps == null) -// return null; -// -// List randomTextures = new LinkedList(); -// -// for (RandomTextureMap randomTextureMap : randomTextureMaps) { -// RandomTextureSet randomTextureSet = new RandomTextureSet(); -// randomTextureSet.textures = getTexturesForVariant(randomTextureMap.textures, variant); -// randomTextureSet.weight = randomTextureMap.weight; -// if (randomTextureSet.textures != null && !randomTextureSet.textures.isEmpty()) -// randomTextures.add(randomTextureSet); -// } -// -// return (!randomTextures.isEmpty()) ? randomTextures : null; -// } -//} diff --git a/needsported/WesterosBlockStateRecord.java b/needsported/WesterosBlockStateRecord.java deleted file mode 100644 index 50a7282f58..0000000000 --- a/needsported/WesterosBlockStateRecord.java +++ /dev/null @@ -1,151 +0,0 @@ -//package com.westerosblocks.needsported; -// -//import java.util.ArrayList; -//import java.util.Collections; -//import java.util.List; -// -//import com.westeroscraft.westerosblocks.WesterosBlockDef.BoundingBox; -//import com.westeroscraft.westerosblocks.WesterosBlockDef.Cuboid; -//import com.westeroscraft.westerosblocks.WesterosBlockDef.RandomTextureSet; -// -//import net.minecraft.world.phys.shapes.Shapes; -//import net.minecraft.world.phys.shapes.VoxelShape; -// -//public class WesterosBlockStateRecord { -// public String stateID = null; // If not defined, value is "stateN" -// public BoundingBox boundingBox = null; // Bounding box -// public List cuboids = null; // List of cuboids composing block (for 'cuboid', and others) -// public List collisionBoxes = null; // For 'solid', used for raytrace (arrow shots) -// public List supportBoxes = null; // For 'solid', used for support/connection (fences, walls, torches) -// public Boolean isCustomModel = false; // If set and true, don't generate new custom model (hand crafted) -// public List textures = null; // List of textures (for single texture set) -// public List randomTextures = null; // On supported blocks (solid, leaves, slabs, stairs), -// // defines sets of textures used for additional random models -// // If randomTextures is used, textures is ignored -// public List overlayTextures = null; // List of overlay textures (for types supporting overlays) -// public boolean rotateRandom = false; // Set random rotation for supporting blocks (solid, leaves) -// public float lightValue = 0.0F; // Emitted light level (0.0-1.0) -// public String colorMult = "#FFFFFF"; // Color multiplier ("#rrggbb' for fixed value, 'foliage', 'grass', 'water') -// public List colorMults = null; // Allows for custom color handlers with multiple colormaps (accessed via tintindex in models) -// public int rotYOffset = 0; // Additional rotation around Y axis (only for cuboid blocks with rotation) - done in blockstate 0, 90, 180, 270 -// public void doStateRecordInit() { -// // If just base textures, generate equivalent random textures (simpler logic for blocks that support them -// if (this.randomTextures == null) { -// if (this.textures == null) this.textures = new ArrayList(); // Always have at least array; -// this.randomTextures = new ArrayList(); -// RandomTextureSet set = new RandomTextureSet(); -// set.textures = textures; -// this.randomTextures.add(set); -// } -// // If we have bounding box, but no cuboids, make trivial cuboid -// if ((this.boundingBox != null) && (this.cuboids == null)) { -// Cuboid c = new Cuboid(); -// c.xMin = this.boundingBox.xMin; -// c.xMax = this.boundingBox.xMax; -// c.yMin = this.boundingBox.yMin; -// c.yMax = this.boundingBox.yMax; -// c.zMin = this.boundingBox.zMin; -// c.zMax = this.boundingBox.zMax; -// this.cuboids = Collections.singletonList(c); -// } -// // If cuboids but no bounding box, compute bounding box -// if ((this.cuboids != null) && (this.boundingBox == null)) { -// this.boundingBox = new BoundingBox(); -// this.boundingBox.xMin = this.boundingBox.yMin = this.boundingBox.zMin = 1.0F; -// this.boundingBox.xMax = this.boundingBox.yMax = this.boundingBox.zMax = 0.0F; -// for (BoundingBox bb : this.cuboids) { -// if (bb.xMin < this.boundingBox.xMin) -// this.boundingBox.xMin = bb.xMin; -// if (bb.yMin < this.boundingBox.yMin) -// this.boundingBox.yMin = bb.yMin; -// if (bb.zMin < this.boundingBox.zMin) -// this.boundingBox.zMin = bb.zMin; -// if (bb.xMax > this.boundingBox.xMax) -// this.boundingBox.xMax = bb.xMax; -// if (bb.yMax > this.boundingBox.yMax) -// this.boundingBox.yMax = bb.yMax; -// if (bb.zMax > this.boundingBox.zMax) -// this.boundingBox.zMax = bb.zMax; -// } -// } -// } -// -// public String getTextureByIndex(int idx) { -// RandomTextureSet set = getRandomTextureSet(0); -// if (set != null) { -// return set.getTextureByIndex(idx); -// } -// return null; -// } -// -// public String getOverlayTextureByIndex(int idx) { -// if (this.overlayTextures != null) { -// return this.overlayTextures.get(Math.min(idx,this.overlayTextures.size()-1)); -// } -// return null; -// } -// -// // Get number of random texture sets -// public int getRandomTextureSetCount() { -// if ((randomTextures != null) && (randomTextures.size() > 0)) { -// return randomTextures.size(); -// } -// return 0; -// } -// -// // Get given random texture set -// public RandomTextureSet getRandomTextureSet(int setnum) { -// if ((randomTextures != null) && (randomTextures.size() > 0)) { -// if (setnum >= randomTextures.size()) { -// setnum = randomTextures.size() - 1; -// } -// return randomTextures.get(setnum); -// } -// return null; -// } -// -// public List getCuboidList() { -// return cuboids; -// } -// -// public List getCollisionBoxList() { -// if (this.collisionBoxes != null) -// return this.collisionBoxes; -// return Collections.emptyList(); -// } -// // Get number of base textures -// public int getTextureCount() { -// RandomTextureSet set = getRandomTextureSet(0); -// if (set != null) { -// return set.getTextureCount(); -// } -// return 0; -// } -// -// // Get customized support box -// public VoxelShape makeSupportBoxShape(List def) { -// VoxelShape s = Shapes.empty(); -// if (supportBoxes != null) { def = supportBoxes; } -// if (def != null) { -// for (BoundingBox b : def) { -// s = Shapes.or(s, b.getAABB()); -// } -// } -// return s; -// } -// -// public boolean isTinted() { -// return (((colorMult != null) && (colorMult.equals("#FFFFFF") == false)) || (colorMults != null)); -// } -// public boolean isCustomModel() { -// return isCustomModel.booleanValue(); -// } -// -// public boolean equals(WesterosBlockStateRecord other) { -// if (this.stateID == null) { -// return (other.stateID == null); -// } -// return this.stateID.equals(other.stateID); -// } -// -//} diff --git a/needsported/WesterosBlockTags.java b/needsported/WesterosBlockTags.java deleted file mode 100644 index c410265833..0000000000 --- a/needsported/WesterosBlockTags.java +++ /dev/null @@ -1,7 +0,0 @@ -//package com.westerosblocks.needsported; -// -//public class WesterosBlockTags { -// public String[] blockNames; -// public String customTag; -//}; -// diff --git a/needsported/WesterosBlockTileEntity.java b/needsported/WesterosBlockTileEntity.java deleted file mode 100644 index 7b268e32fd..0000000000 --- a/needsported/WesterosBlockTileEntity.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.westerosblocks.needsported; - -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.neoforged.neoforge.registries.DeferredRegister; - -// Used to define the interfaces for properly priming one of our custom block definitions -// Block definitions must also have constructor with WesterosBlockDef as parameter -public interface WesterosBlockTileEntity { - public BlockEntityType getBlockEntityType(DeferredRegister> registry, Block blk); -} diff --git a/needsported/WesterosBlocks.java b/needsported/WesterosBlocks.java deleted file mode 100644 index 0b3b360a8a..0000000000 --- a/needsported/WesterosBlocks.java +++ /dev/null @@ -1,652 +0,0 @@ -package com.westerosblocks.needsported; - -import com.westerosblocks.block.WesterosBlockDef; -import com.westeroscraft.westerosblocks.blocks.AuxileryUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.DoorBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.core.BlockPos; -import net.minecraft.CrashReport; -import net.minecraft.ReportedException; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModContainer; -import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.fml.common.Mod; -import net.neoforged.fml.config.ModConfig; -import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; -import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.neoforged.fml.loading.FMLEnvironment; -import net.neoforged.fml.loading.FMLPaths; -import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; -import net.neoforged.neoforge.client.gui.ConfigurationScreen; -import net.neoforged.neoforge.client.gui.IConfigScreenFactory; -import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.server.ServerStoppingEvent; -import net.neoforged.neoforge.registries.DeferredRegister; -import net.neoforged.neoforge.registries.RegisterEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.gson.Gson; -import com.google.gson.JsonParseException; -import com.google.gson.JsonIOException; -import com.google.gson.JsonSyntaxException; -import com.westeroscraft.westerosblocks.blocks.WCHalfDoorBlock; -import com.westeroscraft.westerosblocks.modelexport.ModelExport; -import com.westeroscraft.westerosblocks.modelexport.ModelExportFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.BufferedReader; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - - -@Mod(WesterosBlocks.MOD_ID) -public class WesterosBlocks { -// public static final String MOD_ID = "westerosblocks"; -// public static final Logger log = LogManager.getLogger(); - -// public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(WesterosBlocks.MOD_ID); -// public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(WesterosBlocks.MOD_ID); -// public static final DeferredRegister SOUND_EVENTS = -// DeferredRegister.create(BuiltInRegistries.SOUND_EVENT, WesterosBlocks.MOD_ID); - -// public static WesterosBlockConfig customConfig; - -// public static WesterosBlockDef[] customBlockDefs; - -// public static WesterosBlockDef[] getCustomBlockDefs() { -// return customBlockDefs; -// } - -// public static HashMap customBlocksByName; -// -// public static Block[] customBlocks = new Block[0]; -// -// public static Path modConfigPath; -// -// public static WesterosBlockColorMap[] colorMaps; -// -// public static WesterosItemMenuOverrides[] menuOverrides; - - public WesterosBlocks(IEventBus modEventBus, ModContainer modContainer) { - modEventBus.addListener(this::doClientStuff); - modEventBus.addListener(this::loadComplete); - modEventBus.addListener(this::onCommonSetupEvent); - - // Register ourselves for server and other game events we are interested in - NeoForge.EVENT_BUS.register(this); - - Path configPath = FMLPaths.CONFIGDIR.get(); - - modConfigPath = Paths.get(configPath.toAbsolutePath().toString(), MOD_ID); - - // Create the config folder - try { - Files.createDirectory(modConfigPath); - } catch (FileAlreadyExistsException e) { - // Do nothing - } catch (IOException e) { - log.error("Failed to create westerosblocks config directory", e); - } - - BLOCKS.register(modEventBus); - ITEMS.register(modEventBus); - SOUND_EVENTS.register(modEventBus); - WesterosCreativeModeTabs.register(modEventBus); - // Register the setup method for tile entities - WesterosBlockDef.TILE_ENTITY_TYPES.register(modEventBus); - - // Register our mod's ModConfigSpec so that FML can create and load the config file for us -// modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC); - - // This will use NeoForge's ConfigurationScreen to display this mod's configs -// if (FMLEnvironment.dist.isClient()) { -// modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new); -// } - } - -// private void doClientStuff(final FMLClientSetupEvent event) { -// // do something that can only be done on the client -// log.info("Got game settings {}", event.description()); -// ClientSetup.initRenderRegistry(); -// } - - private void loadComplete(final FMLLoadCompleteEvent event) { - // Initialize with standard block IDs - if (Config.blockDevMode) { - log.info("Block dev mode enabled : block export processing will be done to " + modConfigPath + "/assets/" - + MOD_ID); - } - // Do blocks state export here - if (Config.blockDevMode) { - // Clean up old export - deleteDirectory(new File(modConfigPath.toFile(), "assets")); - deleteDirectory(new File(modConfigPath.toFile(), "data")); - - for (int i = 0; i < customBlockDefs.length; i++) { - if (customBlockDefs[i] == null) - continue; - Block blk = customBlocksByName.get(customBlockDefs[i].blockName); - if (blk != null) { - ModelExport exp = ModelExportFactory.forBlock(blk, customBlockDefs[i], modConfigPath.toFile()); - if (exp != null) { - try { - exp.doBlockStateExport(); - exp.doModelExports(); - // If list, roll through choices as legacyBlockID - if (customBlockDefs[i].legacyBlockIDList != null) { - for (String legacyid : customBlockDefs[i].legacyBlockIDList) { - customBlockDefs[i].legacyBlockID = legacyid; - exp.doWorldConverterMigrate(); - ModelExport.addWorldConverterItemMap(legacyid, customBlockDefs[i].blockName); - } - customBlockDefs[i].legacyBlockID = null; - } else if (customBlockDefs[i].legacyBlockID != null) { - exp.doWorldConverterMigrate(); - ModelExport.addWorldConverterItemMap(customBlockDefs[i].legacyBlockID, customBlockDefs[i].blockName); - } - } catch (IOException iox) { - log.warn(String.format("Error exporting block %s - %s", blk.getName(), iox)); - } - } - } - } - try { - ModelExport.writeNLSFile(modConfigPath); - } catch (IOException iox) { - log.warn(String.format("Error writing NLS - %s", iox)); - } - try { - ModelExport.writeTagDataFiles(modConfigPath); - } catch (IOException iox) { - log.warn(String.format("Error writing tag data files - %s", iox)); - } - try { - ModelExport.writeCustomTagDataFiles(modConfigPath, customConfig); - } catch (IOException iox) { - log.warn(String.format("Error writing custom tag data files - %s", iox)); - } - try { - ModelExport.writeWorldConverterFile(modConfigPath); - } catch (IOException iox) { - log.warn(String.format("Error writing WorldConfig mapping - %s", iox)); - } - try { - ModelExport.writeDynmapOverridesFile(modConfigPath); - } catch (IOException iox) { - log.warn(String.format("Error writing Dynmap Overrides - %s", iox)); - } - try { - ModelExport.writeWorldConverterItemMapFile(modConfigPath); - } catch (IOException iox) { - log.warn(String.format("Error writing WorldConfig item mapping - %s", iox)); - } - } - } - - public static void crash(Exception x, String msg) { - throw new ReportedException(new CrashReport(msg, x)); - } - - public static void crash(String msg) { - crash(new Exception(), msg); - } - -// @EventBusSubscriber(modid = WesterosBlocks.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) -// public static class ColorHandler { -// @SubscribeEvent -// public static void registerItemColors(RegisterColorHandlersEvent.Item event) { -// for (Block blk : WesterosBlocks.customBlocks) { -// if (blk instanceof WesterosBlockLifecycle) { -// WesterosBlockDef def = ((WesterosBlockLifecycle) blk).getWBDefinition(); -// if (def != null) { -// def.registerItemColorHandler(blk, event); -// } -// } -// } -// if (WesterosBlocks.colorMaps != null) { -// WesterosBlocks.log.info("Initializing " + WesterosBlocks.colorMaps.length + " custom color maps"); -// for (WesterosBlockColorMap map : WesterosBlocks.colorMaps) { -// for (String bn : map.blockNames) { -// Block blk = WesterosBlocks.findBlockByName(bn, MOD_ID); -// if (blk != null) { -// WesterosBlockDef.registerVanillaItemColorHandler(bn, blk, map.colorMult, event); -// } -// } -// } -// } -// } -// -// @SubscribeEvent -// public static void registerBlockColors(RegisterColorHandlersEvent.Block event) { -// for (Block blk : WesterosBlocks.customBlocks) { -// if (blk instanceof WesterosBlockLifecycle) { -// WesterosBlockDef def = ((WesterosBlockLifecycle) blk).getWBDefinition(); -// if (def != null) { -// def.registerBlockColorHandler(blk, event); -// } -// } -// } -// if (WesterosBlocks.colorMaps != null) { -// WesterosBlocks.log.info("Initializing " + WesterosBlocks.colorMaps.length + " custom color maps"); -// for (WesterosBlockColorMap map : WesterosBlocks.colorMaps) { -// for (String bn : map.blockNames) { -// Block blk = WesterosBlocks.findBlockByName(bn, "minecraft"); -// if (blk != null) { -// WesterosBlockDef.registerVanillaBlockColorHandler(bn, blk, map.colorMult, event); -// } -// } -// } -// } -// } -// } - - @EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD) - public static class RegistryEvents { - private static boolean didInit = false; - - public static void initialize() { - if (didInit) return; - - // Initialize - log.info("initialize start"); - WesterosBlockDef.initialize(); - // TODO: maybe need biome modifiers? https://docs.neoforged.net/docs/worldgen/biomemodifier/#applying-biome-modifiers - // If snow-in-taiga -// if (Config.snowInTaiga) { -// Biome b = ForgeRegistries.BIOMES.getValue(ResourceLocation.fromNamespaceAndPath("minecraft","taiga")); -// if (b != null) { -// b.climateSettings.temperature = -0.5F; -// b.climateSettings.precipitation = Biome.Precipitation.SNOW; -// } -// log.info("Enabled snow in TAIGA"); -// } - - // Read our block definition resource - try { - customConfig = loadBlockConfig("/WesterosBlocks.json"); - } catch (BlockConfigNotFoundException ex) { - crash("WesterosBlocks couldn't find its block definition resource"); - return; - } catch (JsonSyntaxException iox) { - crash(iox, "WesterosBlocks couldn't parse its block definition"); - return; - } catch (JsonIOException iox) { - crash(iox, "WesterosBlocks couldn't read its block definition"); - return; - } - if (customConfig == null) { - crash("WesterosBlocks couldn't read its block definition"); - return; - } - - customBlockDefs = getBlockDefs(customConfig); - log.info("Loaded " + customBlockDefs.length + " block definitions"); - - // Validate custom block definitions against old copy (if one exists) - if (validateDefs(customBlockDefs) == false) { - log.error("Some block names or states have been removed relative to oldWesterosBlocks.json"); - } - - if (WesterosBlockDef.sanityCheck(customBlockDefs) == false) { - crash("WesterosBlocks.json failed sanity check"); - return; - } - // Register custom tags - ModelExport.declareCustomTags(customConfig); - didInit = true; - log.info("initialize done"); - } - - @SubscribeEvent - public static void onBlocksRegistry(final RegisterEvent event) { - event.register(SOUND_EVENTS.getRegistryKey(), (helper) -> { - initialize(); - for (WesterosBlockDef customBlockDef : customBlockDefs) { - if (customBlockDef == null) - continue; - // Register sound events - customBlockDef.registerSoundEvents(helper); - } - }); - event.register(BLOCKS.getRegistryKey(), (helper) -> { - log.info("block register start"); - // Do initialization, if needed - initialize(); - - // Construct custom block definitions - List blklist = new LinkedList(); - customBlocksByName = new HashMap(); - HashMap countsByType = new HashMap(); - int blockcount = 0; - - for (WesterosBlockDef customBlock : customBlockDefs) { - if (customBlock == null) - continue; - Block blk = customBlock.createBlock(helper); - - if (blk != null) { - blklist.add(blk); - customBlocksByName.put(customBlock.blockName, blk); - // Add to counts - Integer cnt = countsByType.get(customBlock.blockType); - cnt = (cnt == null) ? 1 : (cnt + 1); - countsByType.put(customBlock.blockType, cnt); - blockcount++; - - } else { - crash("Invalid block definition for " + customBlock.blockName + " - aborted during load()"); - return; - } - } - customBlocks = blklist.toArray(new Block[blklist.size()]); - WesterosBlockDef.dumpBlockPerf(); - // Dump information for external mods - WesterosBlocksCompatibility.dumpBlockSets(customConfig.blockSets, modConfigPath); - WesterosBlocksCompatibility.dumpWorldPainterConfig(customBlocks, modConfigPath); - // Brag on block type counts - log.info("Count of custom blocks by type:"); - for (String type : countsByType.keySet()) { - log.info(type + ": " + countsByType.get(type) + " blocks"); - } - log.info("TOTAL: " + blockcount + " blocks"); - colorMaps = customConfig.colorMaps; - menuOverrides = customConfig.menuOverrides; - log.info("block register done"); - }); - - } - -// @SubscribeEvent -// public static void buildContents(BuildCreativeModeTabContentsEvent event) { -// if (menuOverrides != null) { -// for (WesterosItemMenuOverrides mo : menuOverrides) { -// if (mo.blockNames != null) { -// for (String bn : mo.blockNames) { -// log.info("bnname: {}", bn); -// Item itm = BuiltInRegistries.ITEM.get(ResourceLocation.parse(bn)); -// if (itm == null) { -// log.warn("Item for " + bn + " not found - cannot override"); -// } else { -// CreativeModeTab tab = null; -// if (mo.creativeTab != null) { -// log.warn("this work?"); -// tab = WesterosBlockDef.getCreativeTab(mo.creativeTab); -// } -// if (event.getTab() == tab) { -// event.accept(itm); -// } -// log.info("Item for " + bn + " set to tab " + mo.creativeTab); -// } -// } -// } -// } -// } -// Set blockItems = AuxileryUtils.BLOCK_ITEM_TABS.get(event.getTab()); -// if (blockItems != null) { -// for (BlockItem item : blockItems) { -// event.accept(item); -// } -// } -// -// } - - - } - -// public static WesterosBlockConfig loadBlockConfig(String filename) throws BlockConfigNotFoundException, JsonParseException { -// // Read our block definition resource -// WesterosBlockConfig config; -// InputStream in = WesterosBlocks.class.getResourceAsStream(filename); -// if (in == null) { -// throw new BlockConfigNotFoundException(); -// } -// BufferedReader rdr = new BufferedReader(new InputStreamReader(in)); -// Gson gson = new Gson(); -// try { -// config = gson.fromJson(rdr, WesterosBlockConfig.class); -// } catch (JsonParseException iox) { -// throw iox; -// } finally { -// if (in != null) { -// try { -// in.close(); -// } catch (IOException iox) { -// } -// ; -// in = null; -// } -// if (rdr != null) { -// try { -// rdr.close(); -// } catch (IOException iox) { -// } -// ; -// rdr = null; -// } -// } -// return config; -// } - -// public static class BlockConfigNotFoundException extends Exception { -// public BlockConfigNotFoundException() { -// } -// -// public BlockConfigNotFoundException(String message) { -// super(message); -// } -// } - - // Expand block set definitions to obtain the full block definition list -// public static WesterosBlockDef[] getBlockDefs(WesterosBlockConfig config) { -// WesterosBlockSetDef[] blockSetDefs = config.blockSets; -// WesterosBlockDef[] blockDefs = config.blocks; -// List expandedBlockDefs = new LinkedList(Arrays.asList(blockDefs)); -// for (int i = 0; i < blockSetDefs.length; i++) { -// if (blockSetDefs[i] == null) -// continue; -// List variantBlockDefs = blockSetDefs[i].generateBlockDefs(); -// expandedBlockDefs.addAll(variantBlockDefs); -// } -// return expandedBlockDefs.toArray(new WesterosBlockDef[expandedBlockDefs.size()]); -// } - -// public static Block findBlockByName(String blkname, String namespace) { -// Block blk = customBlocksByName.get(blkname); -// if (blk != null) return blk; -// ResourceLocation rl = ResourceLocation.parse(blkname); -// if (rl.getNamespace().equals(namespace)) { -// blk = customBlocksByName.get(rl.getPath()); -// } -// if (blk != null) { -// return blk; -// } -// blk = BuiltInRegistries.BLOCK.get(rl); -// return blk; -// } - - // Load in oldWesterosBlocks.json, if it exists, and use it as a "source of truth" for - // validating modifications to WesterosBlocks.json. - // The important things to check are that all of the block names in oldWesterosBlocks.json - // are preserved, and that all of the state-related attributes for each block are preserved. -// public static boolean validateDefs(WesterosBlockDef[] defs) { -// WesterosBlockDef[] validationDefs; -// try { -// validationDefs = getBlockDefs(loadBlockConfig("/oldWesterosBlocks.json")); -// } catch (BlockConfigNotFoundException ex) { -// log.warn("no oldWesterosBlocks.json found for validation; skipping"); -// return true; -// } catch (JsonParseException ex) { -// log.warn("couldn't read oldWesterosBlocks.json block definition; skipping"); -// return true; -// } -// if (validationDefs == null) { -// log.warn("couldn't read oldWesterosBlocks.json block definition; skipping"); -// return true; -// } -// -// return WesterosBlockDef.compareBlockDefs(defs, validationDefs); -// } - -// private static HashMap registered_sounds = new HashMap(); -// -// public static SoundEvent registerSound(String soundName, RegisterEvent.RegisterHelper helper) { -// SoundEvent event = registered_sounds.get(soundName); -// if (event == null) { -// ResourceLocation location = ResourceLocation.fromNamespaceAndPath(MOD_ID, soundName); -// event = SoundEvent.createVariableRangeEvent(location); -// -//// SOUND_EVENTS.register(soundName, () -> finalEvent); -// helper.register(location, event); -// registered_sounds.put(soundName, event); -// } -// return event; -// } -// -// public static SoundEvent getRegisteredSound(String soundName) { -// return registered_sounds.get(soundName); -// } - - public void onCommonSetupEvent(FMLCommonSetupEvent event) { - - } - - // Directory tree delete -// public static boolean deleteDirectory(File directoryToBeDeleted) { -// File[] allContents = directoryToBeDeleted.listFiles(); -// if (allContents != null) { -// for (File file : allContents) { -// deleteDirectory(file); -// } -// } -// return directoryToBeDeleted.delete(); -// } - -// private static class PendingRestore { -// BlockPos pos; -// Level world; -// -// PendingRestore(Level lvl, BlockPos p) { -// this.world = lvl; -// this.pos = p; -// } -// -// @Override -// public int hashCode() { -// return pos.hashCode() ^ world.hashCode(); -// } -// -// @Override -// public boolean equals(Object o) { -// if (o instanceof PendingRestore) { -// PendingRestore pdo = (PendingRestore) o; -// return (pdo.world == this.world) && (pdo.pos.asLong() == this.pos.asLong()); -// } -// return false; -// } -// }; -// -// private static class RestoreInfo { -// long secCount; -// Boolean open; -// }; -// private static Map pendingHalfDoorRestore = new HashMap(); -// private static int ticks = 0; -// private static long secCount = 0; -// -// public static boolean isAutoRestoreHalfDoor(Block blk) { -// if (Config.autoRestoreAllHalfDoors) return true; -// return false; -// } -// -// public static void setPendingHalfDoorRestore(Level world, BlockPos pos, boolean isOpen, boolean isCreative) { -// PendingRestore pdc = new PendingRestore(world, pos); -// RestoreInfo ri = pendingHalfDoorRestore.get(pdc); -// if ((ri == null) && (!isCreative)) { // New one, and not creative mode, add record -// ri = new RestoreInfo(); -// ri.open = isOpen; -// ri.secCount = secCount + Config.autoRestoreTime; -// pendingHalfDoorRestore.put(pdc, ri); -// } -// // Else, if restore record pending, but creative change, drop it -// else if (ri != null) { -// if (isCreative) { -// pendingHalfDoorRestore.remove(pdc); -// } else { // Else, reset restore time -// ri.secCount = secCount + Config.autoRestoreTime; -// } -// } -// } -// -// public static void handlePendingHalfDoorRestores(boolean now) { -// // Handle pending door close checks -// Set> kvset = pendingHalfDoorRestore.entrySet(); -// Iterator> iter = kvset.iterator(); // So that we can remove during iteration -// while (iter.hasNext()) { -// Entry kv = iter.next(); -// PendingRestore pdc = kv.getKey(); -// RestoreInfo ri = kv.getValue(); -// if (now || (ri.secCount <= secCount)) { -// BlockState bs = pdc.world.getBlockState(pdc.pos); // Get the block state -// if (bs != null) { -// Block blk = bs.getBlock(); -// if ((blk instanceof WCHalfDoorBlock) && isAutoRestoreHalfDoor(blk)) { // Still right type of door -// if (bs.getValue(DoorBlock.OPEN) != ri.open) { // And still wrong state? -// WCHalfDoorBlock dblk = (WCHalfDoorBlock) blk; -// dblk.setOpen(null, pdc.world, bs, pdc.pos, ri.open); -// } -// } -// } -// iter.remove(); // And remove it from the set -// } -// } -// } - - // TODO: phase doesnt exist -// @SubscribeEvent -// public void countTicks(ServerTickEvent event) { -// if (event.phase != TickEvent.Phase.END) return; -// ticks++; -// if (ticks >= 20) { -// secCount++; -// // Handle any pending door restores -// handlePendingHalfDoorRestores(false); -// -// ticks = 0; -// } -// } - -// @SubscribeEvent -// public void serverStopping(ServerStoppingEvent event) { -// // Handle any pending door restores (force immediate) -// handlePendingHalfDoorRestores(true); -// } - -} diff --git a/needsported/WesterosBlocksCompatibility.java b/needsported/WesterosBlocksCompatibility.java deleted file mode 100644 index d58a83633b..0000000000 --- a/needsported/WesterosBlocksCompatibility.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.westerosblocks.needsported; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.StateDefinition; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -// Contains methods for generating config files and other artifacts -// needed for compatibility with external mods -public class WesterosBlocksCompatibility { - - public static final String BLOCKSET_PATH = "blocksets.json"; - public static final String WORLDPAINTER_PATH = "worldpainter.csv"; - public static final String[] WORLDPAINTER_COLS = { - "name", "discriminator", "properties", "opacity", "receivesLight", "insubstantial", - "resource", "tileEntity", "tileEntityId", "treeRelated", "vegetation", "blockLight", - "natural", "watery", "colour", "horizontal_orientation_schemes", "vertical_orientation_scheme" - }; - - /* - * The following allows block set information to be dumped to a json for - * the purpose of supporting external tools - */ - private static class BlockSetFileDef { - public String id = ""; - public String variant = ""; - } - private static class BlockSetFileSetDef { - public String id = ""; - public String altname = ""; - public List blocks = new ArrayList(); - } - private static class BlockSetFile { - public List blocksets = new ArrayList(); - } - - /* - * Dump information about block sets for external tools - */ - public static void dumpBlockSets(WesterosBlockSetDef[] blockSets, Path path) { - FileWriter fos = null; - try { - // Create output file format - BlockSetFile bsf = new BlockSetFile(); - for (WesterosBlockSetDef blockSet : blockSets) { - BlockSetFileSetDef bsf_set = new BlockSetFileSetDef(); - bsf_set.id = WesterosBlocks.MOD_ID + ":" + blockSet.baseBlockName; - if (blockSet.baseLabel != null) { - bsf_set.altname = blockSet.baseLabel.replaceAll(" ", "_").toLowerCase(); - } - // The following is duplicated from generateBlockDefs and can perhaps be refactored - for (String variant : WesterosBlockSetDef.SUPPORTED_VARIANTS) { - if (blockSet.variants != null && !blockSet.variants.contains(variant)) - continue; - else if (blockSet.variants == null && !WesterosBlockSetDef.DEFAULT_VARIANTS.contains(variant)) - continue; - BlockSetFileDef bsf_def = new BlockSetFileDef(); - String suffix = (variant.equals("solid")) ? "" : variant; - if (blockSet.altNames != null && blockSet.altNames.containsKey(variant)) { - bsf_def.id = WesterosBlocks.MOD_ID + ":" + blockSet.altNames.get(variant); - } - else { - bsf_def.id = WesterosBlocks.MOD_ID + ":" + blockSet.baseBlockName; - if (!suffix.isEmpty()) - bsf_def.id += "_" + suffix; - } - bsf_def.variant = variant; - bsf_set.blocks.add(bsf_def); - } - bsf.blocksets.add(bsf_set); - } - // Write json - fos = new FileWriter(new File(path.toFile(), BLOCKSET_PATH)); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(bsf, fos); - - } catch (IOException e) { - WesterosBlocks.log.error("Could not write "+BLOCKSET_PATH); - return; - - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - return; - } - } - } - } - - /* - * Dump a CustomBlocks config file for WorldPainter - * https://www.worldpainter.net/trac/wiki/CustomBlocks - */ - public static void dumpWorldPainterConfig(Block[] blocks, Path path) { - List> data = new ArrayList>(); - - for (Block blk : blocks) { - if (!(blk instanceof WesterosBlockLifecycle)) - continue; - - WesterosBlockDef def = ((WesterosBlockLifecycle)blk).getWBDefinition(); - StateDefinition sd = blk.getStateDefinition(); - - Map row = new HashMap(); - row.put("name", WesterosBlocks.MOD_ID + ":" + def.blockName); - // TODO - row.put("discriminator", null); - row.put("properties", null); - row.put("opacity", null); - row.put("receivesLight", null); - row.put("insubstantial", null); - row.put("resource", null); - row.put("tileEntity", null); - row.put("tileEntityId", null); - row.put("treeRelated", null); - row.put("vegetation", null); - row.put("blockLight", null); - row.put("natural", null); - row.put("watery", null); - row.put("colour", null); - row.put("horizontal_orientation_schemes", null); - row.put("vertical_orientation_scheme", null); - } - - try { - File file = new File(path.toFile(), WORLDPAINTER_PATH); - writeCSV(data, WORLDPAINTER_COLS, file); - } catch (IOException e) { - WesterosBlocks.log.error("Could not write "+WORLDPAINTER_PATH); - return; - } - } - - public static void writeCSV(List> data, String[] columns, File file) - throws IOException { - String out = String.join(",", columns) + "\n"; - - for (Map d : data) { - ArrayList row = new ArrayList(); - for (String c : columns) { - if (d.containsKey(c) && d.get(c) != null) { - Object val = d.get(c); - if (val instanceof Integer) - row.add(String.valueOf(val)); - else if (val instanceof Boolean) - row.add(((Boolean)val) ? "true" : "false"); - else - row.add("\"" + val + "\""); - } - else { - row.add(""); - } - } - out += String.join(",", row) + "\n"; - } - - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - writer.write(out); - writer.close(); - } -} \ No newline at end of file diff --git a/needsported/WesterosCreativeModeTabs.java b/needsported/WesterosCreativeModeTabs.java deleted file mode 100644 index 7d4f09bb32..0000000000 --- a/needsported/WesterosCreativeModeTabs.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.westerosblocks.needsported; - -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Block; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.neoforge.registries.DeferredHolder; -import net.neoforged.neoforge.registries.DeferredRegister; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; - -public class WesterosCreativeModeTabs { - public static final DeferredRegister CREATIVE_MODE_TABS = - DeferredRegister.create(Registries.CREATIVE_MODE_TAB, WesterosBlocks.MOD_ID); - public static final Map> TABS = new HashMap<>(); - - public record TabDefinition(String id, String label, String iconItem) { - } - - public static final TabDefinition[] TAB_DEFINITIONS = { - new TabDefinition("westeros_cobblestone_tab", "Cobblestone", "flagstone"), - new TabDefinition("westeros_fieldstone_tab", "Fieldstone", "light_grey_brick"), - new TabDefinition("westeros_smooth_ashlar_tab", "Smooth Ashlar", "grey_light_stone"), - new TabDefinition("westeros_quarter_ashlar_tab", "Quarter Ashlar", "small_smooth_stone_brick"), - new TabDefinition("westeros_medium_ashlar_tab", "Medium Ashlar", "grey_granite"), - new TabDefinition("westeros_half_ashlar_tab", "Half Ashlar", "stone_brick"), - new TabDefinition("westeros_polished_stone_tab", "Polished Stone", "grey_granite_polished"), - new TabDefinition("westeros_brick_tab", "Brick", "small_orange_bricks_ornate"), - new TabDefinition("westeros_marble_plaster_tab", "Marble and Plaster", "grey_keystone"), - new TabDefinition("westeros_timber_frame_tab", "Timber Frame", "timber_oak_reach_brick_crosshatch"), - new TabDefinition("westeros_roofing_tab", "Roofing", "orange_slate"), - new TabDefinition("westeros_wood_planks_tab", "Wood and Planks", "oak_vertical_planks"), - new TabDefinition("westeros_panelling_carvings_tab", "Panelling and Carvings", "dragon_carving"), - new TabDefinition("westeros_metal_tab", "Metal", "oxidized_bronze_block"), - new TabDefinition("westeros_windows_glass_tab", "Windows and Glass", "coloured_sept_window"), - new TabDefinition("westeros_furniture_tab", "Furniture", "table"), - new TabDefinition("westeros_decor_tab", "Decor", "dead_hare"), - new TabDefinition("westeros_lighting_tab", "Lighting", "red_lantern2"), - new TabDefinition("westeros_tool_blocks_tab", "Tool Blocks", "piston_extension"), - new TabDefinition("westeros_food_blocks_tab", "Food Blocks", "squash"), - new TabDefinition("westeros_cloth_fibers_tab", "Cloth and Fibers", "fancy_blue_carpet"), - new TabDefinition("westeros_banners_tab", "Banners", "westeroscraft_banner"), - new TabDefinition("westeros_terrain_sets_tab", "Terrain Sets", "terrainset_eastern_islands"), - new TabDefinition("westeros_grass_dirt_tab", "Grass and Dirt", "classic_grass_block"), - new TabDefinition("westeros_sand_gravel_tab", "Sand and Gravel", "sand_skeleton"), - new TabDefinition("westeros_logs_tab", "Logs", "weirwood_face_4"), - new TabDefinition("westeros_foliage_tab", "Foliage", "weirwood_leaves"), - new TabDefinition("westeros_grasses_shrubs_tab", "Grasses and Shrubs", "thick_grass"), - new TabDefinition("westeros_flowers_tab", "Flowers", "blue_bells"), - new TabDefinition("westeros_crops_herbs_tab", "Crops and Herbs", "crop_wheat"), - new TabDefinition("westeros_water_air_tab", "Water and Air", "falling_water_block_one"), - new TabDefinition("westeros_misc_tab", "Miscellaneous", "piled_bones"), - new TabDefinition("westeros_utility_tab", "Utility", "approval_utility_block"), - new TabDefinition("westeros_test_tab", "Test", "test_block"), - new TabDefinition("westeros_sounds_tab", "Sounds", "tavern_small"), - new TabDefinition("westeros_do_not_use_tab", "Do Not Use", "note_utility_block") - }; - - - static { - for (TabDefinition def : TAB_DEFINITIONS) { - TABS.put(def.id, registerTab(def.id, def.label, def.iconItem)); - } - } - - private static Supplier registerTab(String tabName, String title, String iconItem) { - return CREATIVE_MODE_TABS.register(tabName, - () -> CreativeModeTab.builder() - .icon(() -> new ItemStack(BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, iconItem)))) - .title(Component.literal(title)) - .displayItems((parameters, output) -> { - // Add logic here to populate the tab with items - // This is where you'd add your blocks/items to the tab - for (WesterosBlockDef def : WesterosBlocks.getCustomBlockDefs()) { - if (def != null && Objects.equals(def.creativeTab, tabName)) { - output.accept(BuiltInRegistries.ITEM.get(ResourceLocation - .fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName))); - } - } - }) - .build()); - } - - public static void register(IEventBus eventBus) { - CREATIVE_MODE_TABS.register(eventBus); - } -} diff --git a/needsported/WesterosItemMenuOverrides.java b/needsported/WesterosItemMenuOverrides.java deleted file mode 100644 index 106d5b6480..0000000000 --- a/needsported/WesterosItemMenuOverrides.java +++ /dev/null @@ -1,10 +0,0 @@ -//package com.westerosblocks.needsported; -// -//import javax.annotation.Nullable; -// -//public class WesterosItemMenuOverrides { -// public String[] blockNames; -// @Nullable -// public String creativeTab; -//}; -// diff --git a/needsported/blocks/AuxileryUtils.java b/needsported/blocks/AuxileryUtils.java deleted file mode 100644 index d3d0c93a4f..0000000000 --- a/needsported/blocks/AuxileryUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.westerosblocks.needsported.blocks; -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.properties.BlockSetType; -import net.minecraft.world.level.block.state.properties.WoodType; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -public class AuxileryUtils { - public static BlockSetType getBlockSetType(BlockBehaviour.Properties props, WesterosBlockDef def) { - //TODO: implment - return BlockSetType.OAK; - } - public static WoodType getWoodType(BlockBehaviour.Properties props, WesterosBlockDef def) { - //TODO: implment - return WoodType.OAK; - } - public static final Map> BLOCK_ITEM_TABS = new HashMap<>(); - public static void registerCreativeTab(BlockItem itemBlock, CreativeModeTab creativeTab) { - BLOCK_ITEM_TABS.computeIfAbsent(creativeTab, (tab) -> new LinkedHashSet<>()).add(itemBlock); - } -} \ No newline at end of file diff --git a/needsported/blocks/WCBeaconBlock.java b/needsported/blocks/WCBeaconBlock.java deleted file mode 100644 index b88af86557..0000000000 --- a/needsported/blocks/WCBeaconBlock.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.Arrays; -import java.util.List; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCBeaconBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCBeaconBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private static WesterosBlockDef.Cuboid[] cuboids = { - new WesterosBlockDef.Cuboid(0f, 0f, 0f, 0f, 1f, 1f, new int[] { 0, 1, 2, 3, 4, 5 }), - new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 0f, 1f, new int[] { 0, 1, 2, 3, 4, 5 }), - new WesterosBlockDef.Cuboid(0f, 0f, 0f, 1f, 1f, 0f, new int[] { 0, 1, 2, 3, 4, 5 }), - new WesterosBlockDef.Cuboid(1f, 0f, 0f, 1f, 1f, 1f, new int[] { 0, 1, 2, 3, 4, 5 }), - //new WesterosBlockDef.Cuboid(0f, 1f, 0f, 1f, 1f, 1f, new int[] { 0, 1, 2, 3, 4, 5 }), - new WesterosBlockDef.Cuboid(0f, 0f, 1f, 1f, 1f, 1f, new int[] { 0, 1, 2, 3, 4, 5 }), - new WesterosBlockDef.Cuboid(0.125f, 0.00625f, 0.125f, 0.125f, 0.1875f, 0.875f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.125f, 0.00625f, 0.125f, 0.875f, 0.00625f, 0.875f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.125f, 0.00625f, 0.125f, 0.875f, 0.1875f, 0.125f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.875f, 0.00625f, 0.125f, 0.875f, 0.1875f, 0.875f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.125f, 0.00625f, 0.1875f, 0.875f, 0.1875f, 0.875f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.125f, 0.00625f, 0.875f, 0.875f, 0.1875f, 0.875f, new int[] { 6, 7, 8, 9, 10, 11 }), - new WesterosBlockDef.Cuboid(0.1875f, 0.1875f, 0.1875f, 0.1875f, 0.875f, 0.8125f, new int[] { 12, 13, 14, 15, 16, 17 }), - new WesterosBlockDef.Cuboid(0.1875f, 0.1875f, 0.1875f, 0.8125f, 0.1875f, 0.8125f, new int[] { 12, 13, 14, 15, 16, 17 }), - new WesterosBlockDef.Cuboid(0.1875f, 0.1875f, 0.1875f, 0.8125f, 0.875f, 0.1875f, new int[] { 12, 13, 14, 15, 16, 17 }), - new WesterosBlockDef.Cuboid(0.8125f, 0.1875f, 0.1875f, 0.8125f, 0.875f, 0.8125f, new int[] { 12, 13, 14, 15, 16, 17 }), - new WesterosBlockDef.Cuboid(0.1875f, 0.875f, 0.1875f, 0.8125f, 0.875f, 0.8125f, new int[] { 12, 13, 14, 15, 16, 17 }), - new WesterosBlockDef.Cuboid(0.1875f, 0.1875f, 0.8125f, 0.8125f, 0.875f, 0.8125f, new int[] { 12, 13, 14, 15, 16, 17 }) - }; - private static List cuboidlist = Arrays.asList(cuboids); - - protected WCBeaconBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, 1); - def.cuboids = cuboidlist; - this.cuboid_by_facing[0] = cuboidlist; - SHAPE_BY_INDEX[0] = getBoundingBoxFromCuboidList(this.cuboid_by_facing[0]); - } -} diff --git a/needsported/blocks/WCBedBlock.java b/needsported/blocks/WCBedBlock.java deleted file mode 100644 index 8c54a40a70..0000000000 --- a/needsported/blocks/WCBedBlock.java +++ /dev/null @@ -1,420 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.List; -import java.util.Optional; - -import javax.annotation.Nullable; - -import com.mojang.serialization.MapCodec; -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.npc.Villager; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.DismountHelper; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.*; -import net.minecraft.world.level.block.*; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BedPart; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.neoforge.registries.RegisterEvent; -import org.apache.commons.lang3.ArrayUtils; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; - - -public class WCBedBlock extends HorizontalDirectionalBlock implements WesterosBlockLifecycle { - public static final MapCodec CODEC = simpleCodec(WCBedBlock::createBlock); - - private static WCBedBlock createBlock(BlockBehaviour.Properties props) { - System.err.println("AAA"); - return null; - } - - @Override - protected MapCodec codec() { - return CODEC; - } - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties().noOcclusion(); - Block blk = new WCBedBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - - public static final EnumProperty PART = BlockStateProperties.BED_PART; - public static final BooleanProperty OCCUPIED = BlockStateProperties.OCCUPIED; - protected static final int HEIGHT = 9; - protected static final VoxelShape BASE = Block.box(0.0D, 3.0D, 0.0D, 16.0D, 9.0D, 16.0D); - protected static final VoxelShape LEG_NORTH_WEST = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 3.0D, 3.0D); - protected static final VoxelShape LEG_SOUTH_WEST = Block.box(0.0D, 0.0D, 13.0D, 3.0D, 3.0D, 16.0D); - protected static final VoxelShape LEG_NORTH_EAST = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 3.0D, 3.0D); - protected static final VoxelShape LEG_SOUTH_EAST = Block.box(13.0D, 0.0D, 13.0D, 16.0D, 3.0D, 16.0D); - protected static final VoxelShape NORTH_SHAPE = Shapes.or(BASE, LEG_NORTH_WEST, LEG_NORTH_EAST); - protected static final VoxelShape SOUTH_SHAPE = Shapes.or(BASE, LEG_SOUTH_WEST, LEG_SOUTH_EAST); - protected static final VoxelShape WEST_SHAPE = Shapes.or(BASE, LEG_NORTH_WEST, LEG_SOUTH_WEST); - protected static final VoxelShape EAST_SHAPE = Shapes.or(BASE, LEG_NORTH_EAST, LEG_SOUTH_EAST); - private final DyeColor color; - - private WesterosBlockDef def; - - public static enum BedType { - NORMAL, RAISED, HAMMOCK - } - - ; - public final BedType bedType; - - protected WCBedBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.color = DyeColor.RED; - this.def = def; - String type = def.getTypeValue("shape", "normal"); - if (type.equals("raised")) - bedType = BedType.RAISED; - else if (type.equals("hammock")) - bedType = BedType.HAMMOCK; - else - bedType = BedType.NORMAL; - this.registerDefaultState(this.stateDefinition.any().setValue(PART, BedPart.FOOT).setValue(OCCUPIED, Boolean.valueOf(false))); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - // Force to model for now - public RenderShape getRenderShape(BlockState state) { - return RenderShape.MODEL; - } - - private static String[] TAGS = {"beds"}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - - - @Nullable - public static Direction getBedOrientation(BlockGetter p_49486_, BlockPos p_49487_) { - BlockState blockstate = p_49486_.getBlockState(p_49487_); - return blockstate.getBlock() instanceof BedBlock ? blockstate.getValue(FACING) : null; - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (level.isClientSide) { - return InteractionResult.CONSUME; - } else { - if (state.getValue(PART) != BedPart.HEAD) { - pos = pos.relative(state.getValue(FACING)); - state = level.getBlockState(pos); - if (!state.is(this)) { - return InteractionResult.CONSUME; - } - } - - if (!canSetSpawn(level)) { - level.removeBlock(pos, false); - BlockPos blockpos = pos.relative(state.getValue(FACING).getOpposite()); - if (level.getBlockState(blockpos).is(this)) { - level.removeBlock(blockpos, false); - } - - level.explode((Entity) null, level.damageSources().badRespawnPointExplosion(blockpos.getCenter()), (ExplosionDamageCalculator) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, 5.0F, true, Level.ExplosionInteraction.BLOCK); - } else if (state.getValue(OCCUPIED)) { - if (!this.kickVillagerOutOfBed(level, pos)) { - player.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true); - } - - return InteractionResult.SUCCESS; - } else { - player.startSleepInBed(pos).ifLeft((p_49477_) -> { - if (p_49477_ != null) { - player.displayClientMessage(p_49477_.getMessage(), true); - } - - }); - return InteractionResult.SUCCESS; - } - } - return InteractionResult.SUCCESS; - } - - // public InteractionResult use(BlockState p_49515_, Level p_49516_, BlockPos p_49517_, Player p_49518_, InteractionHand p_49519_, BlockHitResult p_49520_) { -// if (p_49516_.isClientSide) { -// return InteractionResult.CONSUME; -// } else { -// if (p_49515_.getValue(PART) != BedPart.HEAD) { -// p_49517_ = p_49517_.relative(p_49515_.getValue(FACING)); -// p_49515_ = p_49516_.getBlockState(p_49517_); -// if (!p_49515_.is(this)) { -// return InteractionResult.CONSUME; -// } -// } -// -// if (!canSetSpawn(p_49516_)) { -// p_49516_.removeBlock(p_49517_, false); -// BlockPos blockpos = p_49517_.relative(p_49515_.getValue(FACING).getOpposite()); -// if (p_49516_.getBlockState(blockpos).is(this)) { -// p_49516_.removeBlock(blockpos, false); -// } -// -// p_49516_.explode((Entity) null, p_49516_.damageSources().badRespawnPointExplosion(blockpos.getCenter()), (ExplosionDamageCalculator) null, (double) p_49517_.getX() + 0.5D, (double) p_49517_.getY() + 0.5D, (double) p_49517_.getZ() + 0.5D, 5.0F, true, Level.ExplosionInteraction.BLOCK); -// } else if (p_49515_.getValue(OCCUPIED)) { -// if (!this.kickVillagerOutOfBed(p_49516_, p_49517_)) { -// p_49518_.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true); -// } -// -// return InteractionResult.SUCCESS; -// } else { -// p_49518_.startSleepInBed(p_49517_).ifLeft((p_49477_) -> { -// if (p_49477_ != null) { -// p_49518_.displayClientMessage(p_49477_.getMessage(), true); -// } -// -// }); -// return InteractionResult.SUCCESS; -// } -// } -// } - - public static boolean canSetSpawn(Level p_49489_) { - return p_49489_.dimensionType().bedWorks(); - } - - private boolean kickVillagerOutOfBed(Level p_49491_, BlockPos p_49492_) { - List list = p_49491_.getEntitiesOfClass(Villager.class, new AABB(p_49492_), LivingEntity::isSleeping); - if (list.isEmpty()) { - return false; - } else { - list.get(0).stopSleeping(); - return true; - } - } - - public void fallOn(Level p_152169_, BlockState p_152170_, BlockPos p_152171_, Entity p_152172_, float p_152173_) { - super.fallOn(p_152169_, p_152170_, p_152171_, p_152172_, p_152173_ * 0.5F); - } - - public void updateEntityAfterFallOn(BlockGetter p_49483_, Entity p_49484_) { - if (p_49484_.isSuppressingBounce()) { - super.updateEntityAfterFallOn(p_49483_, p_49484_); - } else { - this.bounceUp(p_49484_); - } - - } - - private void bounceUp(Entity p_49457_) { - Vec3 vec3 = p_49457_.getDeltaMovement(); - if (vec3.y < 0.0D) { - double d0 = p_49457_ instanceof LivingEntity ? 1.0D : 0.8D; - p_49457_.setDeltaMovement(vec3.x, -vec3.y * (double) 0.66F * d0, vec3.z); - } - - } - - @SuppressWarnings("deprecation") - @Override - public BlockState updateShape(BlockState p_49525_, Direction p_49526_, BlockState p_49527_, LevelAccessor p_49528_, BlockPos p_49529_, BlockPos p_49530_) { - if (p_49526_ == getNeighbourDirection(p_49525_.getValue(PART), p_49525_.getValue(FACING))) { - return p_49527_.is(this) && p_49527_.getValue(PART) != p_49525_.getValue(PART) ? p_49525_.setValue(OCCUPIED, p_49527_.getValue(OCCUPIED)) : Blocks.AIR.defaultBlockState(); - } else { - return super.updateShape(p_49525_, p_49526_, p_49527_, p_49528_, p_49529_, p_49530_); - } - } - - private static Direction getNeighbourDirection(BedPart p_49534_, Direction p_49535_) { - return p_49534_ == BedPart.FOOT ? p_49535_ : p_49535_.getOpposite(); - } - - @Override - public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) { - if (!level.isClientSide && player.isCreative()) { - BedPart bedpart = state.getValue(PART); - if (bedpart == BedPart.FOOT) { - BlockPos blockpos = pos.relative(getNeighbourDirection(bedpart, state.getValue(FACING))); - BlockState blockstate = level.getBlockState(blockpos); - if (blockstate.is(this) && blockstate.getValue(PART) == BedPart.HEAD) { - level.setBlock(blockpos, Blocks.AIR.defaultBlockState(), 35); - level.levelEvent(player, 2001, blockpos, Block.getId(blockstate)); - } - } - } - - return super.playerWillDestroy(level, pos, state, player); - } - - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext p_49479_) { - Direction direction = p_49479_.getHorizontalDirection(); - BlockPos blockpos = p_49479_.getClickedPos(); - BlockPos blockpos1 = blockpos.relative(direction); - Level level = p_49479_.getLevel(); - return level.getBlockState(blockpos1).canBeReplaced(p_49479_) && level.getWorldBorder().isWithinBounds(blockpos1) ? this.defaultBlockState().setValue(FACING, direction) : null; - } - - public VoxelShape getShape(BlockState p_49547_, BlockGetter p_49548_, BlockPos p_49549_, CollisionContext p_49550_) { - Direction direction = getConnectedDirection(p_49547_).getOpposite(); - switch (direction) { - case NORTH: - return NORTH_SHAPE; - case SOUTH: - return SOUTH_SHAPE; - case WEST: - return WEST_SHAPE; - default: - return EAST_SHAPE; - } - } - - public static Direction getConnectedDirection(BlockState p_49558_) { - Direction direction = p_49558_.getValue(FACING); - return p_49558_.getValue(PART) == BedPart.HEAD ? direction.getOpposite() : direction; - } - - public static DoubleBlockCombiner.BlockType getBlockType(BlockState p_49560_) { - BedPart bedpart = p_49560_.getValue(PART); - return bedpart == BedPart.HEAD ? DoubleBlockCombiner.BlockType.FIRST : DoubleBlockCombiner.BlockType.SECOND; - } - - private static boolean isBunkBed(BlockGetter p_49542_, BlockPos p_49543_) { - return p_49542_.getBlockState(p_49543_.below()).getBlock() instanceof BedBlock; - } - - public static Optional findStandUpPosition(EntityType p_49459_, CollisionGetter p_49460_, BlockPos p_49461_, float p_49462_) { - Direction direction = p_49460_.getBlockState(p_49461_).getValue(FACING); - Direction direction1 = direction.getClockWise(); - Direction direction2 = direction1.isFacingAngle(p_49462_) ? direction1.getOpposite() : direction1; - if (isBunkBed(p_49460_, p_49461_)) { - return findBunkBedStandUpPosition(p_49459_, p_49460_, p_49461_, direction, direction2); - } else { - int[][] aint = bedStandUpOffsets(direction, direction2); - Optional optional = findStandUpPositionAtOffset(p_49459_, p_49460_, p_49461_, aint, true); - return optional.isPresent() ? optional : findStandUpPositionAtOffset(p_49459_, p_49460_, p_49461_, aint, false); - } - } - - private static Optional findBunkBedStandUpPosition(EntityType p_49464_, CollisionGetter p_49465_, BlockPos p_49466_, Direction p_49467_, Direction p_49468_) { - int[][] aint = bedSurroundStandUpOffsets(p_49467_, p_49468_); - Optional optional = findStandUpPositionAtOffset(p_49464_, p_49465_, p_49466_, aint, true); - if (optional.isPresent()) { - return optional; - } else { - BlockPos blockpos = p_49466_.below(); - Optional optional1 = findStandUpPositionAtOffset(p_49464_, p_49465_, blockpos, aint, true); - if (optional1.isPresent()) { - return optional1; - } else { - int[][] aint1 = bedAboveStandUpOffsets(p_49467_); - Optional optional2 = findStandUpPositionAtOffset(p_49464_, p_49465_, p_49466_, aint1, true); - if (optional2.isPresent()) { - return optional2; - } else { - Optional optional3 = findStandUpPositionAtOffset(p_49464_, p_49465_, p_49466_, aint, false); - if (optional3.isPresent()) { - return optional3; - } else { - Optional optional4 = findStandUpPositionAtOffset(p_49464_, p_49465_, blockpos, aint, false); - return optional4.isPresent() ? optional4 : findStandUpPositionAtOffset(p_49464_, p_49465_, p_49466_, aint1, false); - } - } - } - } - } - - private static Optional findStandUpPositionAtOffset(EntityType p_49470_, CollisionGetter p_49471_, BlockPos p_49472_, int[][] p_49473_, boolean p_49474_) { - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - - for (int[] aint : p_49473_) { - blockpos$mutableblockpos.set(p_49472_.getX() + aint[0], p_49472_.getY(), p_49472_.getZ() + aint[1]); - Vec3 vec3 = DismountHelper.findSafeDismountLocation(p_49470_, p_49471_, blockpos$mutableblockpos, p_49474_); - if (vec3 != null) { - return Optional.of(vec3); - } - } - - return Optional.empty(); - } - - public PushReaction getPistonPushReaction(BlockState p_49556_) { - return PushReaction.DESTROY; - } - - protected void createBlockStateDefinition(StateDefinition.Builder p_49532_) { - p_49532_.add(FACING, PART, OCCUPIED); - } - - public void setPlacedBy(Level p_49499_, BlockPos p_49500_, BlockState p_49501_, @Nullable LivingEntity p_49502_, ItemStack p_49503_) { - super.setPlacedBy(p_49499_, p_49500_, p_49501_, p_49502_, p_49503_); - if (!p_49499_.isClientSide) { - BlockPos blockpos = p_49500_.relative(p_49501_.getValue(FACING)); - p_49499_.setBlock(blockpos, p_49501_.setValue(PART, BedPart.HEAD), 3); - p_49499_.blockUpdated(p_49500_, Blocks.AIR); - p_49501_.updateNeighbourShapes(p_49499_, p_49500_, 3); - } - - } - - public DyeColor getColor() { - return this.color; - } - - public long getSeed(BlockState p_49522_, BlockPos p_49523_) { - BlockPos blockpos = p_49523_.relative(p_49522_.getValue(FACING), p_49522_.getValue(PART) == BedPart.HEAD ? 0 : 1); - return Mth.getSeed(blockpos.getX(), p_49523_.getY(), blockpos.getZ()); - } - - public boolean isPathfindable(BlockState p_49510_, BlockGetter p_49511_, BlockPos p_49512_, PathComputationType p_49513_) { - return false; - } - - private static int[][] bedStandUpOffsets(Direction p_49539_, Direction p_49540_) { - return ArrayUtils.addAll((int[][]) bedSurroundStandUpOffsets(p_49539_, p_49540_), (int[][]) bedAboveStandUpOffsets(p_49539_)); - } - - private static int[][] bedSurroundStandUpOffsets(Direction p_49552_, Direction p_49553_) { - return new int[][]{{p_49553_.getStepX(), p_49553_.getStepZ()}, {p_49553_.getStepX() - p_49552_.getStepX(), p_49553_.getStepZ() - p_49552_.getStepZ()}, {p_49553_.getStepX() - p_49552_.getStepX() * 2, p_49553_.getStepZ() - p_49552_.getStepZ() * 2}, {-p_49552_.getStepX() * 2, -p_49552_.getStepZ() * 2}, {-p_49553_.getStepX() - p_49552_.getStepX() * 2, -p_49553_.getStepZ() - p_49552_.getStepZ() * 2}, {-p_49553_.getStepX() - p_49552_.getStepX(), -p_49553_.getStepZ() - p_49552_.getStepZ()}, {-p_49553_.getStepX(), -p_49553_.getStepZ()}, {-p_49553_.getStepX() + p_49552_.getStepX(), -p_49553_.getStepZ() + p_49552_.getStepZ()}, {p_49552_.getStepX(), p_49552_.getStepZ()}, {p_49553_.getStepX() + p_49552_.getStepX(), p_49553_.getStepZ() + p_49552_.getStepZ()}}; - } - - private static int[][] bedAboveStandUpOffsets(Direction p_49537_) { - return new int[][]{{0, 0}, {-p_49537_.getStepX(), -p_49537_.getStepZ()}}; - } - -} diff --git a/needsported/blocks/WCCakeBlock.java b/needsported/blocks/WCCakeBlock.java deleted file mode 100644 index df3dcc0028..0000000000 --- a/needsported/blocks/WCCakeBlock.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.CakeBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCakeBlock extends CakeBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCCakeBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - - protected WCCakeBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - private static String[] TAGS = { }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCCropBlock.java b/needsported/blocks/WCCropBlock.java deleted file mode 100644 index 63d4ea1e51..0000000000 --- a/needsported/blocks/WCCropBlock.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.Block; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCropBlock extends WCPlantBlock implements WesterosBlockLifecycle { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - String t = def.getType(); - if ((t != null) && (t.indexOf(WesterosBlockDef.LAYER_SENSITIVE) >= 0)) { - tempLAYERS = BlockStateProperties.LAYERS; - } - BlockBehaviour.Properties props = def.makeProperties().noCollission().instabreak(); - Block blk = new WCCropBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - protected WCCropBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def); - } - private static String[] TAGS = { "crops" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCCuboid16WayBlock.java b/needsported/blocks/WCCuboid16WayBlock.java deleted file mode 100644 index 65927f261d..0000000000 --- a/needsported/blocks/WCCuboid16WayBlock.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.tags.FluidTags; -import net.minecraft.util.Mth; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboid16WayBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - Block blk = new WCCuboid16WayBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, true, true); - } - } - - private static final int ROTATIONS = 16; - public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; - - private static final WesterosBlockDef.CuboidRotation[] shape_rotations = { - WesterosBlockDef.CuboidRotation.NONE, - WesterosBlockDef.CuboidRotation.ROTY90, - WesterosBlockDef.CuboidRotation.ROTY180, - WesterosBlockDef.CuboidRotation.ROTY270 }; - protected WCCuboid16WayBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, ROTATIONS); - - // Build rotations - one set for each state, if needed - int stcnt = def.states.size(); - for (int stidx = 0; stidx < stcnt; stidx++) { - int idx = ROTATIONS * stidx; - for (int i = 1; i < ROTATIONS; i++) { - for (WesterosBlockDef.Cuboid c : cuboid_by_facing[idx]) { - cuboid_by_facing[idx+i].add(c.rotateCuboid(shape_rotations[i / 4])); - } - } - } - for (int i = 0; i < cuboid_by_facing.length; i++) { - if (SHAPE_BY_INDEX[i] == null) { - SHAPE_BY_INDEX[i] = getBoundingBoxFromCuboidList(cuboid_by_facing[i]); - } - } - BlockState defbs = this.stateDefinition.any().setValue(ROTATION, 0).setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - super.createBlockStateDefinition(StateDefinition); - StateDefinition.add(ROTATION); - } - - @Override - protected int getIndexFromState(BlockState state) { - if (STATE != null) { - return (STATE.getIndex(state.getValue(STATE)) * ROTATIONS) + state.getValue(ROTATION); - } - else { - return state.getValue(ROTATION); - } - } - - @Override - public BlockState rotate(BlockState state, Rotation rot) { - return state.setValue(ROTATION, Integer.valueOf(rot.rotate(state.getValue(ROTATION), 16))); - } - - @Override - public BlockState mirror(BlockState state, Mirror mirror) { - return state.setValue(ROTATION, Integer.valueOf(mirror.mirror(state.getValue(ROTATION), 16))); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - Integer dir = Integer.valueOf(Mth.floor((double)(ctx.getRotation() * 16.0F / 360.0F) + 0.5D) & 15); - BlockState bs = this.defaultBlockState().setValue(ROTATION, dir).setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } -} diff --git a/needsported/blocks/WCCuboidBlock.java b/needsported/blocks/WCCuboidBlock.java deleted file mode 100644 index f9b1ccf50b..0000000000 --- a/needsported/blocks/WCCuboidBlock.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.*; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboidBlock extends Block implements WesterosBlockLifecycle, SimpleWaterloggedBlock { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - Block blk = new WCCuboidBlock(props, def, 1); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - - } - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - protected boolean toggleOnUse = false; - protected int modelsPerState; - - protected WesterosBlockDef def; - - protected VoxelShape[] SHAPE_BY_INDEX; - protected VoxelShape[] SUPPORT_BY_INDEX; - protected List cuboid_by_facing[]; - - protected WCCuboidBlock(BlockBehaviour.Properties props, WesterosBlockDef def, int modelsPerState) { - super(props); - this.def = def; - this.modelsPerState = modelsPerState; - - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - int cnt = def.states.size(); - this.cuboid_by_facing = new List[cnt * modelsPerState]; - SHAPE_BY_INDEX = new VoxelShape[cnt * modelsPerState]; - for (int i = 0; i < cnt; i++) { - cuboid_by_facing[i * modelsPerState] = def.states.get(i).getCuboidList(); - for (int j = 1; j < modelsPerState; j++) { - cuboid_by_facing[i * modelsPerState + j] = new ArrayList(); - } - SHAPE_BY_INDEX[i * modelsPerState] = getBoundingBoxFromCuboidList(cuboid_by_facing[i * modelsPerState]); - } - SUPPORT_BY_INDEX = new VoxelShape[cnt]; - for (int i = 0; i < cnt; i++) { - SUPPORT_BY_INDEX[i] = def.states.get(i).makeSupportBoxShape(null); - } - BlockState defbs = this.stateDefinition.any().setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - StateDefinition.add(STATE); - } - StateDefinition.add(WATERLOGGED); - } - - protected int getIndexFromState(BlockState state) { - if (STATE != null) - return modelsPerState * STATE.getIndex(state.getValue(STATE)); - else - return 0; - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - return SHAPE_BY_INDEX[getIndexFromState(state)]; - } - @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - return SHAPE_BY_INDEX[getIndexFromState(state)]; - } - @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { - int idx = 0; - if (STATE != null) - idx = STATE.getIndex(state.getValue(STATE)); - return SUPPORT_BY_INDEX[idx]; - } - @Override - public VoxelShape getVisualShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - return SHAPE_BY_INDEX[getIndexFromState(state)]; - } - @SuppressWarnings("deprecation") - @Override - public BlockState updateShape(BlockState state, Direction face, BlockState state2, LevelAccessor world, BlockPos pos, BlockPos pos2) { - if (state.getValue(WATERLOGGED)) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - return super.updateShape(state, face, state2, world, pos, pos2); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - BlockState bs = this.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch(pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } - else { - return InteractionResult.PASS; - } - } - - protected VoxelShape getBoundingBoxFromCuboidList(List cl) { - VoxelShape vs = Shapes.empty(); - if (cl != null) { - for(WesterosBlockDef.Cuboid c : cl) { - vs = Shapes.or(vs, Shapes.box(c.xMin, c.yMin, c.zMin, c.xMax, c.yMax, c.zMax)); - } - } - return vs; - } - - public List getModelCuboids(int stateIdx) { - return cuboid_by_facing[modelsPerState * stateIdx]; - } - - private static String[] TAGS = { }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCCuboidNEBlock.java b/needsported/blocks/WCCuboidNEBlock.java deleted file mode 100644 index 277c1c231e..0000000000 --- a/needsported/blocks/WCCuboidNEBlock.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboidNEBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - Block blk = new WCCuboidNEBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.EAST, Direction.NORTH); - - protected WCCuboidNEBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, 2); - - int stcnt = def.states.size(); - for (int stidx = 0; stidx < stcnt; stidx++) { - for (WesterosBlockDef.Cuboid c : cuboid_by_facing[2 * stidx]) { - cuboid_by_facing[2 * stidx + 1].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY90)); - } - } - for (int i = 0; i < cuboid_by_facing.length; i++) { - if (SHAPE_BY_INDEX[i] == null) { - SHAPE_BY_INDEX[i] = getBoundingBoxFromCuboidList(cuboid_by_facing[i]); - } - } - BlockState defbs = this.stateDefinition.any().setValue(FACING, Direction.EAST).setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - super.createBlockStateDefinition(StateDefinition); - StateDefinition.add(FACING); - } - - @Override - protected int getIndexFromState(BlockState state) { - return super.getIndexFromState(state) + ((state.getValue(FACING) == Direction.EAST) ? 0 : 1); - } - - @Override - public BlockState rotate(BlockState state, Rotation rot) { - switch (rot) { - case CLOCKWISE_180: - default: - return state; - case COUNTERCLOCKWISE_90: - case CLOCKWISE_90: - return (state.getValue(FACING) == Direction.EAST) ? - state.setValue(FACING, Direction.NORTH) : - state.setValue(FACING, Direction.EAST); - } - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - Direction[] adirection = ctx.getNearestLookingDirections(); - Direction dir = Direction.EAST; // Default - for (Direction d : adirection) { - if (d == Direction.EAST || d == Direction.WEST) { - dir = Direction.EAST; - break; - } - if (d == Direction.NORTH || d == Direction.SOUTH) { - dir = Direction.NORTH; - break; - } - } - BlockState bs = this.defaultBlockState().setValue(FACING, dir).setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } -} diff --git a/needsported/blocks/WCCuboidNSEWBlock.java b/needsported/blocks/WCCuboidNSEWBlock.java deleted file mode 100644 index bbd8cf4f4d..0000000000 --- a/needsported/blocks/WCCuboidNSEWBlock.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboidNSEWBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - Block blk = new WCCuboidNSEWBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - // public static final DirectionProperty FACING = - // DirectionProperty.create("facing", Direction.EAST, Direction.SOUTH, - // Direction.WEST, Direction.NORTH); - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - - protected WCCuboidNSEWBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, 4); - - int stcnt = def.states.size(); - for (int stidx = 0; stidx < stcnt; stidx++) { - int off = stidx * this.modelsPerState; - for (WesterosBlockDef.Cuboid c : cuboid_by_facing[off]) { - cuboid_by_facing[off + 1].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY90)); - cuboid_by_facing[off + 2].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY180)); - cuboid_by_facing[off + 3].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY270)); - } - } - for (int i = 0; i < cuboid_by_facing.length; i++) { - if (SHAPE_BY_INDEX[i] == null) { - SHAPE_BY_INDEX[i] = getBoundingBoxFromCuboidList(cuboid_by_facing[i]); - } - } - BlockState defbs = this.stateDefinition.any().setValue(FACING, Direction.EAST).setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - super.createBlockStateDefinition(StateDefinition); - StateDefinition.add(FACING); - } - - @Override - public BlockState rotate(BlockState state, Rotation rot) { - return state.setValue(FACING, rot.rotate(state.getValue(FACING))); - } - - @SuppressWarnings("deprecation") - @Override - public BlockState mirror(BlockState state, Mirror mir) { - return state.rotate(mir.getRotation(state.getValue(FACING))); - } - - @Override - protected int getIndexFromState(BlockState state) { - int off = super.getIndexFromState(state); - switch (state.getValue(FACING)) { - case EAST: - default: - return off; - case SOUTH: - return off + 1; - case WEST: - return off + 2; - case NORTH: - return off + 3; - } - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - Direction[] adirection = ctx.getNearestLookingDirections(); - Direction dir = Direction.EAST; // Default - for (Direction d : adirection) { - if (d == Direction.EAST || d == Direction.WEST || d == Direction.NORTH || d == Direction.SOUTH) { - dir = d.getOpposite(); - break; - } - } - BlockState bs = this.defaultBlockState().setValue(FACING, dir).setValue(WATERLOGGED, - Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } -} diff --git a/needsported/blocks/WCCuboidNSEWStackBlock.java b/needsported/blocks/WCCuboidNSEWStackBlock.java deleted file mode 100644 index 2c7d0a7cb1..0000000000 --- a/needsported/blocks/WCCuboidNSEWStackBlock.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.ArrayList; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.*; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.state.StateDefinition; - -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboidNSEWStackBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCCuboidNSEWStackBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH); - public static final EnumProperty HALF = BlockStateProperties.DOUBLE_BLOCK_HALF; - - public final boolean allowHalfBreak; - // Index = FACING + 4*TOP - - protected WCCuboidNSEWStackBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, 8); - String t = def.getType(); - boolean brk = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allowHalfBreak")) { - brk = true; - } - } - } - this.allowHalfBreak = brk; - - for (int i = 0; i < 2; i++) { - WesterosBlockStateRecord se = def.getStackElementByIndex(i); - for (WesterosBlockDef.Cuboid c : se.cuboids) { - cuboid_by_facing[4*i] = new ArrayList(); // Use clean, since parent uses cuboid not stack - cuboid_by_facing[4*i].add(c); - cuboid_by_facing[4*i + 1].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY90)); - cuboid_by_facing[4*i + 2].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY180)); - cuboid_by_facing[4*i + 3].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY270)); - } - } - for (int j = 0; j < cuboid_by_facing.length; j++) { - SHAPE_BY_INDEX[j] = getBoundingBoxFromCuboidList(cuboid_by_facing[j]); - } - this.registerDefaultState(this.stateDefinition.any() - .setValue(HALF, DoubleBlockHalf.LOWER) - .setValue(FACING, Direction.EAST) - .setValue(WATERLOGGED, Boolean.valueOf(false))); - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - super.createBlockStateDefinition(StateDefinition); - StateDefinition.add(FACING, HALF); - } - @Override - protected int getIndexFromState(BlockState state) { - int topoff = (state.getValue(HALF) == DoubleBlockHalf.LOWER) ? 0 : 4; - switch (state.getValue(FACING)) { - case EAST: - default: - return topoff; - case SOUTH: - return topoff+1; - case WEST: - return topoff+2; - case NORTH: - return topoff+3; - } - } - @Nullable - @Override - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockPos blockpos = ctx.getClickedPos(); - if (blockpos.getY() < ctx.getLevel().getMaxBuildHeight() && ctx.getLevel().getBlockState(blockpos.above()).canBeReplaced(ctx)) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - Direction[] adirection = ctx.getNearestLookingDirections(); - Direction dir = Direction.EAST; // Default - for (Direction d : adirection) { - if (d == Direction.EAST || d == Direction.WEST || d == Direction.NORTH || d == Direction.SOUTH) { - dir = d; - break; - } - } - return this.defaultBlockState() - .setValue(FACING, dir) - .setValue(HALF, DoubleBlockHalf.LOWER) - .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - } - else { - return null; - } - } - - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState state2, LevelAccessor world, BlockPos pos, BlockPos pos2) { - if (allowHalfBreak) { return super.updateShape(state, dir, state2, world, pos, pos2); } - DoubleBlockHalf doubleblockhalf = state.getValue(HALF); - if (dir.getAxis() != Direction.Axis.Y || doubleblockhalf == DoubleBlockHalf.LOWER != (dir == Direction.UP) || state2.is(this) && state2.getValue(HALF) != doubleblockhalf) { - return doubleblockhalf == DoubleBlockHalf.LOWER && dir == Direction.DOWN && !state.canSurvive(world, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, dir, state2, world, pos, pos2); - } else { - return Blocks.AIR.defaultBlockState(); - } - } - - @Override - public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack item) { - BlockPos above = pos.above(); - FluidState fluidstate =world.getFluidState(above); - BlockState newstate = this.defaultBlockState() - .setValue(FACING, state.getValue(FACING)) - .setValue(HALF, DoubleBlockHalf.UPPER) - .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - world.setBlock(pos.above(), newstate, 3); - } - - @SuppressWarnings("deprecation") - @Override - public boolean canSurvive(BlockState state, LevelReader reader, BlockPos pos) { - if (this.allowHalfBreak || (state.getValue(HALF) != DoubleBlockHalf.UPPER)) { - return super.canSurvive(state, reader, pos); - } - else { - BlockState blockstate = reader.getBlockState(pos.below()); - if (state.getBlock() != this) { - return super.canSurvive(state, reader, pos); - } - return blockstate.is(this) && blockstate.getValue(HALF) == DoubleBlockHalf.LOWER; - } - } -} diff --git a/needsported/blocks/WCCuboidNSEWUDBlock.java b/needsported/blocks/WCCuboidNSEWUDBlock.java deleted file mode 100644 index cc4386eea4..0000000000 --- a/needsported/blocks/WCCuboidNSEWUDBlock.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.List; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCCuboidNSEWUDBlock extends WCCuboidBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - Block blk = new WCCuboidNSEWUDBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.DOWN, Direction.UP); - - protected WCCuboidNSEWUDBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def, 6); - - int stcnt = def.states.size(); - for (int stidx = 0; stidx < stcnt; stidx++) { - int off = stidx * this.modelsPerState; - for (WesterosBlockDef.Cuboid c : cuboid_by_facing[off]) { - cuboid_by_facing[off + 1].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY90)); - cuboid_by_facing[off + 2].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY180)); - cuboid_by_facing[off + 3].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTY270)); - cuboid_by_facing[off + 4].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTZ90)); - cuboid_by_facing[off + 5].add(c.rotateCuboid(WesterosBlockDef.CuboidRotation.ROTZ270)); - } - } - for (int i = 0; i < cuboid_by_facing.length; i++) { - if (SHAPE_BY_INDEX[i] == null) { - SHAPE_BY_INDEX[i] = getBoundingBoxFromCuboidList(cuboid_by_facing[i]); - } - } - BlockState defbs = this.stateDefinition.any().setValue(FACING, Direction.EAST).setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - super.createBlockStateDefinition(StateDefinition); - StateDefinition.add(FACING); - } - - @Override - public List getModelCuboids(int stateIdx) { - return cuboid_by_facing[modelsPerState * stateIdx + 3]; - } - - @Override - protected int getIndexFromState(BlockState state) { - int off = super.getIndexFromState(state); - switch (state.getValue(FACING)) { - case EAST: - return off; - case SOUTH: - return off+1; - case WEST: - return off+2; - case NORTH: - return off+3; - case DOWN: - return off+4; - case UP: - return off+5; - } - return off; - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - Direction[] adirection = ctx.getNearestLookingDirections(); - Direction dir = Direction.EAST; // Default - for (Direction d : adirection) { - dir = d; - break; - } - BlockState bs = this.defaultBlockState().setValue(FACING, dir).setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } -} diff --git a/needsported/blocks/WCDoorBlock.java b/needsported/blocks/WCDoorBlock.java deleted file mode 100644 index 6d18e957d9..0000000000 --- a/needsported/blocks/WCDoorBlock.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.level.block.DoorBlock; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.core.BlockPos; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - - -public class WCDoorBlock extends DoorBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCDoorBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean locked = false; - private boolean allow_unsupported = false; - - protected WCDoorBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(AuxileryUtils.getBlockSetType(props, def), props); - this.def = def; - String type = def.getType(); - if (type != null) { - String[] toks = type.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - String [] flds = tok.split(":"); - if (flds.length < 2) continue; - if (flds[0].equals("locked")) { - locked = flds[1].equals("true"); - } - } - } - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - - - if (this.locked) { - return InteractionResult.PASS; - } - else { - return super.useWithoutItem(state, level, pos, player, hitResult); - } - } - - @Override - public boolean canSurvive(BlockState p_52783_, LevelReader p_52784_, BlockPos p_52785_) { - if (allow_unsupported && (p_52783_.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER)) return true; - return super.canSurvive(p_52783_, p_52784_, p_52785_); - } - - private static String[] TAGS = { "doors" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCFanBlock.java b/needsported/blocks/WCFanBlock.java deleted file mode 100644 index c58b4897d1..0000000000 --- a/needsported/blocks/WCFanBlock.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCFanBlock extends Block implements SimpleWaterloggedBlock, WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties floorprops = def.makeProperties().noCollission().instabreak(); - Block floorblock = new WCFanBlock(floorprops, def); - @SuppressWarnings("deprecation") - BlockBehaviour.Properties wallprops = def.makeProperties().noCollission().instabreak().dropsLike(floorblock); - Block wallblock = new WCWallFanBlock(wallprops, def); -// def.registerWallOrFloorBlock(floorblock, wallblock, helper); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), floorblock); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, "wall_" + def.blockName), wallblock); - def.registerBlockItem(def.blockName, floorblock); - def.registerBlockItem("wall_" + def.blockName, wallblock); - - def.registerRenderType(floorblock, false, false); - def.registerRenderType(wallblock, false, false); - return floorblock; - } - } - - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - private WesterosBlockDef def; - private boolean allow_unsupported = false; - - private static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 4.0, 14.0); - - protected WCFanBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - } - } - BlockState defbs = this.stateDefinition.any().setValue(WATERLOGGED, Boolean.valueOf(false)); - this.registerDefaultState(defbs); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState bs = super.getStateForPlacement(ctx); - if (bs == null) return null; - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - bs = bs.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - return bs; - } - - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch(pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { - stateDefinition.add(WATERLOGGED); - } - - @Override - public BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) { - if (direction == Direction.DOWN && !this.canSurvive(blockState, levelAccessor, blockPos)) { - return Blocks.AIR.defaultBlockState(); - } - return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2); - } - - @Override - public boolean canSurvive(BlockState state, LevelReader levelReader, BlockPos blockPos) { - if (this.allow_unsupported) return true; - BlockPos blockPos2 = blockPos.below(); - return levelReader.getBlockState(blockPos2).isFaceSturdy(levelReader, blockPos2, Direction.UP); - } - - @Override - public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { - return state.getFluidState().isEmpty(); - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) { - return SHAPE; - } - - private static String[] TAGS = { "fans" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCFenceBlock.java b/needsported/blocks/WCFenceBlock.java deleted file mode 100644 index 81714a11a4..0000000000 --- a/needsported/blocks/WCFenceBlock.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.FenceBlock; -import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.tags.BlockTags; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.phys.BlockHitResult; - -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCFenceBlock extends FenceBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - // Process types - String t = def.getType(); - Boolean doUnconnect = null; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - // See if we have unconnect - if (parts[0].equals("unconnect")) { - doUnconnect = "true".equals(parts[1]); - tempUNCONNECT = UNCONNECT; - } - } - } - Block blk = new WCFenceBlock(props, def, doUnconnect); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - }; - - public static final BooleanProperty UNCONNECT = BooleanProperty.create("unconnect"); - protected static BooleanProperty tempUNCONNECT; - - public final boolean unconnect; - public final Boolean unconnectDef; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - - protected boolean toggleOnUse = false; - - private WesterosBlockDef def; - - protected WCFenceBlock(BlockBehaviour.Properties props, WesterosBlockDef def, Boolean doUnconnect) { - super(props); - this.def = def; - - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - - unconnect = (doUnconnect != null); - unconnectDef = doUnconnect; - BlockState defbs = this.stateDefinition.any() - .setValue(NORTH, Boolean.valueOf(false)) - .setValue(EAST, Boolean.valueOf(false)) - .setValue(SOUTH, Boolean.valueOf(false)) - .setValue(WEST, Boolean.valueOf(false)) - .setValue(WATERLOGGED, Boolean.valueOf(false)); - if (unconnect) { - defbs = defbs.setValue(UNCONNECT, unconnectDef); - } - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { - if (tempUNCONNECT != null) { - stateDefinition.add(tempUNCONNECT); - tempUNCONNECT = null; - } - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - stateDefinition.add(STATE); - } - super.createBlockStateDefinition(stateDefinition); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - if (unconnect && unconnectDef) { - return this.defaultBlockState(); - } - return super.getStateForPlacement(ctx); - } - - - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState nstate, LevelAccessor world, BlockPos pos, BlockPos pos2) { - if (unconnect && state.getValue(UNCONNECT)) { - if (state.getValue(WATERLOGGED)) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - return state; - } - return super.updateShape(state, dir, nstate, world, pos, pos); - } - - @Override - public boolean connectsTo(BlockState p_53330_, boolean p_53331_, Direction p_53332_) { - Block block = p_53330_.getBlock(); - boolean flag = this.isSameFence(p_53330_) && ((!p_53330_.hasProperty(UNCONNECT)) || (!p_53330_.getValue(UNCONNECT))); - boolean flag1 = block instanceof FenceGateBlock && FenceGateBlock.connectsToDirection(p_53330_, p_53332_); - return !isExceptionForConnection(p_53330_) && p_53331_ || flag || flag1; - } - - private boolean isSameFence(BlockState p_153255_) { - return p_153255_.is(BlockTags.FENCES) && p_153255_.is(BlockTags.WOODEN_FENCES) == this.defaultBlockState().is(BlockTags.WOODEN_FENCES); - } - - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } - else { - return InteractionResult.PASS; - } - } - - - private static String[] TAGS = { "fences" }; - private static String[] TAGS2 = { "fences", "wooden_fences" }; - @Override - public String[] getBlockTags() { - return def.getMaterial() == AuxMaterial.WOOD ? TAGS2 : TAGS; - } -} diff --git a/needsported/blocks/WCFenceGateBlock.java b/needsported/blocks/WCFenceGateBlock.java deleted file mode 100644 index 84089b4091..0000000000 --- a/needsported/blocks/WCFenceGateBlock.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.core.BlockPos; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - - -public class WCFenceGateBlock extends FenceGateBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCFenceGateBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean locked = false; - - protected WCFenceGateBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(AuxileryUtils.getWoodType(props, def), props); - this.def = def; - String type = def.getType(); - if (type != null) { - String[] toks = type.split(","); - for (String tok : toks) { - String [] flds = tok.split(":"); - if (flds.length < 2) continue; - if (flds[0].equals("locked")) { - locked = flds[1].equals("true"); - } - } - } - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.locked) { - if (player.isCreative() && player.getMainHandItem().isEmpty()) { - return super.useWithoutItem(state, level, pos, player, hitResult); - } - else { - return InteractionResult.PASS; - } - } - else { - return super.useWithoutItem(state, level, pos, player, hitResult); - } - } - - private static String[] TAGS = { "fence_gates" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCFireBlock.java b/needsported/blocks/WCFireBlock.java deleted file mode 100644 index dc5d6c3c2e..0000000000 --- a/needsported/blocks/WCFireBlock.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.Random; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.FireBlock; -import net.minecraft.core.Direction; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelReader; -import net.neoforged.neoforge.registries.RegisterEvent; - - -public class WCFireBlock extends FireBlock implements WesterosBlockLifecycle -{ - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noCollission().instabreak(); //.randomTicks(); - Block blk = new WCFireBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - private WesterosBlockDef def; - - protected WCFireBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - } - - @Override - public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) { - return true; - } - - - @Override - protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { -// super.tick(state, level, pos, random); - } - - @Override - public boolean canCatchFire(BlockGetter world, BlockPos pos, Direction face) { - return false; - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - private static String[] TAGS = { "fire" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCFlowerPotBlock.java b/needsported/blocks/WCFlowerPotBlock.java deleted file mode 100644 index c27ef38488..0000000000 --- a/needsported/blocks/WCFlowerPotBlock.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.*; -import java.util.function.Supplier; - -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.FlowerPotBlock; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCFlowerPotBlock extends FlowerPotBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - String emptyPotID = "minecraft:flower_pot"; - String plantBlockID = null; - - if (def.type != null) { - String[] toks = def.type.split(","); - for (String tok : toks) { - if (tok.startsWith("pot-id:")) { - emptyPotID = tok.substring(tok.indexOf(':')+1).trim(); - } - if (tok.equals("empty-pot")) { - emptyPotID = null; - } - if (tok.startsWith("plant-id:")) { - plantBlockID = tok.substring(tok.indexOf(':')+1).trim(); - } - } - } - //WesterosBlocks.log.info(String.format("pot-id=%s, plant-id=%s", emptyPotID, plantBlockID)); - - Supplier emptyPot = null; - Supplier plant = () -> null; - if (emptyPotID != null) { - emptyPotID = "flower_pot"; - FlowerPotBlock emptyPotBlk = (FlowerPotBlock) WesterosBlocks.findBlockByName(emptyPotID, "minecraft"); - if ((emptyPotBlk == null) || (emptyPotBlk == Blocks.AIR)) { - WesterosBlocks.log.error(String.format("emptyPotID '%s' not found for block '%s'", - emptyPotID, def.blockName)); - return null; - } - //WesterosBlocks.log.info(String.format("emptyPotBlk=%s", emptyPotBlk.getRegistryName())); - emptyPot = () -> emptyPotBlk; - if (plantBlockID != null) { - Block plantBlk = WesterosBlocks.findBlockByName(plantBlockID, "minecraft"); - if ((plantBlk == null) || (plantBlk == Blocks.AIR)) { - WesterosBlocks.log.error(String.format("plantBlockID '%s' not found for block '%s'", - plantBlockID, def.blockName)); - return null; - } - //WesterosBlocks.log.info(String.format("plantBlk=%s", plantBlk.getRegistryName())); - plant = () -> plantBlk; - } - } - Block blk = new WCFlowerPotBlock(emptyPot, plant, props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, def.nonOpaque); - } - } - protected WesterosBlockDef def; - - protected WCFlowerPotBlock(Supplier emptyPot, Supplier plant, BlockBehaviour.Properties props, WesterosBlockDef def) { - super(emptyPot, plant, props); - this.def = def; - Block pl = plant.get(); - if ((pl != null) && (emptyPot != null) && (emptyPot.get() != null)) { - //WesterosBlocks.log.info(String.format("addPlant=%s to %s", pl.getRegistryName(), emptyPot.get().getRegistryName())); - emptyPot.get().addPlant(BuiltInRegistries.BLOCK.getKey(pl), () -> this); - } - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = { "flower_pots" }; - @Override - public String[] getBlockTags() { - return TAGS; - } -} diff --git a/needsported/blocks/WCFurnaceBlock.java b/needsported/blocks/WCFurnaceBlock.java deleted file mode 100644 index ec3c822c26..0000000000 --- a/needsported/blocks/WCFurnaceBlock.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.Random; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.FurnaceBlock; -import net.minecraft.world.MenuProvider; -import net.minecraft.world.entity.player.Player; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.stats.Stats; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.core.Direction; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import com.westeroscraft.westerosblocks.tileentity.WCFurnaceBlockEntity; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.registries.RegisterEvent; - -// Custom furnace block -public class WCFurnaceBlock extends FurnaceBlock implements WesterosBlockLifecycle { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - final boolean alwaysOnVal = def.getTypeValue("always-on").equals("true"); - BlockBehaviour.Properties props = def.makeProperties().lightLevel((state) -> { - return (alwaysOnVal || state.getValue(BlockStateProperties.LIT)) ? (int) (16 * def.lightValue) : 0; - }); - Block blk = new WCFurnaceBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - Block rblk = def.registerRenderType(blk, true, def.nonOpaque); - // Register tile entity - WesterosBlockDef.registerBlockEntity(WCFurnaceBlockEntity.ENTITYTYPE, WCFurnaceBlockEntity::new, rblk); - - return rblk; - - } - } - - private WesterosBlockDef def; - private boolean alwaysOn; - - protected WCFurnaceBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - alwaysOn = def.getTypeValue("always-on").equals("true"); - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, false)); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { - boolean lit = state.getValue(LIT); - boolean active = alwaysOn || lit; - - if (active) { - double d0 = (double) pos.getX() + 0.5D; - double d1 = (double) pos.getY(); - double d2 = (double) pos.getZ() + 0.5D; - if (random.nextDouble() < 0.1D) { - world.playLocalSound(d0, d1, d2, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, - false); - } - - Direction direction = state.getValue(FACING); - Direction.Axis direction$axis = direction.getAxis(); - double d4 = random.nextDouble() * 0.6D - 0.3D; - double d5 = direction$axis == Direction.Axis.X ? (double) direction.getStepX() * 0.52D : d4; - double d6 = random.nextDouble() * 6.0D / 16.0D; - double d7 = direction$axis == Direction.Axis.Z ? (double) direction.getStepZ() * 0.52D : d4; - world.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); - world.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); - } - } - - @Override - public BlockEntity newBlockEntity(BlockPos pos, BlockState bs) { - return new WCFurnaceBlockEntity(pos, bs); - } - - @Override - protected void openContainer(Level world, BlockPos pos, Player player) { - BlockEntity blockentity = world.getBlockEntity(pos); - if (blockentity instanceof WCFurnaceBlockEntity) { - player.openMenu((MenuProvider)blockentity); - player.awardStat(Stats.INTERACT_WITH_FURNACE); - } - } - - private static String[] TAGS = {}; - - @Override - public String[] getBlockTags() { - return TAGS; - } -} diff --git a/needsported/blocks/WCHalfDoorBlock.java b/needsported/blocks/WCHalfDoorBlock.java deleted file mode 100644 index d9d43279c7..0000000000 --- a/needsported/blocks/WCHalfDoorBlock.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.gameevent.GameEvent; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.DoorHingeSide; -import net.minecraft.core.Direction; -import net.minecraft.util.Mth; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; - -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.registries.RegisterEvent; - -import javax.annotation.Nullable; - -public class WCHalfDoorBlock extends Block implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - def.nonOpaque = true; - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCHalfDoorBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - public static final BooleanProperty OPEN = BlockStateProperties.OPEN; - public static final EnumProperty HINGE = BlockStateProperties.DOOR_HINGE; - public static final BooleanProperty POWERED = BlockStateProperties.POWERED; - protected static final VoxelShape SOUTH_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D); - protected static final VoxelShape NORTH_AABB = Block.box(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D); - protected static final VoxelShape WEST_AABB = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); - protected static final VoxelShape EAST_AABB = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D); - - private WesterosBlockDef def; - private boolean locked = false; - private boolean allow_unsupported = false; - private final AuxMaterial material; - - protected WCHalfDoorBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String type = def.getType(); - if (type != null) { - String[] toks = type.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - String[] flds = tok.split(":"); - if (flds.length < 2) continue; - if (flds[0].equals("locked")) { - locked = flds[1].equals("true"); - } - } - } - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPEN, Boolean.valueOf(false)).setValue(HINGE, DoorHingeSide.LEFT).setValue(POWERED, Boolean.valueOf(false))); - this.material = AuxMaterial.getMaterial(props, def); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext selCtx) { - Direction direction = state.getValue(FACING); - boolean flag = !state.getValue(OPEN); - boolean flag1 = state.getValue(HINGE) == DoorHingeSide.RIGHT; - switch (direction) { - case EAST: - default: - return flag ? EAST_AABB : (flag1 ? NORTH_AABB : SOUTH_AABB); - case SOUTH: - return flag ? SOUTH_AABB : (flag1 ? EAST_AABB : WEST_AABB); - case WEST: - return flag ? WEST_AABB : (flag1 ? SOUTH_AABB : NORTH_AABB); - case NORTH: - return flag ? NORTH_AABB : (flag1 ? WEST_AABB : EAST_AABB); - } - } - - @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { - return Shapes.empty(); - } - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch (pathComputationType) { - case LAND: - return state.getValue(OPEN); - case WATER: - return false; - case AIR: - return state.getValue(OPEN); - default: - return false; - } - } - - - private int getCloseSound() { - return this.material == AuxMaterial.METAL ? 1011 : 1012; - } - - private int getOpenSound() { - return this.material == AuxMaterial.METAL ? 1005 : 1006; - } - - @Nullable - @Override - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockPos blockpos = ctx.getClickedPos(); - Level level = ctx.getLevel(); - boolean flag = level.hasNeighborSignal(blockpos); - return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()).setValue(HINGE, this.getHinge(ctx)).setValue(POWERED, Boolean.valueOf(flag)).setValue(OPEN, Boolean.valueOf(flag)); - } - - private DoorHingeSide getHinge(BlockPlaceContext ctx) { - BlockGetter BlockGetter = ctx.getLevel(); - BlockPos blockpos = ctx.getClickedPos(); - Direction direction = ctx.getHorizontalDirection(); - BlockPos blockpos1 = blockpos.above(); - Direction direction1 = direction.getCounterClockWise(); - BlockPos blockpos2 = blockpos.relative(direction1); - BlockState blockstate = BlockGetter.getBlockState(blockpos2); - BlockPos blockpos3 = blockpos1.relative(direction1); - BlockState blockstate1 = BlockGetter.getBlockState(blockpos3); - Direction direction2 = direction.getClockWise(); - BlockPos blockpos4 = blockpos.relative(direction2); - BlockState blockstate2 = BlockGetter.getBlockState(blockpos4); - BlockPos blockpos5 = blockpos1.relative(direction2); - BlockState blockstate3 = BlockGetter.getBlockState(blockpos5); - int i = (blockstate.isCollisionShapeFullBlock(BlockGetter, blockpos2) ? -1 : 0) + (blockstate1.isCollisionShapeFullBlock(BlockGetter, blockpos3) ? -1 : 0) + (blockstate2.isCollisionShapeFullBlock(BlockGetter, blockpos4) ? 1 : 0) + (blockstate3.isCollisionShapeFullBlock(BlockGetter, blockpos5) ? 1 : 0); - boolean flag = blockstate.is(this); - boolean flag1 = blockstate2.is(this); - if ((!flag || flag1) && i <= 0) { - if ((!flag1 || flag) && i >= 0) { - int j = direction.getStepX(); - int k = direction.getStepZ(); - Vec3 vec3 = ctx.getClickLocation(); - double d0 = vec3.x - (double) blockpos.getX(); - double d1 = vec3.z - (double) blockpos.getZ(); - return (j >= 0 || !(d1 < 0.5D)) && (j <= 0 || !(d1 > 0.5D)) && (k >= 0 || !(d0 > 0.5D)) && (k <= 0 || !(d0 < 0.5D)) ? DoorHingeSide.LEFT : DoorHingeSide.RIGHT; - } else { - return DoorHingeSide.LEFT; - } - } else { - return DoorHingeSide.RIGHT; - } - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.locked) { - return InteractionResult.PASS; - } else { - state = state.cycle(OPEN); - level.setBlock(pos, state, 10); - level.levelEvent(player, state.getValue(OPEN) ? this.getOpenSound() : this.getCloseSound(), pos, 0); - level.gameEvent(player, this.isOpen(state) ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, player.position()); - // Is this a door we should be planning to close - if (WesterosBlocks.isAutoRestoreHalfDoor(state.getBlock())) { - boolean isCreative = (player != null) ? player.isCreative() : false; - WesterosBlocks.setPendingHalfDoorRestore(level, pos, !state.getValue(OPEN), isCreative); - } - return InteractionResult.sidedSuccess(level.isClientSide); - } - } - - public boolean isOpen(BlockState state) { - return state.getValue(OPEN); - } - - public void setOpen(@Nullable Entity entity, Level level, BlockState state, BlockPos pos, boolean open) { - if (state.is(this) && state.getValue(OPEN) != open) { - level.setBlock(pos, state.setValue(OPEN, Boolean.valueOf(open)), 10); - this.playSound(level, pos, open); - level.gameEvent(entity, open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); - } - } - - @Override - public void neighborChanged(BlockState state, Level level, BlockPos ppos, Block block, BlockPos pos2, boolean chg) { - boolean flag = level.hasNeighborSignal(ppos); - if (block != this && flag != state.getValue(POWERED)) { - if (flag != state.getValue(OPEN)) { - this.playSound(level, ppos, flag); - level.gameEvent(flag ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, ppos, GameEvent.Context.of(state)); - } - - level.setBlock(ppos, state.setValue(POWERED, Boolean.valueOf(flag)).setValue(OPEN, Boolean.valueOf(flag)), 2); - } - - } - - @Override - public boolean canSurvive(BlockState state, LevelReader reader, BlockPos pos) { - if (allow_unsupported) return true; - BlockPos blockpos = pos.below(); - BlockState blockstate = reader.getBlockState(blockpos); - return blockstate.isFaceSturdy(reader, blockpos, Direction.UP); - } - - private void playSound(Level level, BlockPos pos, boolean open) { - level.levelEvent((Player) null, open ? this.getOpenSound() : this.getCloseSound(), pos, 0); - } - - @Override - public PushReaction getPistonPushReaction(BlockState p_52814_) { - return PushReaction.DESTROY; - } - - @Override - public BlockState rotate(BlockState state, Rotation rot) { - return state.setValue(FACING, rot.rotate(state.getValue(FACING))); - } - - @SuppressWarnings("deprecation") - @Override - public BlockState mirror(BlockState state, Mirror mirror) { - return mirror == Mirror.NONE ? state : state.rotate(mirror.getRotation(state.getValue(FACING))).cycle(HINGE); - } - - @OnlyIn(Dist.CLIENT) - @Override - public long getSeed(BlockState state, BlockPos pos) { - return Mth.getSeed(pos.getX(), pos.below(0).getY(), pos.getZ()); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder state) { - state.add(FACING, OPEN, HINGE, POWERED); - } - - private static String[] TAGS = {"doors"}; - - @Override - public String[] getBlockTags() { - return TAGS; - } -} diff --git a/needsported/blocks/WCLadderBlock.java b/needsported/blocks/WCLadderBlock.java deleted file mode 100644 index e4d73273d4..0000000000 --- a/needsported/blocks/WCLadderBlock.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.block.LadderBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelReader; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCLadderBlock extends LadderBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noOcclusion(); - - Block blk = new WCLadderBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean allow_unsupported; - private boolean no_climb; - - protected WCLadderBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - if (tok.equals("no-climb")) { - no_climb = true; - } - } - } - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { - return Shapes.empty(); - } - - @Override - public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { - return allow_unsupported || super.canSurvive(state, world, pos); - } - private static String[] TAGS = { "climbable" }; - private static String[] TAGS_NOCLIMB = { }; - @Override - public String[] getBlockTags() { - if (no_climb) return TAGS_NOCLIMB; - return TAGS; - } - -} diff --git a/needsported/blocks/WCLayerBlock.java b/needsported/blocks/WCLayerBlock.java deleted file mode 100644 index 6fc9d3c8e2..0000000000 --- a/needsported/blocks/WCLayerBlock.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.tags.FluidTags; -import net.minecraft.core.Direction; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelAccessor; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCLayerBlock extends Block implements WesterosBlockLifecycle, SimpleWaterloggedBlock { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - props = props.isViewBlocking((state, level, pos) -> { - return state.getValue(LAYERS) >= 8; - }); - Block blk = new WCLayerBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public static final IntegerProperty LAYERS = BlockStateProperties.LAYERS; - public final int layerCount = 8; - public boolean softLayer = false; - - public static final VoxelShape[] SHAPE_BY_LAYER = new VoxelShape[]{Shapes.empty(), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)}; - - private WesterosBlockDef def; - - protected WCLayerBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if ((t != null) && (t.indexOf("softLayer") >= 0)) { - softLayer = true; - } - this.registerDefaultState(this.stateDefinition.any().setValue(LAYERS, Integer.valueOf(1)).setValue(WATERLOGGED, - Boolean.valueOf(false))); - } - - public VoxelShape getShape(BlockState p_56620_, BlockGetter p_56621_, BlockPos p_56622_, CollisionContext p_56623_) { - return SHAPE_BY_LAYER[p_56620_.getValue(LAYERS)]; - } - - public VoxelShape getCollisionShape(BlockState p_56625_, BlockGetter p_56626_, BlockPos p_56627_, CollisionContext p_56628_) { - return SHAPE_BY_LAYER[p_56625_.getValue(LAYERS) - 1]; - } - - public VoxelShape getBlockSupportShape(BlockState p_56632_, BlockGetter p_56633_, BlockPos p_56634_) { - return SHAPE_BY_LAYER[p_56632_.getValue(LAYERS)]; - } - - public VoxelShape getVisualShape(BlockState p_56597_, BlockGetter p_56598_, BlockPos p_56599_, CollisionContext p_56600_) { - return SHAPE_BY_LAYER[p_56597_.getValue(LAYERS)]; - } - - //public boolean useShapeForLightOcclusion(BlockState p_56630_) { - // return true; - //} - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public boolean canBeReplaced(BlockState state, BlockPlaceContext itemContext) { - int i = state.getValue(LAYERS); - if (itemContext.getItemInHand().getItem() == this.asItem() && i < layerCount) { - if (itemContext.replacingClickedOnBlock()) { - return itemContext.getClickedFace() == Direction.UP; - } else { - return true; - } - } else { - return false; - } - } - - @Nullable - @Override - public BlockState getStateForPlacement(BlockPlaceContext itemContext) { - BlockPos blockpos = itemContext.getClickedPos(); - BlockState blockstate = itemContext.getLevel().getBlockState(blockpos); - FluidState fluidstate = itemContext.getLevel().getFluidState(blockpos); - if (blockstate.is(this)) { - int i = blockstate.getValue(LAYERS); - int newCount = Math.min(layerCount, i + 1); - return blockstate.setValue(LAYERS, Integer.valueOf(newCount)). - setValue(WATERLOGGED, Boolean.valueOf((newCount < layerCount) && fluidstate.is(FluidTags.WATER))); - } - else { - return this.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - } - } - - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - @Override - public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluid) { - return (state.getValue(LAYERS) < layerCount) ? SimpleWaterloggedBlock.super.placeLiquid(world, pos, state, fluid) - : false; - } - - @Override - public boolean canPlaceLiquid(@org.jetbrains.annotations.Nullable Player player, BlockGetter level, BlockPos pos, BlockState state, Fluid fluid) { - return (state.getValue(LAYERS) < layerCount) ? SimpleWaterloggedBlock.super.canPlaceLiquid(player, level, pos, state, fluid) - : false; - } - - @SuppressWarnings("deprecation") - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState state2, LevelAccessor level, BlockPos pos, - BlockPos pos2) { - if (state.getValue(WATERLOGGED)) { - level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); - } - return super.updateShape(state, dir, state2, level, pos, pos2); - } - - public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType PathComputationType) { - switch (PathComputationType) { - case LAND: - return state.getValue(LAYERS) <= (layerCount / 2); - case WATER: - return world.getFluidState(pos).is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - StateDefinition.add(LAYERS, WATERLOGGED); - } - - private static String[] TAGS = {}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCLeavesBlock.java b/needsported/blocks/WCLeavesBlock.java deleted file mode 100644 index 6e693a1597..0000000000 --- a/needsported/blocks/WCLeavesBlock.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.LeavesBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCLeavesBlock extends LeavesBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - if (def.lightOpacity == WesterosBlockDef.DEF_INT) { - def.lightOpacity = 1; - } - BlockBehaviour.Properties props = def.makeProperties().noOcclusion().isSuffocating((state, reader, pos) -> false).isViewBlocking((state, reader, pos) -> false); - Block blk = new WCLeavesBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, true, true); - } - } - protected WesterosBlockDef def; - private final boolean nodecay; - public final boolean betterfoliage; - public final boolean overlay; - - protected WCLeavesBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String typ = def.getType(); - betterfoliage = (typ != null) && typ.contains("better-foliage"); - overlay = (typ != null) && typ.contains("overlay"); - nodecay = (typ != null) && typ.contains("no-decay"); - this.registerDefaultState(this.stateDefinition.any().setValue(DISTANCE, Integer.valueOf(7)).setValue(PERSISTENT, Boolean.valueOf(!nodecay))); - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = { "leaves" }; - @Override - public String[] getBlockTags() { - return TAGS; - } -} diff --git a/needsported/blocks/WCLogBlock.java b/needsported/blocks/WCLogBlock.java deleted file mode 100644 index d228adc33d..0000000000 --- a/needsported/blocks/WCLogBlock.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RotatedPillarBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCLogBlock extends RotatedPillarBlock implements WesterosBlockLifecycle { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - - Block blk = new WCLogBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - protected WesterosBlockDef def; - - protected WCLogBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = {"logs"}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCPaneBlock.java b/needsported/blocks/WCPaneBlock.java deleted file mode 100644 index 4c505a50d3..0000000000 --- a/needsported/blocks/WCPaneBlock.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.IronBarsBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCPaneBlock extends IronBarsBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noOcclusion(); - String t = def.getType(); - boolean doUnconnect = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - if (parts[0].equals("unconnect")) { - doUnconnect = true; - tempUNCONNECT = UNCONNECT; - } - } - } - Block blk = new WCPaneBlock(props, def, doUnconnect); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, true); - } - } - - public static final BooleanProperty UNCONNECT = BooleanProperty.create("unconnect"); - protected static BooleanProperty tempUNCONNECT; - - private WesterosBlockDef def; - private boolean legacy_model; - private boolean bars_model; - public final boolean unconnect; - - protected WCPaneBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doUnconnect) { - super(props); - this.def = def; - this.unconnect = doUnconnect; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("legacy-model")) { - legacy_model = true; - } - if (tok.equals("bars-model")) { - bars_model = true; - } - } - } - if (doUnconnect) { - this.registerDefaultState(this.stateDefinition.any(). - setValue(NORTH, Boolean.valueOf(false)). - setValue(EAST, Boolean.valueOf(false)). - setValue(SOUTH, Boolean.valueOf(false)). - setValue(WEST, Boolean.valueOf(false)). - setValue(WATERLOGGED, Boolean.valueOf(false)). - setValue(UNCONNECT, Boolean.valueOf(false))); - } - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder sd) { - if (tempUNCONNECT != null) { - sd.add(tempUNCONNECT); - tempUNCONNECT = null; - } - super.createBlockStateDefinition(sd); - } - - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState nstate, LevelAccessor world, BlockPos pos, BlockPos pos2) { - if (unconnect && state.getValue(UNCONNECT)) { - if (state.getValue(WATERLOGGED)) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - return state; - } - return super.updateShape(state, dir, nstate, world, pos, pos); - } - - public boolean isLegacyModel() { - return legacy_model; - } - - public boolean isBarsModel() { - return bars_model; - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = { }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCParticleBlock.java b/needsported/blocks/WCParticleBlock.java deleted file mode 100644 index 9fc485e42a..0000000000 --- a/needsported/blocks/WCParticleBlock.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.*; -import net.minecraft.ChatFormatting; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.core.particles.SimpleParticleType; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.neoforge.registries.RegisterEvent; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; -import java.util.Random; - -public class WCParticleBlock extends Block implements SimpleWaterloggedBlock, WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noCollission().noOcclusion(); - - Block blk = new WCParticleBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, true); - } - } - - private final WesterosBlockDef def; - protected static final VoxelShape OFF_SHAPE = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 12.0D, 12.0D); - protected static final VoxelShape ON_SHAPE = Block.box(6.0D, 6.0D, 6.0D, 10.0D, 10.0D, 10.0D); - - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public static final BooleanProperty POWERED = BlockStateProperties.POWERED; - public static final IntegerProperty PARTICLE_RANGE = IntegerProperty.create("range", 1, 10); - public static final IntegerProperty PARTICLE_STRENGTH = IntegerProperty.create("strength", 1, 10); - - - protected WCParticleBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - - this.registerDefaultState(this.defaultBlockState().setValue(POWERED, Boolean.valueOf(false)).setValue(PARTICLE_STRENGTH, 1).setValue(PARTICLE_RANGE, 1).setValue(WATERLOGGED, Boolean.valueOf(false))); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @SuppressWarnings("null") - @Override - public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { - if (state.getValue(POWERED)) { - return ON_SHAPE; - } else { - return OFF_SHAPE; - } - } - - @Override - public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { - final String ptype = def.getTypeValue("particleType"); - super.animateTick(state, level, pos, random); - - if (state.getValue(POWERED)) { - for (int i = 0; i < state.getValue(PARTICLE_STRENGTH); i++) { - level.addParticle(getParticleByType(ptype), true, - (double) pos.getX() - ((double) state.getValue(PARTICLE_RANGE) / 2) + random.nextDouble(), - (double) pos.getY() - ((double) state.getValue(PARTICLE_RANGE) / 2) + random.nextDouble(), - (double) pos.getZ() - ((double) state.getValue(PARTICLE_RANGE) / 2) + random.nextDouble(), - 0.0D, 0.0D, 0.00); - } - } - } - - - @SuppressWarnings("null") - @Override - public VoxelShape getCollisionShape(BlockState state, @NotNull BlockGetter p_58056_, BlockPos p_58057_, - CollisionContext p_58058_) { - if (state.getValue(POWERED)) { - return Shapes.empty(); - } else { - return OFF_SHAPE; - } - } - - @SuppressWarnings("null") - @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(POWERED, PARTICLE_STRENGTH, PARTICLE_RANGE, WATERLOGGED); - } - - @SuppressWarnings("null") - @Override - public BlockState getStateForPlacement(BlockPlaceContext context) { - FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos()); - - return this.defaultBlockState().setValue(POWERED, false).setValue(PARTICLE_STRENGTH, 1).setValue(PARTICLE_RANGE, 1).setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER)); - } - - @SuppressWarnings("null") - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState state2, LevelAccessor world, BlockPos pos, - BlockPos pos2) { - if (state.getValue(WATERLOGGED)) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - - return super.updateShape(state, dir, state2, world, pos, pos2); - } - - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - // TODO -// @Override -// protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { -// -// level.playSound(null, pos, SoundEvents.UI_BUTTON_CLICK, SoundSource.BLOCKS, 1.0f, 1.0f); -// -// // auto set power on first use -// if (!state.getValue(POWERED) && player.getMainHandItem().isEmpty()) { -// level.setBlock(pos, this.defaultBlockState().setValue(POWERED, true).setValue(PARTICLE_STRENGTH, state.getValue(PARTICLE_STRENGTH)).setValue(WATERLOGGED, Boolean.valueOf(level.getFluidState(pos).getType() == Fluids.WATER)), 11); -// } -// -// if (state.getValue(POWERED) && player.getMainHandItem().isEmpty()) { -// int range = state.getValue(PARTICLE_RANGE); -// int strength = state.getValue(PARTICLE_STRENGTH); -// -// if (player.isShiftKeyDown()) { -// // calculate the new range value -// range = range + 1; -// if (range > Config.particleEmitterRangeMax.get()) range = 1; -// if (range == 0) range = 10; -// if (level.isClientSide) { -// player.sendMessage(new TextComponent(ChatFormatting.YELLOW + "PARTICLE RANGE: " + range), player.getUUID()); -// } -// } else { -// // otherwise calculate strength value -// strength = strength + 1; -// if (strength > WesterosBlocks.Config.particleEmitterStrengthMax.get()) strength = 1; -// if (strength == 0) strength = 10; -// if (level.isClientSide) { -// player.sendMessage(new TextComponent(ChatFormatting.YELLOW + "PARTICLE STRENGTH: " + strength), player.getUUID()); -// } -// } -// -// level.setBlock(pos, this.defaultBlockState().setValue(POWERED, true).setValue(PARTICLE_STRENGTH, strength).setValue(PARTICLE_RANGE, range).setValue(WATERLOGGED, level.getFluidState(pos).getType() == Fluids.WATER), 11); -// -// return InteractionResult.sidedSuccess(level.isClientSide); -// -// } else { -// return InteractionResult.PASS; -// } -// } - - private static final String[] TAGS = {}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - - public static SimpleParticleType getParticleByType(String type) { - return switch (type) { - case "campfire_cosy_smoke" -> ParticleTypes.CAMPFIRE_COSY_SMOKE; - case "campfire_signal_smoke" -> ParticleTypes.CAMPFIRE_SIGNAL_SMOKE; - case "smoke" -> ParticleTypes.SMOKE; - case "large_smoke" -> ParticleTypes.LARGE_SMOKE; - case "ash" -> ParticleTypes.ASH; - case "bubble" -> ParticleTypes.BUBBLE; - default -> ParticleTypes.CLOUD; - }; - } -} diff --git a/needsported/blocks/WCPlantBlock.java b/needsported/blocks/WCPlantBlock.java deleted file mode 100644 index 18af70637c..0000000000 --- a/needsported/blocks/WCPlantBlock.java +++ /dev/null @@ -1,210 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SlabBlock; -import net.minecraft.world.level.block.SnowLayerBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.tags.FluidTags; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -import javax.annotation.Nullable; - -public class WCPlantBlock extends Block implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noCollission().instabreak(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - String t = def.getType(); - if ((t != null) && (t.indexOf(WesterosBlockDef.LAYER_SENSITIVE) >= 0)) { - tempLAYERS = BlockStateProperties.LAYERS; - } - Block blk = new WCPlantBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - private WesterosBlockDef def; - protected static WesterosBlockDef.StateProperty tempSTATE; - protected static IntegerProperty tempLAYERS; - protected WesterosBlockDef.StateProperty STATE; - protected IntegerProperty LAYERS; - protected boolean toggleOnUse = false; - public boolean layerSensitive = false; - - public static final VoxelShape[] SHAPE_BY_LAYER = new VoxelShape[]{Shapes.empty(), Block.box(0.0D, -14.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, -12.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, -10.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, -8.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, -6.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, -4.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, -2.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)}; - - protected WCPlantBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - BlockState defbs = this.stateDefinition.any().setValue(WATERLOGGED, Boolean.valueOf(false)); - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - if (LAYERS != null) { - defbs = defbs.setValue(LAYERS, 8); - } - this.registerDefaultState(defbs); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState bs = super.getStateForPlacement(ctx); - if (bs == null) return null; - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - bs = bs.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - if (LAYERS != null) { - BlockState below = ctx.getLevel().getBlockState(ctx.getClickedPos().relative(Direction.DOWN)); - if ((below != null) && (below.hasProperty(BlockStateProperties.LAYERS))) { - Block blk = below.getBlock(); - Integer layer = below.getValue(BlockStateProperties.LAYERS); - // See if soft layer - if ((blk instanceof SnowLayerBlock) || ((blk instanceof WCLayerBlock) && ((WCLayerBlock) blk).softLayer)) { - layer = (layer > 2) ? Integer.valueOf(layer - 2) : Integer.valueOf(1); - } - bs = bs.setValue(LAYERS, layer); - } else if ((below != null) && (below.getBlock() instanceof SlabBlock)) { - SlabType slabtype = below.getValue(BlockStateProperties.SLAB_TYPE); - if (slabtype == SlabType.BOTTOM) bs = bs.setValue(LAYERS, 4); - } - } - return bs; - } - - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch (pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (tempLAYERS != null) { - LAYERS = tempLAYERS; - tempLAYERS = null; - } - if (STATE != null) { - stateDefinition.add(STATE); - } - if (LAYERS != null) { - stateDefinition.add(LAYERS); - } - stateDefinition.add(WATERLOGGED); - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } else { - return InteractionResult.PASS; - } - } - -// TODO: not sure if required anymore -// @Override -// public BlockState getPlant(BlockGetter world, BlockPos pos) { -// BlockState state = world.getBlockState(pos); -// if (state.getBlock() != this) return defaultBlockState(); -// return state; -// } - - @Override - public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { - return state.getFluidState().isEmpty(); - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) { - if (LAYERS != null) { - return SHAPE_BY_LAYER[state.getValue(LAYERS)]; - } else { - return Shapes.block(); - } - } - - private static String[] TAGS = {"flowers"}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCRailBlock.java b/needsported/blocks/WCRailBlock.java deleted file mode 100644 index 58f5b9f0ac..0000000000 --- a/needsported/blocks/WCRailBlock.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RailBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCRailBlock extends RailBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noOcclusion().noCollission(); - - Block blk = new WCRailBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean allow_unsupported = false; - - protected WCRailBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - } - } - - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public boolean canSurvive(BlockState p_49395_, LevelReader p_49396_, BlockPos p_49397_) { - if (this.allow_unsupported) return true; - return super.canSurvive(p_49395_, p_49396_, p_49397_); - } - - @Override - public void neighborChanged(BlockState p_49377_, Level p_49378_, BlockPos p_49379_, Block p_49380_, BlockPos p_49381_, boolean p_49382_) { - if (!this.allow_unsupported) { - super.neighborChanged(p_49377_, p_49378_, p_49379_, p_49380_, p_49381_, p_49382_); - } - else if (!p_49378_.isClientSide && p_49378_.getBlockState(p_49379_).is(this)) { - this.updateState(p_49377_, p_49378_, p_49379_, p_49380_); - } - } - - private static String[] TAGS = { "rails" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCSandBlock.java b/needsported/blocks/WCSandBlock.java deleted file mode 100644 index 033204ff79..0000000000 --- a/needsported/blocks/WCSandBlock.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.ColorRGBA; -import net.minecraft.world.level.block.ColoredFallingBlock; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCSandBlock extends ColoredFallingBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCSandBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, true, false); - } - } - - private WesterosBlockDef def; - - protected WCSandBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(new ColorRGBA(14406560), props); // TODO: configurable dust color - this.def = def; - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = { "sand" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCSlabBlock.java b/needsported/blocks/WCSlabBlock.java deleted file mode 100644 index 5ba4763e66..0000000000 --- a/needsported/blocks/WCSlabBlock.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.*; - -import javax.annotation.Nullable; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.SlabBlock; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.core.BlockPos; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCSlabBlock extends SlabBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - // Process types - String t = def.getType(); - boolean doConnectstate = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - // See if we have connectstate - if (parts[0].equals("connectstate")) { - doConnectstate = true; - tempCONNECTSTATE = CONNECTSTATE; - } - } - } - Block blk = new WCSlabBlock(props, def, doConnectstate); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - protected WesterosBlockDef def; - - public static final IntegerProperty CONNECTSTATE = IntegerProperty.create("connectstate", 0, 3); - protected static IntegerProperty tempCONNECTSTATE; - public final boolean connectstate; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - - protected boolean toggleOnUse = false; - - protected WCSlabBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doConnectstate) { - super(props); - this.def = def; - - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - - connectstate = doConnectstate; - BlockState defbs = this.stateDefinition.any(); - if (connectstate) { - defbs = defbs.setValue(CONNECTSTATE, 0); - } - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - protected WCSlabBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - this(props, def, false); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - if (tempCONNECTSTATE != null) { - StateDefinition.add(tempCONNECTSTATE); - tempCONNECTSTATE = null; - } - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - StateDefinition.add(STATE); - } - super.createBlockStateDefinition(StateDefinition); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState bs = super.getStateForPlacement(ctx); - return bs; - } - - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } - else { - return InteractionResult.PASS; - } - } - - private static String[] TAGS = { "slabs" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCSolidBlock.java b/needsported/blocks/WCSolidBlock.java deleted file mode 100644 index 1d79087f21..0000000000 --- a/needsported/blocks/WCSolidBlock.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.neoforged.neoforge.registries.RegisterEvent; - -import javax.annotation.Nullable; - -public class WCSolidBlock extends Block implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - // Process types - String t = def.getType(); - boolean doConnectstate = false; - Boolean doSymmetrical = null; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - // See if we have connectstate - if (parts[0].equals("connectstate")) { - doConnectstate = true; - tempCONNECTSTATE = CONNECTSTATE; - } - // See if we have symmetrical - if (parts[0].equals("symmetrical")) { - doSymmetrical = "true".equals(parts[1]); - tempSYMMETRICAL = SYMMETRICAL; - } - } - } - boolean finalDoConnectstate = doConnectstate; - Boolean finalDoSymmetrical = doSymmetrical; - - Block blk = new WCSolidBlock(props, def, finalDoConnectstate, finalDoSymmetrical); - - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); -// AuxileryUtils.registerCreativeTab(blk.asItem(), def.creativeTab); - return def.registerRenderType(blk, true, def.nonOpaque); - } - } - - protected WesterosBlockDef def; - protected VoxelShape collisionbox; - protected VoxelShape supportbox; - - public static final IntegerProperty CONNECTSTATE = IntegerProperty.create("connectstate", 0, 3); - protected static IntegerProperty tempCONNECTSTATE; - public final boolean connectstate; - - public static final BooleanProperty SYMMETRICAL = BooleanProperty.create("symmetrical"); - protected static BooleanProperty tempSYMMETRICAL; - - public final boolean symmetrical; - public final Boolean symmetricalDef; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - - protected boolean toggleOnUse = false; - - protected WCSolidBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doConnectstate, Boolean doSymmetrical) { - super(props); - this.def = def; - - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - - collisionbox = def.makeCollisionBoxShape(); - if (def.supportBoxes == null) { - supportbox = collisionbox; - } else { - supportbox = def.makeSupportBoxShape(null); - } - - connectstate = doConnectstate; - symmetrical = (doSymmetrical != null); - symmetricalDef = doSymmetrical; - BlockState defbs = this.stateDefinition.any(); - if (connectstate) { - defbs = defbs.setValue(CONNECTSTATE, 0); - } - if (symmetrical) { - defbs = defbs.setValue(SYMMETRICAL, symmetricalDef); - } - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - protected WCSolidBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doConnectstate) { - this(props, def, doConnectstate, null); - } - - protected WCSolidBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - this(props, def, false, null); - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - return collisionbox; - } - - @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - return collisionbox; - } - - @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { - return supportbox; - } - - @Override - public VoxelShape getVisualShape(BlockState state, BlockGetter reader, BlockPos pos, CollisionContext ctx) { - if (def.nonOpaque) - return Shapes.empty(); - else - return collisionbox; - } - - @SuppressWarnings("deprecation") - public boolean skipRendering(BlockState state, BlockState other_state, Direction direction) { - if (def.nonOpaque) - return other_state.is(this) ? true : super.skipRendering(state, other_state, direction); - else - return false; - } - - - public float getShadeBrightness(BlockState p_48731_, BlockGetter p_48732_, BlockPos p_48733_) { - return (def.lightOpacity == 0) ? 1.0F : 0.2F; - } - - public boolean propagatesSkylightDown(BlockState p_48740_, BlockGetter p_48741_, BlockPos p_48742_) { - return (def.lightOpacity == 0); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder StateDefinition) { - if (tempCONNECTSTATE != null) { - StateDefinition.add(tempCONNECTSTATE); - tempCONNECTSTATE = null; - } - if (tempSYMMETRICAL != null) { - StateDefinition.add(tempSYMMETRICAL); - tempSYMMETRICAL = null; - } - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - StateDefinition.add(STATE); - } - super.createBlockStateDefinition(StateDefinition); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState bs = super.getStateForPlacement(ctx); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - return bs; - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } else { - return InteractionResult.PASS; - } - } - - private static String[] TAGS = {}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCSoulSandBlock.java b/needsported/blocks/WCSoulSandBlock.java deleted file mode 100644 index 3eca84d3a0..0000000000 --- a/needsported/blocks/WCSoulSandBlock.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoulSandBlock; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCSoulSandBlock extends SoulSandBlock implements WesterosBlockLifecycle { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCSoulSandBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, true, false); - } - } - - private WesterosBlockDef def; - - protected WCSoulSandBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static String[] TAGS = { "soul_speed_blocks" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCSoundBlock.java b/needsported/blocks/WCSoundBlock.java deleted file mode 100644 index a473968a89..0000000000 --- a/needsported/blocks/WCSoundBlock.java +++ /dev/null @@ -1,222 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundSource; - -import java.util.Random; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCSoundBlock extends WCSolidBlock { - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().randomTicks(); - if ((def.soundList == null) || (def.soundList.size() == 0)) { - WesterosBlocks.log.error(String.format("Non-empty soundList rrquired for ''%s'", def.blockName)); - return null; - } - if ((def.soundList != null) && (def.soundList.size() > 1)) { - protoINDEX = IntegerProperty.create("index", 0, def.soundList.size()-1); - } - Block blk = new WCSoundBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, true, def.nonOpaque); - } - } - - private static IntegerProperty protoINDEX; // Hand off for registration - - public static final BooleanProperty POWERED = BlockStateProperties.POWERED; - public IntegerProperty INDEX; // 0 = no sound selected, else soundList[val-1] - public int playback_period; - public int random_playback_addition; - public int startTime; - public int endTime; - - protected WCSoundBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props, def); - String type = def.getType(); - if (type != null) { - String[] toks = type.split(","); - for (String tok : toks) { - String[] flds = tok.split(":"); - if (flds.length < 2) - continue; - if (flds[0].equals("period")) { // In seconds - convert to ticks - playback_period = (int) Math.round(20.0 * Double.parseDouble(flds[1])); - } else if (flds[0].equals("random-add")) { // In seconds - convert to ticks - random_playback_addition = (int) Math.round(20.0 * Double.parseDouble(flds[1])); // In ticks - } else if (flds[0].equals("start-time")) { // Start time (hour of day * 100) - convert to ticks - startTime = ((Integer.parseInt(flds[1]) * 10) + 18000) % 24000; - } else if (flds[0].equals("end-time")) { // End time (hour of day * 100) - convert to ticks - endTime = ((Integer.parseInt(flds[1]) * 10) + 18000) % 24000; - } else { - WesterosBlocks.log.warn("Invalid type attribute '" + flds[0] + "' in " + def.blockName); - } - } - } - if (INDEX != null) { - this.registerDefaultState(this.stateDefinition.any().setValue(POWERED, Boolean.valueOf(false)).setValue(INDEX, 1)); - } - else { - this.registerDefaultState(this.stateDefinition.any().setValue(POWERED, Boolean.valueOf(false))); - } - } - - @Override - public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos pos2, boolean chgflag) { - boolean flag = world.hasNeighborSignal(pos); - if (flag != state.getValue(POWERED)) { - if (flag) { - this.playNote(world, pos); - world.scheduleTick(pos, this, getNextTriggerTick(world.random)); - } - world.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(flag)), 3); - } - - } - - // Trigger block event to cause play of sound - private void playNote(Level world, BlockPos pos) { - world.blockEvent(pos, this, 0, 0); - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - - if (level.isClientSide) { - return InteractionResult.SUCCESS; - } else { // Rotate state on server side, and play new note - if (INDEX != null) { - int index = state.getValue(INDEX); - index = (index + 1) % def.soundList.size(); - state = state.setValue(INDEX, index); // Rotate sounds selection - level.setBlock(pos, state, 3); - //WesterosBlocks.log.info("WCSoundBlock.use(" + pos + ") - set to INDEX=" + index); - } - this.playNote(level, pos); - level.scheduleTick(pos, this, getNextTriggerTick(level.random)); - return InteractionResult.CONSUME; - } - } - - @Override - public boolean triggerEvent(BlockState state, Level world, BlockPos ppos, int eventID, int eventArg) { - //WesterosBlocks.log.info("WCSoundBlock.trigger(" + ppos + ")"); - int i = 0; - int sndindex = (INDEX != null) ? state.getValue(INDEX) : 0; - String soundid = def.soundList.get(sndindex); - SoundEvent event = WesterosBlocks.getRegisteredSound(soundid); - if (event != null) { - float f = (float) Math.pow(2.0D, (double) (i - 12) / 12.0D); - world.playSound((Player) null, ppos, event, SoundSource.RECORDS, 3.0F, f); - //WesterosBlocks.log.info("WCSoundBlock.trigger(" + ppos + ") - playing " + soundid); - } - return true; - } - - // Compute time for next trigger - private int getNextTriggerTick(RandomSource rnd) { - return playback_period + rnd.nextInt(random_playback_addition + 1); - } - @SuppressWarnings("deprecation") - @Override - public void onPlace(BlockState state, Level world, BlockPos pos, BlockState state2, boolean flg) { - super.onPlace(state, world, pos, state2, flg); - // Add our tick schedule, if needed - if (playback_period > 0) { - world.scheduleTick(pos, this, getNextTriggerTick(world.random)); - } - } - - @Override - public boolean isRandomlyTicking(BlockState state) { - return (playback_period >= 0); - } - - @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { - if (playback_period >= 0) { - //WesterosBlocks.log.info("WCSoundBlock.randomTick(" + pos + ")"); - // No tick? Add it (migration) - if (!world.getBlockTicks().hasScheduledTick(pos, this)) { - //WesterosBlocks.log.info("WCSoundBlock.randomTick(" + pos + ") - schuled"); - // Compute time for next trigger - world.scheduleTick(pos, this, getNextTriggerTick(world.random)); - } - } - } - - @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rnd) { - //WesterosBlocks.log.info("WCSoundBlock.tick(" + pos + ")"); - if (playback_period <= 0) { // Not periodic, so quit - //WesterosBlocks.log.info("WCSoundBlock.tick(" + pos + ") - not periodic"); - return; - } - - // Get time of day of trigger - see if we are going to trigger - long wt = (world.getDayTime() % 24000); - if (wt < 0) - wt += 24000; - //WesterosBlocks.log.info("WCSoundBlock.tick(" + pos + ") - consider sound at wt=" + wt + ",startTime=" + startTime + ",endTime=" + endTime); - - boolean trigger = true; - if (this.startTime == this.endTime) { // No limit? - - } - else if (this.startTime > this.endTime) { // Split across 0 (e.g. nighttime) - trigger = ((wt < this.endTime) || (wt >= this.startTime));// And between end and start - } - else { - trigger = ((wt >= this.startTime) && (wt < this.endTime)); - } - if (trigger) { - //WesterosBlocks.log.info("WCSoundBlock.tick(" + pos + ") - trigger sound"); - playNote(world, pos); - } - // Compute time for next trigger - world.scheduleTick(pos, this, getNextTriggerTick(world.random)); - } - - protected void createBlockStateDefinition(StateDefinition.Builder container) { - if (protoINDEX != null) { - INDEX = protoINDEX; - protoINDEX = null; - } - // Only use index for blocks with multiple sounds in list - if (INDEX != null) { - container.add(POWERED, INDEX); - } - else { - container.add(POWERED); - } - } - private static String[] TAGS = { }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCStairBlock.java b/needsported/blocks/WCStairBlock.java deleted file mode 100644 index 9ac6154cb8..0000000000 --- a/needsported/blocks/WCStairBlock.java +++ /dev/null @@ -1,379 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.stream.IntStream; - -import com.westeroscraft.westerosblocks.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.StateHolder; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.Half; -import net.minecraft.world.level.block.state.properties.StairsShape; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionHand; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCStairBlock extends Block implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - // Process types - String t = def.getType(); - boolean doUnconnect = false; - boolean doConnectstate = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - // See if we have unconnect - if (parts[0].equals("unconnect")) { - doUnconnect = true; - tempUNCONNECT = UNCONNECT; - } - // See if we have connectstate - if (parts[0].equals("connectstate")) { - doConnectstate = true; - tempCONNECTSTATE = CONNECTSTATE; - } - } - } - - Block blk = new WCStairBlock(props, def, doUnconnect, doConnectstate); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - public static final EnumProperty HALF = BlockStateProperties.HALF; - public static final EnumProperty SHAPE = BlockStateProperties.STAIRS_SHAPE; - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - protected static final VoxelShape BOTTOM_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); - protected static final VoxelShape TOP_AABB = Block.box(0.0, 8.0, 0.0, 16.0, 16.0, 16.0); - protected static final VoxelShape OCTET_NNN = Block.box(0.0, 0.0, 0.0, 8.0, 8.0, 8.0); - protected static final VoxelShape OCTET_NNP = Block.box(0.0, 0.0, 8.0, 8.0, 8.0, 16.0); - protected static final VoxelShape OCTET_NPN = Block.box(0.0, 8.0, 0.0, 8.0, 16.0, 8.0); - protected static final VoxelShape OCTET_NPP = Block.box(0.0, 8.0, 8.0, 8.0, 16.0, 16.0); - protected static final VoxelShape OCTET_PNN = Block.box(8.0, 0.0, 0.0, 16.0, 8.0, 8.0); - protected static final VoxelShape OCTET_PNP = Block.box(8.0, 0.0, 8.0, 16.0, 8.0, 16.0); - protected static final VoxelShape OCTET_PPN = Block.box(8.0, 8.0, 0.0, 16.0, 16.0, 8.0); - protected static final VoxelShape OCTET_PPP = Block.box(8.0, 8.0, 8.0, 16.0, 16.0, 16.0); - - private WesterosBlockDef def; - public static final BooleanProperty UNCONNECT = BooleanProperty.create("unconnect"); - protected static BooleanProperty tempUNCONNECT; - public final boolean unconnect; - - public static final IntegerProperty CONNECTSTATE = IntegerProperty.create("connectstate", 0, 3); - protected static IntegerProperty tempCONNECTSTATE; - public final boolean connectstate; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - - protected boolean toggleOnUse = false; - - public final boolean no_uvlock; - - protected static final VoxelShape[] TOP_SHAPES = makeShapes(TOP_AABB, OCTET_NNN, OCTET_PNN, OCTET_NNP, OCTET_PNP); - protected static final VoxelShape[] BOTTOM_SHAPES = makeShapes(BOTTOM_AABB, OCTET_NPN, OCTET_PPN, OCTET_NPP, OCTET_PPP); - private static final int[] SHAPE_BY_STATE = new int[]{12, 5, 3, 10, 14, 13, 7, 11, 13, 7, 11, 14, 8, 4, 1, 2, 4, 1, 2, 8}; - - protected WCStairBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doUnconnect, boolean doConnectstate) { - super(props); - this.def = def; - - String t = def.getType(); - boolean no_uvlock = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("no-uvlock")) { - no_uvlock = true; - } - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - - this.no_uvlock = no_uvlock; - this.unconnect = doUnconnect; - this.connectstate = doConnectstate; - BlockState defbs = this.stateDefinition.any() - .setValue(FACING, Direction.NORTH) - .setValue(HALF, Half.BOTTOM) - .setValue(SHAPE, StairsShape.STRAIGHT) - .setValue(WATERLOGGED, Boolean.valueOf(false)); - if (unconnect) { - defbs = defbs.setValue(UNCONNECT, Boolean.valueOf(false)); - } - if (connectstate) { - defbs = defbs.setValue(CONNECTSTATE, 0); - } - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - } - - protected WCStairBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doUnconnect) { - this(props, def, doUnconnect, false); - } - - protected WCStairBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - this(props, def, false, false); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public boolean useShapeForLightOcclusion(BlockState blockState) { - return true; - } - - @Override - public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { - return (blockState.getValue(HALF) == Half.TOP ? TOP_SHAPES : BOTTOM_SHAPES)[SHAPE_BY_STATE[this.getShapeIndex(blockState)]]; - } - - private int getShapeIndex(BlockState blockState) { - return blockState.getValue(SHAPE).ordinal() * 4 + blockState.getValue(FACING).get2DDataValue(); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder sd) { - if (tempUNCONNECT != null) { - sd.add(tempUNCONNECT); - tempUNCONNECT = null; - } - if (tempCONNECTSTATE != null) { - sd.add(tempCONNECTSTATE); - tempCONNECTSTATE = null; - } - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - sd.add(STATE); - } - sd.add(FACING, HALF, SHAPE, WATERLOGGED); - } - - @Override - public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) { - Direction direction = blockPlaceContext.getClickedFace(); - BlockPos blockPos = blockPlaceContext.getClickedPos(); - FluidState fluidState = blockPlaceContext.getLevel().getFluidState(blockPos); - BlockState blockState = (BlockState)((BlockState)((BlockState)this.defaultBlockState().setValue(FACING, blockPlaceContext.getHorizontalDirection())).setValue(HALF, direction == Direction.DOWN || direction != Direction.UP && blockPlaceContext.getClickLocation().y - (double)blockPos.getY() > 0.5 ? Half.TOP : Half.BOTTOM)).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); - return (BlockState)blockState.setValue(SHAPE, getStairsShape(blockState, blockPlaceContext.getLevel(), blockPos)); - } - - private static VoxelShape[] makeShapes(VoxelShape voxelShape, VoxelShape voxelShape2, VoxelShape voxelShape3, VoxelShape voxelShape4, VoxelShape voxelShape5) { - return (VoxelShape[])IntStream.range(0, 16).mapToObj(n -> makeStairShape(n, voxelShape, voxelShape2, voxelShape3, voxelShape4, voxelShape5)).toArray(VoxelShape[]::new); - } - - private static VoxelShape makeStairShape(int n, VoxelShape voxelShape, VoxelShape voxelShape2, VoxelShape voxelShape3, VoxelShape voxelShape4, VoxelShape voxelShape5) { - VoxelShape voxelShape6 = voxelShape; - if ((n & 1) != 0) { - voxelShape6 = Shapes.or(voxelShape6, voxelShape2); - } - if ((n & 2) != 0) { - voxelShape6 = Shapes.or(voxelShape6, voxelShape3); - } - if ((n & 4) != 0) { - voxelShape6 = Shapes.or(voxelShape6, voxelShape4); - } - if ((n & 8) != 0) { - voxelShape6 = Shapes.or(voxelShape6, voxelShape5); - } - return voxelShape6; - } - - @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState state2, LevelAccessor world, BlockPos pos, BlockPos pos2) { - if (unconnect && state.getValue(UNCONNECT)) { - if (state.getValue(WATERLOGGED).booleanValue()) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - return state; - } - if (state.getValue(WATERLOGGED).booleanValue()) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - if (direction.getAxis().isHorizontal()) { - return (BlockState)state.setValue(SHAPE, getStairsShape(state, world, pos)); - } - return super.updateShape(state, direction, state2, world, pos, pos2); - } - - private static StairsShape getStairsShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) { - Direction direction; - Object object; - Direction direction2 = blockState.getValue(FACING); - BlockState blockState2 = blockGetter.getBlockState(blockPos.relative(direction2)); - if (isStairs(blockState2) && blockState.getValue(HALF) == blockState2.getValue(HALF) && ((Direction)(object = blockState2.getValue(FACING))).getAxis() != blockState.getValue(FACING).getAxis() && canTakeShape(blockState, blockGetter, blockPos, ((Direction)object).getOpposite())) { - if (object == direction2.getCounterClockWise()) { - return StairsShape.OUTER_LEFT; - } - return StairsShape.OUTER_RIGHT; - } - object = blockGetter.getBlockState(blockPos.relative(direction2.getOpposite())); - if (isStairs((BlockState)object) && blockState.getValue(HALF) == ((StateHolder)object).getValue(HALF) && (direction = ((Direction)((StateHolder)object).getValue(FACING))).getAxis() != blockState.getValue(FACING).getAxis() && canTakeShape(blockState, blockGetter, blockPos, direction)) { - if (direction == direction2.getCounterClockWise()) { - return StairsShape.INNER_LEFT; - } - return StairsShape.INNER_RIGHT; - } - return StairsShape.STRAIGHT; - } - - private static boolean canTakeShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction direction) { - BlockState blockState2 = blockGetter.getBlockState(blockPos.relative(direction)); - return !isStairs(blockState2) || blockState2.getValue(FACING) != blockState.getValue(FACING) || blockState2.getValue(HALF) != blockState.getValue(HALF); - } - - public static boolean isStairs(BlockState blockState) { - return blockState.getBlock() instanceof WCStairBlock; - } - - @Override - public FluidState getFluidState(BlockState blockState) { - if (blockState.getValue(WATERLOGGED).booleanValue()) { - return Fluids.WATER.getSource(false); - } - return super.getFluidState(blockState); - } - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - return false; - } - - @Override - public BlockState rotate(BlockState blockState, Rotation rotation) { - return (BlockState)blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING))); - } - - @Override - public BlockState mirror(BlockState blockState, Mirror mirror) { - Direction direction = blockState.getValue(FACING); - StairsShape stairsShape = blockState.getValue(SHAPE); - switch (mirror) { - case LEFT_RIGHT: { - if (direction.getAxis() != Direction.Axis.Z) break; - switch (stairsShape) { - case INNER_LEFT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_RIGHT); - } - case INNER_RIGHT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_LEFT); - } - case OUTER_LEFT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_RIGHT); - } - case OUTER_RIGHT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_LEFT); - } - } - return blockState.rotate(Rotation.CLOCKWISE_180); - } - case FRONT_BACK: { - if (direction.getAxis() != Direction.Axis.X) break; - switch (stairsShape) { - case INNER_LEFT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_LEFT); - } - case INNER_RIGHT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_RIGHT); - } - case OUTER_LEFT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_RIGHT); - } - case OUTER_RIGHT: { - return (BlockState)blockState.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_LEFT); - } - case STRAIGHT: { - return blockState.rotate(Rotation.CLOCKWISE_180); - } - } - break; - } - } - return super.mirror(blockState, mirror); - } - - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } - else { - return InteractionResult.PASS; - } - } - - @Override - public void onPlace(BlockState blockState, Level level, BlockPos blockPos, BlockState blockState2, boolean bl) { - if (blockState.is(blockState.getBlock())) { - return; - } - super.onPlace(blockState, level, blockPos, blockState2, false); - } - - @Override - public void onRemove(BlockState blockState, Level level, BlockPos blockPos, BlockState blockState2, boolean bl) { - if (blockState.is(blockState2.getBlock())) { - return; - } - super.onRemove(blockState, level, blockPos, blockState2, bl); - } - - private static String[] TAGS = { "stairs" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCTorchBlock.java b/needsported/blocks/WCTorchBlock.java deleted file mode 100644 index 6d9876e604..0000000000 --- a/needsported/blocks/WCTorchBlock.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.core.particles.SimpleParticleType; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.TorchBlock; - -import java.util.Random; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCTorchBlock extends TorchBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties floorprops = def.makeProperties().noCollission().instabreak(); - Block floorblock = new WCTorchBlock(floorprops, def); - @SuppressWarnings("deprecation") - BlockBehaviour.Properties wallprops = def.makeProperties().noCollission().instabreak().dropsLike(floorblock); - Block wallblock = new WCWallTorchBlock(wallprops, def); -// def.registerWallOrFloorBlock(floorblock, wallblock, helper); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), floorblock); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, "wall_" + def.blockName), wallblock); - def.registerBlockItem(def.blockName, floorblock); - def.registerBlockItem("wall_" + def.blockName, wallblock); - def.registerRenderType(floorblock, false, false); - def.registerRenderType(wallblock, false, false); - return floorblock; - } - } - - private WesterosBlockDef def; - private boolean allow_unsupported = false; - private boolean no_particle = false; - - private static SimpleParticleType getParticle(String typeStr) { - if (typeStr != null && typeStr.contains("no-particle")) { - return new SimpleParticleType(false); - } - return ParticleTypes.FLAME; - } - - protected WCTorchBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(WCTorchBlock.getParticle(def.getType()), props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - else if (tok.equals("no-particle")) { - no_particle = true; - } - } - } - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rnd) { - if (!this.no_particle) super.animateTick(state, level, pos, rnd); - } - - @Override - public boolean canSurvive(BlockState p_49395_, LevelReader p_49396_, BlockPos p_49397_) { - if (this.allow_unsupported) return true; - return super.canSurvive(p_49395_, p_49396_, p_49397_); - } - - private static String[] TAGS = { "wall_post_override" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCTrapDoorBlock.java b/needsported/blocks/WCTrapDoorBlock.java deleted file mode 100644 index cef0222aff..0000000000 --- a/needsported/blocks/WCTrapDoorBlock.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.TrapDoorBlock; - -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.core.BlockPos; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCTrapDoorBlock extends TrapDoorBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - Block blk = new WCTrapDoorBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean locked = false; - - protected WCTrapDoorBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(AuxileryUtils.getBlockSetType(props, def), props); - this.def = def; - String type = def.getType(); - if (type != null) { - String[] toks = type.split(","); - for (String tok : toks) { - String [] flds = tok.split(":"); - if (flds.length < 2) continue; - if (flds[0].equals("locked")) { - locked = flds[1].equals("true"); - } - } - } - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - - if (this.locked) { - return InteractionResult.PASS; - } - else { - state = state.cycle(OPEN); - level.setBlock(pos, state, 2); - if (state.getValue(WATERLOGGED)) { - level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); - } - this.playSound(player, level, pos, state.getValue(OPEN)); - return InteractionResult.sidedSuccess(level.isClientSide); - } - } - - private static String[] TAGS = { "trapdoors" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCVinesBlock.java b/needsported/blocks/WCVinesBlock.java deleted file mode 100644 index b26e4bcc54..0000000000 --- a/needsported/blocks/WCVinesBlock.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import java.util.Map; -import java.util.Random; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.PipeBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.VineBlock; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.core.Direction; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.tags.FluidTags; - -import com.google.common.collect.ImmutableMap; -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCVinesBlock extends VineBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties().noOcclusion(); - Block blk = new WCVinesBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - - private WesterosBlockDef def; - private boolean allow_unsupported = false; - private boolean no_climb = false; - public boolean has_down = false; - public static final BooleanProperty DOWN = PipeBlock.DOWN; - private static final VoxelShape UP_AABB = Block.box(0.0D, 15.0D, 0.0D, 16.0D, 16.0D, 16.0D); - private static final VoxelShape DOWN_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); - private static final VoxelShape WEST_AABB = Block.box(0.0D, 0.0D, 0.0D, 1.0D, 16.0D, 16.0D); - private static final VoxelShape EAST_AABB = Block.box(15.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); - private static final VoxelShape NORTH_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 1.0D); - private static final VoxelShape SOUTH_AABB = Block.box(0.0D, 0.0D, 15.0D, 16.0D, 16.0D, 16.0D); - private final Map shapesCache; - - public static final Map PROPERTY_BY_DIRECTION = PipeBlock.PROPERTY_BY_DIRECTION.entrySet().stream().collect(Util.toMap()); - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - protected WCVinesBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - if (tok.equals("no-climb")) { - no_climb = true; - } - if (tok.equals("has-down")) { - has_down = true; - } - } - } - this.shapesCache = ImmutableMap.copyOf(this.stateDefinition.getPossibleStates().stream().collect(Collectors.toMap(Function.identity(), WCVinesBlock::calculateShape))); - this.registerDefaultState(this.stateDefinition.any().setValue(UP, Boolean.valueOf(false)).setValue(NORTH, Boolean.valueOf(false)).setValue(EAST, Boolean.valueOf(false)) - .setValue(SOUTH, Boolean.valueOf(false)).setValue(WEST, Boolean.valueOf(false)) - .setValue(DOWN, Boolean.valueOf(false)).setValue(WATERLOGGED, Boolean.valueOf(false))); - } - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - private static VoxelShape calculateShape(BlockState p_242685_0_) { - VoxelShape voxelshape = Shapes.empty(); - if (p_242685_0_.getValue(UP)) { - voxelshape = UP_AABB; - } - if (p_242685_0_.getValue(DOWN)) { - voxelshape = Shapes.or(voxelshape, DOWN_AABB); - } - - if (p_242685_0_.getValue(NORTH)) { - voxelshape = Shapes.or(voxelshape, NORTH_AABB); - } - - if (p_242685_0_.getValue(SOUTH)) { - voxelshape = Shapes.or(voxelshape, SOUTH_AABB); - } - - if (p_242685_0_.getValue(EAST)) { - voxelshape = Shapes.or(voxelshape, EAST_AABB); - } - - if (p_242685_0_.getValue(WEST)) { - voxelshape = Shapes.or(voxelshape, WEST_AABB); - } - return voxelshape; - } - - - @Override - public VoxelShape getShape(BlockState p_220053_1_, BlockGetter p_220053_2_, BlockPos p_220053_3_, CollisionContext p_220053_4_) { - return this.shapesCache.get(p_220053_1_); - } - @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { - return Shapes.empty(); - } - - @Override - public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) { - - return allow_unsupported || this.hasFaces(this.getUpdatedState(p_196260_1_, p_196260_2_, p_196260_3_)); - } - - private boolean hasFaces(BlockState p_196543_1_) { - return this.countFaces(p_196543_1_) > 0; - } - - private int countFaces(BlockState p_208496_1_) { - int i = 0; - - for(BooleanProperty booleanproperty : PROPERTY_BY_DIRECTION.values()) { - if (p_208496_1_.getValue(booleanproperty)) { - ++i; - } - } - - return i; - } - - private boolean canSupportAtFace(BlockGetter p_196541_1_, BlockPos p_196541_2_, Direction p_196541_3_) { - if ((!has_down) && (p_196541_3_ == Direction.DOWN)) { - return false; - } else { - BlockPos blockpos = p_196541_2_.relative(p_196541_3_); - if (allow_unsupported ) { - return true; - } - if (isAcceptableNeighbour(p_196541_1_, blockpos, p_196541_3_)) { - return true; - } else if (p_196541_3_.getAxis() == Direction.Axis.Y) { - return false; - } else { - BooleanProperty booleanproperty = PROPERTY_BY_DIRECTION.get(p_196541_3_); - BlockState blockstate = p_196541_1_.getBlockState(p_196541_2_.above()); - return blockstate.is(this) && blockstate.getValue(booleanproperty); - } - } - } - - public static boolean isAcceptableNeighbour(BlockGetter p_196542_0_, BlockPos p_196542_1_, Direction p_196542_2_) { - BlockState blockstate = p_196542_0_.getBlockState(p_196542_1_); - return Block.isFaceFull(blockstate.getCollisionShape(p_196542_0_, p_196542_1_), p_196542_2_.getOpposite()); - } - - private BlockState getUpdatedState(BlockState p_196545_1_, BlockGetter p_196545_2_, BlockPos p_196545_3_) { - BlockPos blockpos = p_196545_3_.above(); - if (p_196545_1_.getValue(UP)) { - p_196545_1_ = p_196545_1_.setValue(UP, Boolean.valueOf(allow_unsupported || isAcceptableNeighbour(p_196545_2_, blockpos, Direction.DOWN))); - } - - BlockState blockstate = null; - - for(Direction direction : Direction.Plane.HORIZONTAL) { - BooleanProperty booleanproperty = getPropertyForFace(direction); - if (p_196545_1_.getValue(booleanproperty)) { - boolean flag = allow_unsupported || this.canSupportAtFace(p_196545_2_, p_196545_3_, direction); - if (!flag) { - if (blockstate == null) { - blockstate = p_196545_2_.getBlockState(blockpos); - } - - flag = blockstate.is(this) && blockstate.getValue(booleanproperty); - } - - p_196545_1_ = p_196545_1_.setValue(booleanproperty, Boolean.valueOf(flag)); - } - } - - return p_196545_1_; - } - - @Override - public BlockState updateShape(BlockState p_196271_1_, Direction p_196271_2_, BlockState p_196271_3_, LevelAccessor p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) { - if ((!has_down) && (p_196271_2_ == Direction.DOWN)) { - return super.updateShape(p_196271_1_, p_196271_2_, p_196271_3_, p_196271_4_, p_196271_5_, p_196271_6_); - } else { - BlockState blockstate = this.getUpdatedState(p_196271_1_, p_196271_4_, p_196271_5_); - return !this.hasFaces(blockstate) ? Blocks.AIR.defaultBlockState() : blockstate; - } - } - - @Nullable - @Override - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState blockstate = ctx.getLevel().getBlockState(ctx.getClickedPos()); - boolean flag = blockstate.is(this); - BlockState blockstate1 = flag ? blockstate : this.defaultBlockState(); - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - blockstate1 = blockstate1.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - - for(Direction direction : ctx.getNearestLookingDirections()) { - if (has_down || (direction != Direction.DOWN)) { - BooleanProperty booleanproperty = getPropertyForFace(direction); - boolean flag1 = flag && blockstate.getValue(booleanproperty); - if (!flag1 && this.canSupportAtFace(ctx.getLevel(), ctx.getClickedPos(), direction)) { - return blockstate1.setValue(booleanproperty, Boolean.valueOf(true)); - } - } - } - return flag ? blockstate1 : null; - } - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - - - @Override - public boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch(pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - public void randomTick(BlockState p_225542_1_, ServerLevel p_225542_2_, BlockPos p_225542_3_, RandomSource p_225542_4_) { - } - @Override - protected void createBlockStateDefinition(StateDefinition.Builder container) { - container.add(UP, NORTH, EAST, SOUTH, WEST, DOWN, WATERLOGGED); - } - - public static BooleanProperty getPropertyForFace(Direction p_176267_0_) { - return PROPERTY_BY_DIRECTION.get(p_176267_0_); - } - - private static String[] TAGS = { "climbable" }; - private static String[] TAGS_NOCLIMB = { }; - @Override - public String[] getBlockTags() { - if (no_climb) return TAGS_NOCLIMB; - return TAGS; - } -} diff --git a/needsported/blocks/WCWallBlock.java b/needsported/blocks/WCWallBlock.java deleted file mode 100644 index 479f2dc24b..0000000000 --- a/needsported/blocks/WCWallBlock.java +++ /dev/null @@ -1,510 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.WallBlock; - -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.level.block.IronBarsBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.block.state.properties.Property; -import net.minecraft.world.level.block.state.properties.WallSide; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.phys.shapes.BooleanOp; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.Level; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.tags.BlockTags; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -public class WCWallBlock extends Block implements SimpleWaterloggedBlock, WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - BlockBehaviour.Properties props = def.makeProperties(); - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - // Process types - String t = def.getType(); - boolean doUnconnect = false; - boolean doConnectstate = false; - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - String[] parts = tok.split(":"); - // See if we have unconnect - if (parts[0].equals("unconnect")) { - doUnconnect = true; - tempUNCONNECT = UNCONNECT; - } - // See if we have connectstate - if (parts[0].equals("connectstate")) { - doConnectstate = true; - tempCONNECTSTATE = CONNECTSTATE; - } - } - } - - Block blk = new WCWallBlock(props, def, doUnconnect, doConnectstate); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - - return def.registerRenderType(blk, false, false); - } - } - - public static final BooleanProperty UP = BlockStateProperties.UP; - public static final EnumProperty EAST_WALL = BlockStateProperties.EAST_WALL; - public static final EnumProperty NORTH_WALL = BlockStateProperties.NORTH_WALL; - public static final EnumProperty SOUTH_WALL = BlockStateProperties.SOUTH_WALL; - public static final EnumProperty WEST_WALL = BlockStateProperties.WEST_WALL; - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - private static final VoxelShape POST_TEST = Block.box(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D); - private static final VoxelShape NORTH_TEST = Block.box(7.0D, 0.0D, 0.0D, 9.0D, 16.0D, 9.0D); - private static final VoxelShape SOUTH_TEST = Block.box(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 16.0D); - private static final VoxelShape WEST_TEST = Block.box(0.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D); - private static final VoxelShape EAST_TEST = Block.box(7.0D, 0.0D, 7.0D, 16.0D, 16.0D, 9.0D); - - private WesterosBlockDef def; - public static final BooleanProperty UNCONNECT = BooleanProperty.create("unconnect"); - protected static BooleanProperty tempUNCONNECT; - public final boolean unconnect; - - public static final IntegerProperty CONNECTSTATE = IntegerProperty.create("connectstate", 0, 3); - protected static IntegerProperty tempCONNECTSTATE; - public final boolean connectstate; - - protected static WesterosBlockDef.StateProperty tempSTATE; - protected WesterosBlockDef.StateProperty STATE; - - protected boolean toggleOnUse = false; - - public final VoxelShape[] ourShapeByIndex; - public final VoxelShape[] ourCollisionShapeByIndex; - - private static VoxelShape[] ourCollisionShapeByIndexShared = null; - private static VoxelShape[] ourShapeByIndexSharedShort = null; - private static VoxelShape[] ourShapeByIndexSharedNormal = null; - - public static enum WallSize { - NORMAL, // 16/16 high wall - SHORT // 13/16 high wall - } - - ; - - public final WallSize wallSize; // "normal", or "short" - - protected WCWallBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doUnconnect, boolean doConnectstate) { - super(props); - this.def = def; - - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - - String height = def.getTypeValue("size", "normal"); - float wheight; - if (height.equals("short")) { - wallSize = WallSize.SHORT; - wheight = 13; - } else { - wallSize = WallSize.NORMAL; - wheight = 16; - } - unconnect = doUnconnect; - connectstate = doConnectstate; - BlockState defbs = this.stateDefinition.any() - .setValue(UP, Boolean.valueOf(true)) - .setValue(NORTH_WALL, WallSide.NONE) - .setValue(EAST_WALL, WallSide.NONE) - .setValue(SOUTH_WALL, WallSide.NONE) - .setValue(WEST_WALL, WallSide.NONE) - .setValue(WATERLOGGED, Boolean.valueOf(false)); - if (unconnect) { - defbs = defbs.setValue(UNCONNECT, Boolean.valueOf(false)); - } - if (connectstate) { - defbs = defbs.setValue(CONNECTSTATE, 0); - } - if (STATE != null) { - defbs = defbs.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(defbs); - - if (ourCollisionShapeByIndexShared == null) { - ourCollisionShapeByIndexShared = makeShapes(4.0F, 3.0F, 24.0F, 0.0F, 24.0F, 24.0F); - } - this.ourCollisionShapeByIndex = ourCollisionShapeByIndexShared; - if (height.equals("short")) { - if (ourShapeByIndexSharedShort == null) { - ourShapeByIndexSharedShort = makeShapes(4.0F, 3.0F, 16.0F, 0.0F, wheight, 16.0F); - } - this.ourShapeByIndex = ourShapeByIndexSharedShort; - } else { - if (ourShapeByIndexSharedNormal == null) { - ourShapeByIndexSharedNormal = makeShapes(4.0F, 3.0F, 16.0F, 0.0F, wheight, 16.0F); - } - this.ourShapeByIndex = ourShapeByIndexSharedNormal; - } - } - - protected WCWallBlock(BlockBehaviour.Properties props, WesterosBlockDef def, boolean doUnconnect) { - this(props, def, doUnconnect, false); - } - - protected WCWallBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - this(props, def, false, false); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter p_58051_, BlockPos p_58052_, CollisionContext p_58053_) { - return this.ourShapeByIndex[getStateIndex(state)]; - } - - @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter p_58056_, BlockPos p_58057_, - CollisionContext p_58058_) { - return this.ourCollisionShapeByIndex[getStateIndex(state)]; - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder sd) { - if (tempUNCONNECT != null) { - sd.add(tempUNCONNECT); - tempUNCONNECT = null; - } - if (tempCONNECTSTATE != null) { - sd.add(tempCONNECTSTATE); - tempCONNECTSTATE = null; - } - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (STATE != null) { - sd.add(STATE); - } - sd.add(UP, NORTH_WALL, EAST_WALL, WEST_WALL, SOUTH_WALL, WATERLOGGED); - } - - private static VoxelShape applyWallShape(VoxelShape p_58034_, WallSide p_58035_, VoxelShape p_58036_, - VoxelShape p_58037_) { - if (p_58035_ == WallSide.TALL) { - return Shapes.or(p_58034_, p_58037_); - } else { - return p_58035_ == WallSide.LOW ? Shapes.or(p_58034_, p_58036_) : p_58034_; - } - } - - private static int getStateIndex(BlockState bs) { - return getStateIndex(bs.getValue(UP).booleanValue(), bs.getValue(EAST_WALL).ordinal(), - bs.getValue(WEST_WALL).ordinal(), bs.getValue(NORTH_WALL).ordinal(), bs.getValue(SOUTH_WALL).ordinal()); - } - - private static int getStateIndex(boolean up, int east, int west, int north, int south) { - return (up ? 1 : 0) + (east * 2) + (west * 6) + (north * 18) + (south * 54); - } - - private static VoxelShape[] makeShapes(float p_57966_, float p_57967_, float p_57968_, float p_57969_, - float p_57970_, float p_57971_) { - float f = 8.0F - p_57966_; - float f1 = 8.0F + p_57966_; - float f2 = 8.0F - p_57967_; - float f3 = 8.0F + p_57967_; - VoxelShape voxelshape = Block.box((double) f, 0.0D, (double) f, (double) f1, (double) p_57968_, (double) f1); - VoxelShape voxelshape1 = Block.box((double) f2, (double) p_57969_, 0.0D, (double) f3, (double) p_57970_, - (double) f3); - VoxelShape voxelshape2 = Block.box((double) f2, (double) p_57969_, (double) f2, (double) f3, (double) p_57970_, - 16.0D); - VoxelShape voxelshape3 = Block.box(0.0D, (double) p_57969_, (double) f2, (double) f3, (double) p_57970_, - (double) f3); - VoxelShape voxelshape4 = Block.box((double) f2, (double) p_57969_, (double) f2, 16.0D, (double) p_57970_, - (double) f3); - VoxelShape voxelshape5 = Block.box((double) f2, (double) p_57969_, 0.0D, (double) f3, (double) p_57971_, - (double) f3); - VoxelShape voxelshape6 = Block.box((double) f2, (double) p_57969_, (double) f2, (double) f3, (double) p_57971_, - 16.0D); - VoxelShape voxelshape7 = Block.box(0.0D, (double) p_57969_, (double) f2, (double) f3, (double) p_57971_, - (double) f3); - VoxelShape voxelshape8 = Block.box((double) f2, (double) p_57969_, (double) f2, 16.0D, (double) p_57971_, - (double) f3); - VoxelShape[] map = new VoxelShape[2 * 3 * 3 * 3 * 3]; - - for (Boolean up : UP.getPossibleValues()) { - for (WallSide east : EAST_WALL.getPossibleValues()) { - for (WallSide north : NORTH_WALL.getPossibleValues()) { - for (WallSide west : WEST_WALL.getPossibleValues()) { - for (WallSide south : SOUTH_WALL.getPossibleValues()) { - VoxelShape shape = Shapes.empty(); - shape = applyWallShape(shape, east, voxelshape4, voxelshape8); - shape = applyWallShape(shape, west, voxelshape3, voxelshape7); - shape = applyWallShape(shape, north, voxelshape1, voxelshape5); - shape = applyWallShape(shape, south, voxelshape2, voxelshape6); - if (up) { - shape = Shapes.or(shape, voxelshape); - } - map[getStateIndex(up.booleanValue(), east.ordinal(), west.ordinal(), - north.ordinal(), south.ordinal())] = shape; - } - } - } - } - } - return map; - } - - @Override - protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - return false; - } - - private boolean connectsTo(BlockState p_58021_, boolean p_58022_, Direction p_58023_) { - Block block = p_58021_.getBlock(); - boolean flag = block instanceof FenceGateBlock && FenceGateBlock.connectsToDirection(p_58021_, p_58023_); - return p_58021_.is(BlockTags.WALLS) || !isExceptionForConnection(p_58021_) && p_58022_ - || block instanceof IronBarsBlock || flag; - } - - @Override - public BlockState getStateForPlacement(BlockPlaceContext p_57973_) { - LevelReader levelreader = p_57973_.getLevel(); - BlockPos blockpos = p_57973_.getClickedPos(); - FluidState fluidstate = p_57973_.getLevel().getFluidState(p_57973_.getClickedPos()); - BlockPos blockpos1 = blockpos.north(); - BlockPos blockpos2 = blockpos.east(); - BlockPos blockpos3 = blockpos.south(); - BlockPos blockpos4 = blockpos.west(); - BlockPos blockpos5 = blockpos.above(); - BlockState blockstate = levelreader.getBlockState(blockpos1); - BlockState blockstate1 = levelreader.getBlockState(blockpos2); - BlockState blockstate2 = levelreader.getBlockState(blockpos3); - BlockState blockstate3 = levelreader.getBlockState(blockpos4); - BlockState blockstate4 = levelreader.getBlockState(blockpos5); - boolean flag = this.connectsTo(blockstate, blockstate.isFaceSturdy(levelreader, blockpos1, Direction.SOUTH), - Direction.SOUTH); - boolean flag1 = this.connectsTo(blockstate1, blockstate1.isFaceSturdy(levelreader, blockpos2, Direction.WEST), - Direction.WEST); - boolean flag2 = this.connectsTo(blockstate2, blockstate2.isFaceSturdy(levelreader, blockpos3, Direction.NORTH), - Direction.NORTH); - boolean flag3 = this.connectsTo(blockstate3, blockstate3.isFaceSturdy(levelreader, blockpos4, Direction.EAST), - Direction.EAST); - BlockState blockstate5 = this.defaultBlockState().setValue(WATERLOGGED, - Boolean.valueOf(fluidstate.getType() == Fluids.WATER)); - return this.updateShape(levelreader, blockstate5, blockpos5, blockstate4, flag, flag1, flag2, flag3); - } - - @Override - public BlockState updateShape(BlockState state, Direction dir, BlockState state2, LevelAccessor world, BlockPos pos, - BlockPos pos2) { - if (state.getValue(WATERLOGGED)) { - world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); - } - if (unconnect && state.getValue(UNCONNECT)) { - return state; - } - if (dir == Direction.DOWN) { - return super.updateShape(state, dir, state2, world, pos, pos2); - } else { - return dir == Direction.UP ? this.topUpdate(world, state, pos2, state2) - : this.sideUpdate(world, pos, state, pos2, state2, dir); - } - } - - private static boolean isConnected(BlockState p_58011_, Property p_58012_) { - return p_58011_.getValue(p_58012_) != WallSide.NONE; - } - - private static boolean isCovered(VoxelShape p_58039_, VoxelShape p_58040_) { - return !Shapes.joinIsNotEmpty(p_58040_, p_58039_, BooleanOp.ONLY_FIRST); - } - - private BlockState topUpdate(LevelReader p_57975_, BlockState p_57976_, BlockPos p_57977_, BlockState p_57978_) { - boolean flag = isConnected(p_57976_, NORTH_WALL); - boolean flag1 = isConnected(p_57976_, EAST_WALL); - boolean flag2 = isConnected(p_57976_, SOUTH_WALL); - boolean flag3 = isConnected(p_57976_, WEST_WALL); - return this.updateShape(p_57975_, p_57976_, p_57977_, p_57978_, flag, flag1, flag2, flag3); - } - - private BlockState sideUpdate(LevelReader p_57989_, BlockPos p_57990_, BlockState p_57991_, BlockPos p_57992_, - BlockState p_57993_, Direction p_57994_) { - Direction direction = p_57994_.getOpposite(); - boolean flag = p_57994_ == Direction.NORTH - ? this.connectsTo(p_57993_, p_57993_.isFaceSturdy(p_57989_, p_57992_, direction), direction) - : isConnected(p_57991_, NORTH_WALL); - boolean flag1 = p_57994_ == Direction.EAST - ? this.connectsTo(p_57993_, p_57993_.isFaceSturdy(p_57989_, p_57992_, direction), direction) - : isConnected(p_57991_, EAST_WALL); - boolean flag2 = p_57994_ == Direction.SOUTH - ? this.connectsTo(p_57993_, p_57993_.isFaceSturdy(p_57989_, p_57992_, direction), direction) - : isConnected(p_57991_, SOUTH_WALL); - boolean flag3 = p_57994_ == Direction.WEST - ? this.connectsTo(p_57993_, p_57993_.isFaceSturdy(p_57989_, p_57992_, direction), direction) - : isConnected(p_57991_, WEST_WALL); - BlockPos blockpos = p_57990_.above(); - BlockState blockstate = p_57989_.getBlockState(blockpos); - return this.updateShape(p_57989_, p_57991_, blockpos, blockstate, flag, flag1, flag2, flag3); - } - - private BlockState updateShape(LevelReader p_57980_, BlockState p_57981_, BlockPos p_57982_, BlockState p_57983_, - boolean p_57984_, boolean p_57985_, boolean p_57986_, boolean p_57987_) { - VoxelShape voxelshape = p_57983_.getCollisionShape(p_57980_, p_57982_).getFaceShape(Direction.DOWN); - BlockState blockstate = this.updateSides(p_57981_, p_57984_, p_57985_, p_57986_, p_57987_, voxelshape); - return blockstate.setValue(UP, Boolean.valueOf(this.shouldRaisePost(blockstate, p_57983_, voxelshape))); - } - - private boolean shouldRaisePost(BlockState p_58007_, BlockState p_58008_, VoxelShape p_58009_) { - boolean flag = p_58008_.getBlock() instanceof WallBlock && p_58008_.getValue(UP); - if (flag) { - return true; - } else { - WallSide wallside = p_58007_.getValue(NORTH_WALL); - WallSide wallside1 = p_58007_.getValue(SOUTH_WALL); - WallSide wallside2 = p_58007_.getValue(EAST_WALL); - WallSide wallside3 = p_58007_.getValue(WEST_WALL); - boolean flag1 = wallside1 == WallSide.NONE; - boolean flag2 = wallside3 == WallSide.NONE; - boolean flag3 = wallside2 == WallSide.NONE; - boolean flag4 = wallside == WallSide.NONE; - boolean flag5 = flag4 && flag1 && flag2 && flag3 || flag4 != flag1 || flag2 != flag3; - if (flag5) { - return true; - } else { - boolean flag6 = wallside == WallSide.TALL && wallside1 == WallSide.TALL - || wallside2 == WallSide.TALL && wallside3 == WallSide.TALL; - if (flag6) { - return false; - } else { - return p_58008_.is(BlockTags.WALL_POST_OVERRIDE) || isCovered(p_58009_, POST_TEST); - } - } - } - } - - private BlockState updateSides(BlockState p_58025_, boolean p_58026_, boolean p_58027_, boolean p_58028_, - boolean p_58029_, VoxelShape p_58030_) { - return p_58025_.setValue(NORTH_WALL, this.makeWallState(p_58026_, p_58030_, NORTH_TEST)) - .setValue(EAST_WALL, this.makeWallState(p_58027_, p_58030_, EAST_TEST)) - .setValue(SOUTH_WALL, this.makeWallState(p_58028_, p_58030_, SOUTH_TEST)) - .setValue(WEST_WALL, this.makeWallState(p_58029_, p_58030_, WEST_TEST)); - } - - private WallSide makeWallState(boolean p_58042_, VoxelShape p_58043_, VoxelShape p_58044_) { - if (p_58042_) { - return isCovered(p_58043_, p_58044_) ? WallSide.TALL : WallSide.LOW; - } else { - return WallSide.NONE; - } - } - - @Override - public FluidState getFluidState(BlockState p_58060_) { - return p_58060_.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(p_58060_); - } - - @Override - public boolean propagatesSkylightDown(BlockState p_58046_, BlockGetter p_58047_, BlockPos p_58048_) { - return !p_58046_.getValue(WATERLOGGED); - } - - @Override - public BlockState rotate(BlockState p_58004_, Rotation p_58005_) { - switch (p_58005_) { - case CLOCKWISE_180: - return p_58004_.setValue(NORTH_WALL, p_58004_.getValue(SOUTH_WALL)) - .setValue(EAST_WALL, p_58004_.getValue(WEST_WALL)) - .setValue(SOUTH_WALL, p_58004_.getValue(NORTH_WALL)) - .setValue(WEST_WALL, p_58004_.getValue(EAST_WALL)); - case COUNTERCLOCKWISE_90: - return p_58004_.setValue(NORTH_WALL, p_58004_.getValue(EAST_WALL)) - .setValue(EAST_WALL, p_58004_.getValue(SOUTH_WALL)) - .setValue(SOUTH_WALL, p_58004_.getValue(WEST_WALL)) - .setValue(WEST_WALL, p_58004_.getValue(NORTH_WALL)); - case CLOCKWISE_90: - return p_58004_.setValue(NORTH_WALL, p_58004_.getValue(WEST_WALL)) - .setValue(EAST_WALL, p_58004_.getValue(NORTH_WALL)) - .setValue(SOUTH_WALL, p_58004_.getValue(EAST_WALL)) - .setValue(WEST_WALL, p_58004_.getValue(SOUTH_WALL)); - default: - return p_58004_; - } - } - - @Override - public BlockState mirror(BlockState p_58001_, Mirror p_58002_) { - switch (p_58002_) { - case LEFT_RIGHT: - return p_58001_.setValue(NORTH_WALL, p_58001_.getValue(SOUTH_WALL)).setValue(SOUTH_WALL, - p_58001_.getValue(NORTH_WALL)); - case FRONT_BACK: - return p_58001_.setValue(EAST_WALL, p_58001_.getValue(WEST_WALL)).setValue(WEST_WALL, - p_58001_.getValue(EAST_WALL)); - default: - return super.mirror(p_58001_, p_58002_); - } - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } else { - return InteractionResult.PASS; - } - } - - private static String[] TAGS = {"walls"}; - - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCWallFanBlock.java b/needsported/blocks/WCWallFanBlock.java deleted file mode 100644 index da8050130d..0000000000 --- a/needsported/blocks/WCWallFanBlock.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import java.util.Map; - -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraft.world.level.block.SimpleWaterloggedBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.tags.FluidTags; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.Mirror; -import net.minecraft.world.level.block.Rotation; - -import javax.annotation.Nullable; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; - -public class WCWallFanBlock extends Block implements SimpleWaterloggedBlock, WesterosBlockLifecycle { - - public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - private WesterosBlockDef def; - private boolean allow_unsupported = false; - - private static final Map SHAPES = Maps.newEnumMap((Map)ImmutableMap.of((Object)Direction.NORTH, (Object)Block.box(0.0, 4.0, 5.0, 16.0, 12.0, 16.0), (Object)Direction.SOUTH, (Object)Block.box(0.0, 4.0, 0.0, 16.0, 12.0, 11.0), (Object)Direction.WEST, (Object)Block.box(5.0, 4.0, 0.0, 16.0, 12.0, 16.0), (Object)Direction.EAST, (Object)Block.box(0.0, 4.0, 0.0, 11.0, 12.0, 16.0))); - - protected WCWallFanBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - } - } - BlockState defbs = this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false)); - this.registerDefaultState(defbs); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - // Get waterlogging state - BlockState bs = super.getStateForPlacement(ctx); - if (bs == null) return null; - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - bs = bs.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - // Get direction state - Direction[] directionArray; - Level level = ctx.getLevel(); - BlockPos blockPos = ctx.getClickedPos(); - for (Direction direction : directionArray = ctx.getNearestLookingDirections()) { - if (!direction.getAxis().isHorizontal() || !(bs = (BlockState)bs.setValue(FACING, direction.getOpposite())).canSurvive(level, blockPos)) continue; - return bs; - } - return null; - } - - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - - @Override - public boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch(pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { - stateDefinition.add(FACING, WATERLOGGED); - } - - @Override - public BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) { - if (direction.getOpposite() == blockState.getValue(FACING) && !blockState.canSurvive(levelAccessor, blockPos)) { - return Blocks.AIR.defaultBlockState(); - } - return blockState; - } - - @Override - public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) { - if (this.allow_unsupported) return true; - Direction direction = blockState.getValue(FACING); - BlockPos blockPos2 = blockPos.relative(direction.getOpposite()); - BlockState blockState2 = levelReader.getBlockState(blockPos2); - return blockState2.isFaceSturdy(levelReader, blockPos2, direction); - } - - @Override - public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { - return state.getFluidState().isEmpty(); - } - - @Override - public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) { - return SHAPES.get(state.getValue(FACING)); - } - - @Override - public BlockState rotate(BlockState blockState, Rotation rotation) { - return (BlockState)blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING))); - } - - @Override - public BlockState mirror(BlockState blockState, Mirror mirror) { - return blockState.rotate(mirror.getRotation(blockState.getValue(FACING))); - } - - private static String[] TAGS = { "fans" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCWallTorchBlock.java b/needsported/blocks/WCWallTorchBlock.java deleted file mode 100644 index 31deea93fc..0000000000 --- a/needsported/blocks/WCWallTorchBlock.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.core.particles.SimpleParticleType; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.WallTorchBlock; -import net.minecraft.world.level.Level; - -import java.util.Random; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; - -public class WCWallTorchBlock extends WallTorchBlock implements WesterosBlockLifecycle { - private WesterosBlockDef def; - private boolean allow_unsupported = false; - private boolean no_particle = false; - - private static SimpleParticleType getParticle(String typeStr) { - if (typeStr != null && typeStr.contains("no-particle")) { - return new SimpleParticleType(false); - } - return ParticleTypes.FLAME; - } - - protected WCWallTorchBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(WCWallTorchBlock.getParticle(def.getType()), props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("allow-unsupported")) { - allow_unsupported = true; - } - else if (tok.equals("no-particle")) { - no_particle = true; - } - } - } - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rnd) { - if (!this.no_particle) super.animateTick(state, level, pos, rnd); - } - - @Override - public boolean canSurvive(BlockState p_49395_, LevelReader p_49396_, BlockPos p_49397_) { - if (this.allow_unsupported) return true; - return super.canSurvive(p_49395_, p_49396_, p_49397_); - } - - private static String[] TAGS = { "wall_post_override" }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/blocks/WCWebBlock.java b/needsported/blocks/WCWebBlock.java deleted file mode 100644 index 223b803c1a..0000000000 --- a/needsported/blocks/WCWebBlock.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.westerosblocks.needsported.blocks; - -import com.westeroscraft.westerosblocks.WesterosBlocks; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.WebBlock; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SlabBlock; -import net.minecraft.world.level.block.SnowLayerBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.tags.FluidTags; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockFactory; -import net.neoforged.neoforge.registries.RegisterEvent; - -import javax.annotation.Nullable; - -public class WCWebBlock extends WebBlock implements WesterosBlockLifecycle { - - public static class Factory extends WesterosBlockFactory { - @Override - public Block buildBlockClass(WesterosBlockDef def, RegisterEvent.RegisterHelper helper) { - // See if we have a state property - WesterosBlockDef.StateProperty state = def.buildStateProperty(); - if (state != null) { - tempSTATE = state; - } - String t = def.getType(); - if ((t != null) && (t.indexOf(WesterosBlockDef.LAYER_SENSITIVE) >= 0)) { - tempLAYERS = BlockStateProperties.LAYERS; - } - BlockBehaviour.Properties props = def.makeProperties().noCollission(); - - Block blk = new WCWebBlock(props, def); - helper.register(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, def.blockName), blk); - def.registerBlockItem(def.blockName, blk); - return def.registerRenderType(blk, false, false); - } - } - private WesterosBlockDef def; - protected static WesterosBlockDef.StateProperty tempSTATE; - protected static IntegerProperty tempLAYERS; - protected WesterosBlockDef.StateProperty STATE; - protected IntegerProperty LAYERS; - protected boolean toggleOnUse = false; - private boolean noInWeb = false; - public boolean layerSensitive = false; - // Support waterlogged on these blocks - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - - protected WCWebBlock(BlockBehaviour.Properties props, WesterosBlockDef def) { - super(props); - this.def = def; - String t = def.getType(); - if (t != null) { - String[] toks = t.split(","); - for (String tok : toks) { - if (tok.equals("no-in-web")) { - noInWeb = true; - } - if (tok.equals("toggleOnUse")) { - toggleOnUse = true; - } - } - } - BlockState bsdef = this.stateDefinition.any().setValue(WATERLOGGED, Boolean.valueOf(false)); - if (LAYERS != null) { - bsdef = bsdef.setValue(LAYERS, 8); - } - if (STATE != null) { - bsdef = bsdef.setValue(STATE, STATE.defValue); - } - this.registerDefaultState(bsdef); - } - - @Override - public WesterosBlockDef getWBDefinition() { - return def; - } - - @Override - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { - if (!noInWeb) - super.entityInside(state, world, pos, entity); - } - - @Override - protected void createBlockStateDefinition(StateDefinition.Builder statedef) { - if (tempSTATE != null) { - STATE = tempSTATE; - tempSTATE = null; - } - if (tempLAYERS != null) { - LAYERS = tempLAYERS; - tempLAYERS = null; - } - if (STATE != null) { - statedef.add(STATE); - } - if (LAYERS != null) { - statedef.add(LAYERS); - } - statedef.add(WATERLOGGED); - } - - @Override - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState bs = super.getStateForPlacement(ctx); - if (bs == null) return null; - FluidState fluidstate = ctx.getLevel().getFluidState(ctx.getClickedPos()); - bs = bs.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.is(FluidTags.WATER))); - if (STATE != null) { - bs = bs.setValue(STATE, STATE.defValue); - } - if (LAYERS != null) { - BlockState below = ctx.getLevel().getBlockState(ctx.getClickedPos().relative(Direction.DOWN)); - if ((below != null) && (below.hasProperty(BlockStateProperties.LAYERS))) { - Block blk = below.getBlock(); - Integer layer = below.getValue(BlockStateProperties.LAYERS); - // See if soft layer - if ((blk instanceof SnowLayerBlock) || ((blk instanceof WCLayerBlock) && ((WCLayerBlock)blk).softLayer)) { - layer = (layer > 2) ? Integer.valueOf(layer - 2) : Integer.valueOf(1); - } - bs = bs.setValue(LAYERS, layer); - } - else if ((below != null) && (below.getBlock() instanceof SlabBlock)) { - SlabType slabtype = below.getValue(BlockStateProperties.SLAB_TYPE); - if (slabtype == SlabType.BOTTOM) bs = bs.setValue(LAYERS, 4); - } - } - return bs; - } - - @SuppressWarnings("deprecation") - @Override - public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); - } - @Override - public boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { - switch(pathComputationType) { - case LAND: - return false; - case WATER: - return state.getFluidState().is(FluidTags.WATER); - case AIR: - return false; - default: - return false; - } - } - - @Override - protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - if (this.toggleOnUse && (this.STATE != null) && player.isCreative() && player.getMainHandItem().isEmpty()) { - state = state.cycle(this.STATE); - level.setBlock(pos, state, 10); - level.levelEvent(player, 1006, pos, 0); - return InteractionResult.sidedSuccess(level.isClientSide); - } - else { - return InteractionResult.PASS; - } - } - - private static String[] TAGS = { }; - @Override - public String[] getBlockTags() { - return TAGS; - } - -} diff --git a/needsported/mixin/MixinClientboundGameEventPacket.java b/needsported/mixin/MixinClientboundGameEventPacket.java deleted file mode 100644 index 0ee43aa625..0000000000 --- a/needsported/mixin/MixinClientboundGameEventPacket.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.westerosblocks.needsported.mixin; -// TODO -//package com.westeroscraft.westerosblocks.mixin; -// -//import org.spongepowered.asm.mixin.Mixin; -// -//import org.spongepowered.asm.mixin.Shadow; -//import org.spongepowered.asm.mixin.injection.At; -//import org.spongepowered.asm.mixin.injection.Inject; -//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// -////import com.westeroscraft.westerosblocks.network.ClientMessageHandler; -// -//import net.minecraft.network.protocol.game.ClientboundGameEventPacket; -// -//@Mixin(ClientboundGameEventPacket.class) -//public abstract class MixinClientboundGameEventPacket -//{ -// @Shadow private ClientboundGameEventPacket.Type event; -// @Shadow private float param; -// -// // This constructor is fake and never used -// protected MixinClientboundGameEventPacket() -// { -// } -// -// @Inject(method = "handle", at = @At("TAIL")) -// private void handle(CallbackInfo ci) -// { -// // Record latest levels sent from server, for sake of reset -// if (event == ClientboundGameEventPacket.START_RAINING) { -// ClientMessageHandler.savedRain = true; -// ClientMessageHandler.savedRainLevel = 1.0F; -// } -// else if (event == ClientboundGameEventPacket.STOP_RAINING) { -// ClientMessageHandler.savedRain = false; -// ClientMessageHandler.savedRainLevel = 0.0F; -// } -// else if (event == ClientboundGameEventPacket.RAIN_LEVEL_CHANGE) { -// ClientMessageHandler.savedRainLevel = param; -// } -// else if (event == ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE) { -// ClientMessageHandler.savedThunderLevel = param; -// } -// -// switch (ClientMessageHandler.weatherCond) { -// case RESET: -// // Nothing to do -// break; -// case CLEAR: -// if (event == ClientboundGameEventPacket.START_RAINING) { -// event = ClientboundGameEventPacket.STOP_RAINING; // Force it to be stop -// param = 0.0F; -// } -// else if (event == ClientboundGameEventPacket.RAIN_LEVEL_CHANGE) { -// param = 0.0F; // Force to zero -// } -// else if (event == ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE) { -// param = 0.0F; // Force to zero -// } -// break; -// case RAIN: -// if (event == ClientboundGameEventPacket.STOP_RAINING) { -// event = ClientboundGameEventPacket.START_RAINING; // Force it to be start -// param = 0.0F; -// } -// else if (event == ClientboundGameEventPacket.RAIN_LEVEL_CHANGE) { -// param = 1.0F; // Force to one -// } -// else if (event == ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE) { -// param = 0.0F; // Force to zero -// } -// break; -// case THUNDER: -// if (event == ClientboundGameEventPacket.STOP_RAINING) { -// event = ClientboundGameEventPacket.START_RAINING; // Force it to be start -// param = 0.0F; -// } -// else if (event == ClientboundGameEventPacket.RAIN_LEVEL_CHANGE) { -// param = 1.0F; // Force to one -// } -// else if (event == ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE) { -// param = 1.0F; // Force to one -// } -// break; -// } -// } -//} \ No newline at end of file diff --git a/needsported/mixin/MixinClientboundSetTimePacket.java b/needsported/mixin/MixinClientboundSetTimePacket.java deleted file mode 100644 index a7d41a5496..0000000000 --- a/needsported/mixin/MixinClientboundSetTimePacket.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.westerosblocks.needsported.mixin; -// TODO - -//package com.westeroscraft.westerosblocks.mixin; -// -//import org.spongepowered.asm.mixin.Mixin; -//import org.spongepowered.asm.mixin.Shadow; -//import org.spongepowered.asm.mixin.injection.At; -//import org.spongepowered.asm.mixin.injection.Inject; -//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// -//import com.westeroscraft.westerosblocks.WesterosBlocks; -////import com.westeroscraft.westerosblocks.network.ClientMessageHandler; -// -//import net.minecraft.network.protocol.game.ClientGamePacketListener; -//import net.minecraft.network.protocol.game.ClientboundSetTimePacket; -// -//@Mixin(ClientboundSetTimePacket.class) -//public abstract class MixinClientboundSetTimePacket -//{ -// @Shadow private long gameTime; -// @Shadow private long dayTime; -// -// // This constructor is fake and never used -// protected MixinClientboundSetTimePacket() -// { -// } -// -// @Inject(method = "handle(Lnet/minecraft/network/protocol/game/ClientGamePacketListener;)V", at = @At("HEAD")) -// private void handle(ClientGamePacketListener listener, CallbackInfo ci) -// { -// //WesterosBlocks.log.info("SetTimePacket(" + gameTime + "," + dayTime + ")"); -// if (ClientMessageHandler.ptimeRelative) { // If we are relative mode -// if (ClientMessageHandler.ptimeOffset != 0) { -// //gameTime += ClientMessageHandler.ptimeOffset; -// dayTime = dayTime + ClientMessageHandler.ptimeOffset; -// } -// } -// else { // Else, absolute -// //gameTime = ClientMessageHandler.ptimeOffset; -// dayTime = -ClientMessageHandler.ptimeOffset; -// if (dayTime == 0) dayTime = -1; -// } -// //WesterosBlocks.log.info("SetTimePacket(exit)(" + gameTime + "," + dayTime + ")"); -// } -//} diff --git a/needsported/mixin/MixinDimensionSpecialEffects.java b/needsported/mixin/MixinDimensionSpecialEffects.java deleted file mode 100644 index 1f17865b75..0000000000 --- a/needsported/mixin/MixinDimensionSpecialEffects.java +++ /dev/null @@ -1,27 +0,0 @@ -//package com.westerosblocks.needsported.mixin; -// -//import net.minecraft.client.renderer.DimensionSpecialEffects; -//import org.spongepowered.asm.mixin.Mixin; -//import org.spongepowered.asm.mixin.Shadow; -//import org.spongepowered.asm.mixin.injection.At; -//import org.spongepowered.asm.mixin.injection.Inject; -//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -// -//@Mixin(DimensionSpecialEffects.class) -//public abstract class MixinDimensionSpecialEffects -//{ -// @Shadow float cloudLevel; -// -// // This constructor is fake and never used -// protected MixinDimensionSpecialEffects() -// { -// } -// -// @Inject(method = "getCloudHeight()F", at = @At("TAIL"), cancellable=true) -// private void doGetCloudHeight(CallbackInfoReturnable ci) { -// if (cloudLevel < 639.0F) { -// ci.setReturnValue(639.0F); -// } -// } -// -//} diff --git a/needsported/mixin/MixinDoorBlock.java b/needsported/mixin/MixinDoorBlock.java deleted file mode 100644 index 2d3f2c763e..0000000000 --- a/needsported/mixin/MixinDoorBlock.java +++ /dev/null @@ -1,47 +0,0 @@ -//package com.westerosblocks.needsported.mixin; -// -//import com.westeroscraft.westerosblocks.Config; -//import net.minecraft.core.BlockPos; -//import net.minecraft.world.InteractionHand; -//import net.minecraft.world.InteractionResult; -//import net.minecraft.world.entity.player.Player; -//import net.minecraft.world.level.BlockGetter; -//import net.minecraft.world.level.Level; -//import net.minecraft.world.level.LevelReader; -//import net.minecraft.world.level.block.Block; -//import net.minecraft.world.level.block.DoorBlock; -//import net.minecraft.world.level.block.state.BlockBehaviour; -//import net.minecraft.world.level.block.state.BlockState; -//import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; -//import net.minecraft.world.phys.BlockHitResult; -//import net.minecraft.world.phys.shapes.Shapes; -//import net.minecraft.world.phys.shapes.VoxelShape; -// -//import org.spongepowered.asm.mixin.Mixin; -//import org.spongepowered.asm.mixin.injection.At; -//import org.spongepowered.asm.mixin.injection.Inject; -//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -// -//@Mixin(DoorBlock.class) -//public abstract class MixinDoorBlock extends Block -//{ -// public MixinDoorBlock(BlockBehaviour.Properties props) { -// super(props); -// } -// -// @Inject(method = "canSurvive(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)Z", at = @At("HEAD"), cancellable=true) -// public void doCanSurvive(BlockState p_52783_, LevelReader p_52784_, BlockPos p_52785_, CallbackInfoReturnable ci) { -// if ((p_52783_.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER) && Config.doorSurviveAny) { -// ci.setReturnValue(true); -// } -// } -// -// @Override -// public VoxelShape getBlockSupportShape(BlockState state, BlockGetter reader, BlockPos pos) { -// if (Config.doorNoConnect) { -// return Shapes.empty(); -// } -// return super.getBlockSupportShape(state, reader, pos); -// } -// -//} diff --git a/needsported/mixin/MixinLevel.java b/needsported/mixin/MixinLevel.java deleted file mode 100644 index 98c09a76f2..0000000000 --- a/needsported/mixin/MixinLevel.java +++ /dev/null @@ -1,31 +0,0 @@ -//package com.westerosblocks.needsported.mixin; -// -//import com.westeroscraft.westerosblocks.Config; -//import net.minecraft.client.renderer.DimensionSpecialEffects; -//import net.minecraft.world.level.Level; -// -//import org.spongepowered.asm.mixin.Mixin; -//import org.spongepowered.asm.mixin.Shadow; -//import org.spongepowered.asm.mixin.injection.At; -//import org.spongepowered.asm.mixin.injection.Inject; -//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -// -//import com.westeroscraft.westerosblocks.WesterosBlocks; -// -//@Mixin(Level.class) -//public abstract class MixinLevel -//{ -// // This constructor is fake and never used -// protected MixinLevel() -// { -// } -// -// @Inject(method = "getSeaLevel()I", at = @At("TAIL"), cancellable=true) -// private void doGetSeaLevel(CallbackInfoReturnable ci) { -// Integer override = Config.seaLevelOverride; -// if (override.intValue() != 0) { -// ci.setReturnValue(override); -// } -// } -// -//} diff --git a/needsported/modelexport/FanBlockModelExport.java b/needsported/modelexport/FanBlockModelExport.java deleted file mode 100644 index 75dde1f1ac..0000000000 --- a/needsported/modelexport/FanBlockModelExport.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.westerosblocks.needsported.modelexport; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockStateRecord; -import com.westeroscraft.westerosblocks.WesterosBlocks; - -import net.minecraft.world.level.block.Block; - -public class FanBlockModelExport extends ModelExport { - // Template objects for Gson export of block models - public static class ModelObjectFan { - public String parent = "westerosblocks:block/untinted/fan"; - public Texture textures = new Texture(); - } - public static class ModelObjectWallFan { - public String parent = "westerosblocks:block/untinted/wall_fan"; - public Texture textures = new Texture(); - } - public static class Texture { - public String fan; - } - public static class ModelObject { - public String parent = "item/generated"; - public Texture0 textures = new Texture0(); - } - public static class Texture0 { - public String layer0; - } - - public FanBlockModelExport(Block blk, WesterosBlockDef def, File dest) { - super(blk, def, dest); - addNLSString("block." + WesterosBlocks.MOD_ID + "." + def.blockName, def.label); - } - - @Override - public void doBlockStateExport() throws IOException { - StateObject so = new StateObject(); - - // Loop over the random sets we've got - for (int setidx = 0; setidx < def.getRandomTextureSetCount(); setidx++) { - WesterosBlockDef.RandomTextureSet set = def.getRandomTextureSet(setidx); - - // Make floor block - Variant var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("base", setidx); - var.weight = set.weight; - so.addVariant("", var, null); - this.writeBlockStateFile(def.blockName, so); - - // Make wall block - so = new StateObject(); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", setidx); - var.y = 90; - so.addVariant("facing=east", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", setidx); - var.y = 180; - so.addVariant("facing=south", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", setidx); - var.y = 270; - so.addVariant("facing=west", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", setidx); - var.y = 0; - so.addVariant("facing=north", var, null); - - this.writeBlockStateFile("wall_" + def.blockName, so); - } - } - - protected void doFanModel(boolean isTinted, int setidx) throws IOException { - WesterosBlockDef.RandomTextureSet set = def.getRandomTextureSet(setidx); - String txt = getTextureID(set.getTextureByIndex(0)); - ModelObjectFan mod = new ModelObjectFan(); - mod.parent = (isTinted) ? "westerosblocks:block/tinted/fan" : "westerosblocks:block/untinted/fan"; - mod.textures.fan = txt; - this.writeBlockModelFile(getModelName("base", setidx), mod); - } - - protected void doWallFanModel(boolean isTinted, int setidx) throws IOException { - WesterosBlockDef.RandomTextureSet set = def.getRandomTextureSet(setidx); - String txt = getTextureID(set.getTextureByIndex(0)); - ModelObjectWallFan mod = new ModelObjectWallFan(); - mod.parent = (isTinted) ? "westerosblocks:block/tinted/wall_fan" : "westerosblocks:block/untinted/wall_fan"; - mod.textures.fan = txt; - this.writeBlockModelFile(getModelName("wall", setidx), mod); - } - - @Override - public void doModelExports() throws IOException { - boolean isTinted = def.isTinted(); - // Loop over the random sets we've got - for (int setidx = 0; setidx < def.getRandomTextureSetCount(); setidx++) { - doFanModel(isTinted, setidx); - doWallFanModel(isTinted, setidx); - } - - // Build simple item model that refers to block model - String txt = getTextureID(def.getRandomTextureSet(0).getTextureByIndex(0)); - ModelObjectFan mod = new ModelObjectFan(); - mod.parent = (isTinted) ? "westerosblocks:block/tinted/fan" : "westerosblocks:block/untinted/fan"; - mod.textures.fan = txt; - this.writeItemModelFile(def.blockName, mod); - // Handle tint resources - if (isTinted) { - String tintres = def.getBlockColorMapResource(); - if (tintres != null) { - ModelExport.addTintingOverride(def.getBlockName(), "", tintres); - } - } - } - - @Override - public void doWorldConverterMigrate() throws IOException { - String oldID = def.getLegacyBlockName(); - if (oldID == null) return; - Map oldmap = def.getLegacyBlockMap(); - addWorldConverterComment(def.legacyBlockID + "(" + def.label + ")"); - // BUild old variant map - HashMap oldstate = new HashMap(); - HashMap newstate = new HashMap(); - if (oldmap != null) { - for (String k : oldmap.keySet()) { - oldstate.put(k, oldmap.get(k)); - } - } - oldstate.put("facing", "north"); - newstate.put("facing", "north"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "south"); - newstate.put("facing", "south"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "east"); - newstate.put("facing", "east"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "west"); - newstate.put("facing", "west"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "up"); - addWorldConverterRecord(oldID, oldstate, def.getBlockName(), null); - } -} diff --git a/needsported/modelexport/ModelExport.java b/needsported/modelexport/ModelExport.java deleted file mode 100644 index e62253f167..0000000000 --- a/needsported/modelexport/ModelExport.java +++ /dev/null @@ -1,583 +0,0 @@ -package com.westerosblocks.needsported.modelexport; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeSet; -import java.util.LinkedList; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.westeroscraft.westerosblocks.WesterosBlockConfig; -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlockLifecycle; -import com.westeroscraft.westerosblocks.WesterosBlockTags; -import com.westeroscraft.westerosblocks.WesterosBlocks; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.block.Block; - -public abstract class ModelExport { - private static File destdir; - private static File blockstatedir; - private static File blockmodeldir; - private static File itemmodeldir; - private static boolean didInit = false; - - // Common state lists - public static final String[] FACING = { "north", "south", "east", "west" }; - public static final String[] BOOLEAN = { "true", "false" }; - public static final String[] TOPBOTTOM = { "top", "bottom" }; - public static final String[] UPPERLOWER = { "upper", "lower" }; - public static final String[] LEFTRIGHT = { "left", "right" }; - public static final String[] ALLFACING = { "north", "south", "east", "west", "up", "down" }; - public static final String[] UPFACING = { "north", "south", "east", "west", "up" }; - public static final String[] HEADFOOT = { "head", "foot" }; - public static final String[] AGE15 = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; - public static final String[] DISTANCE7 = { "0", "1", "2", "3", "4", "5", "6", "7" }; - public static final String[] BITES7 = { "0", "1", "2", "3", "4", "5", "6", "7" }; - public static final String[] SHAPE5 = { "straight", "inner_right", "inner_left", "outer_right", "outer_left" }; - public static final String[] AXIS = { "x", "y", "z" }; - public static final String[] FACINGNE = { "north", "east" }; - public static final String[] RAILSHAPE = { "north_south", "east_west", "ascending_east", "ascending_west", "ascending_north", "ascending_south","south_east", "south_west", "north_west", "north_east" }; - - // Test for WB standard 'all clear' texture - public boolean isTransparentTexture(String txt) { - return txt.equals("transparent"); - } - - public static void doInit(File dest) { - if (!didInit) { - destdir = dest; - blockstatedir = new File(destdir, "assets/" + WesterosBlocks.MOD_ID + "/blockstates"); - blockstatedir.mkdirs(); - blockmodeldir = new File(destdir, "assets/" + WesterosBlocks.MOD_ID + "/models/block/generated"); - blockmodeldir.mkdirs(); - itemmodeldir = new File(destdir, "assets/" + WesterosBlocks.MOD_ID + "/models/item"); - itemmodeldir.mkdirs(); - didInit = true; - } - } - - protected final Block block; - protected final WesterosBlockDef def; - public ModelExport(Block block, WesterosBlockDef def, File dest) { - doInit(dest); - this.block = block; - this.def = def; - } - public void writeBlockStateFile(String blockname, Object obj) throws IOException { - File f = new File(blockstatedir, blockname + ".json"); - f.getParentFile().mkdirs(); - FileWriter fos = null; - try { - fos = new FileWriter(f); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(obj, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - protected String getModelName(String ext, int setidx) { - return def.blockName + "/" + ext + ("_v" + (setidx+1)); - } - - protected String getModelName(String ext, int setidx, String cond) { - if (cond == null) - return getModelName(ext, setidx); - return def.blockName + "/" + cond + "/" + ext + ("_v" + (setidx+1)); - } - - public void writeBlockModelFile(String model, Object obj) throws IOException { - File f = new File(blockmodeldir, model + ".json"); - f.getParentFile().mkdirs(); - FileWriter fos = null; - try { - fos = new FileWriter(f); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(obj, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - public void writeItemModelFile(String model, Object obj) throws IOException { - File f = new File(itemmodeldir, model + ".json"); - f.getParentFile().mkdirs(); - FileWriter fos = null; - try { - fos = new FileWriter(f); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(obj, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - public static String getTextureID(String id) { - if (id.indexOf(':') >= 0) { - return id; - } - else { - return WesterosBlocks.MOD_ID + ":block/" + id; - } - } - public abstract void doBlockStateExport() throws IOException; - public abstract void doModelExports() throws IOException; - public void doWorldConverterMigrate() throws IOException { - WesterosBlocks.log.info("No WorldConverter support for " + def.blockType); - } - - private static HashMap nls = new HashMap(); - public static void addNLSString(String id, String val) { - nls.put(id, val); - } - public static void writeNLSFile(Path dest) throws IOException { - File tgt = new File(dest.toFile(), "assets/" + WesterosBlocks.MOD_ID + "/lang"); - tgt.mkdirs(); - FileWriter fos = null; - try { - fos = new FileWriter(new File(tgt, "en_us.json")); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(nls, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - private static LinkedList wcList = new LinkedList(); - private static LinkedList itmMapList = new LinkedList(); - - public static void addWorldConverterRecord(String oldBlockName, Map oldBlockState, String newBlockName, Map newBlockState) { - if (oldBlockName.indexOf(':') < 0) oldBlockName = WesterosBlocks.MOD_ID + ":" + oldBlockName; - if (newBlockName.indexOf(':') < 0) newBlockName = WesterosBlocks.MOD_ID + ":" + newBlockName; - StringBuilder sb = new StringBuilder(oldBlockName); - if ((oldBlockState != null) && (oldBlockState.size() > 0)) { - sb.append('['); - boolean first = true; - TreeSet keys = new TreeSet(oldBlockState.keySet()); - for (String key : keys) { - if (!first) sb.append(','); - sb.append(key).append("=").append(oldBlockState.get(key)); - first = false; - } - sb.append(']'); - } - sb.append(" -> "); - sb.append(newBlockName); - if ((newBlockState != null) && (newBlockState.size() > 0)) { - sb.append('['); - boolean first = true; - TreeSet keys = new TreeSet(newBlockState.keySet()); - for (String key : keys) { - if (!first) sb.append(','); - sb.append(key).append("=").append(newBlockState.get(key)); - first = false; - } - sb.append(']'); - } - wcList.add(sb.toString()); - } - public static void addWorldConverterComment(String txt) { - //wcList.add("# " + txt); - } - public static void addWorldConverterItemMap(String src, String dest) { - String [] tokens = src.split(":"); - if (tokens.length == 1) { - src = WesterosBlocks.MOD_ID + ":" + tokens[0] + ":0"; - } - else if (tokens.length == 2) { - if (tokens[0].equals("minecraft")) { - src = "minecraft:" + tokens[1] + ":0"; - } - else { - src = WesterosBlocks.MOD_ID + ":" + tokens[0] + ":" + tokens[1]; - } - } - else if (tokens.length == 3) { - src = tokens[0] + ":" + tokens[1] + ":" + tokens[2]; - } -// itmMapList.add(String.format("%s -> %s:%s", src, WesterosBlocks.MOD_ID, dest)); - itmMapList.add(String.format("itemIDMapping.put(\"%s\", \"%s:%s\");", src, WesterosBlocks.MOD_ID, dest)); - } - public static void writeWorldConverterFile(Path dest) throws IOException { - FileWriter fos = null; - try { - fos = new FileWriter(new File(dest.toFile(), "blocks_1.12-1.18__westerosblocks.txt")); - for (String line : wcList) { - fos.write(line + "\r\n"); - } - } finally { - if (fos != null) { - fos.close(); - } - } - } - public static void writeWorldConverterItemMapFile(Path dest) throws IOException { - FileWriter fos = null; - try { - fos = new FileWriter(new File(dest.toFile(), "items_1.12-1.18__westerosblocks.txt")); - for (String line : itmMapList) { - fos.write(line + "\r\n"); - } - } finally { - if (fos != null) { - fos.close(); - } - } - } - - private static class TagFile { - boolean replace = false; - String[] values = {}; - }; - - public static void writeTagDataFiles(Path dest) throws IOException { - File tgt = new File(dest.toFile(), "data/minecraft/tags/blocks"); - tgt.mkdirs(); - HashMap> blksByTag = new HashMap>(); - // Load all the tags - for (String blockName : WesterosBlocks.customBlocksByName.keySet()) { - Block blk = WesterosBlocks.customBlocksByName.get(blockName); - if (blk instanceof WesterosBlockLifecycle) { - WesterosBlockLifecycle wb = (WesterosBlockLifecycle) blk; - String[] tags = wb.getBlockTags(); // Get block tags - for (String tag : tags) { - ArrayList lst = blksByTag.get(tag.toLowerCase()); - if (lst == null) { - lst = new ArrayList(); - blksByTag.put(tag.toLowerCase(), lst); - } - lst.add(WesterosBlocks.MOD_ID + ":" + blockName); - } - } - } - // And write the files for each - for (String tagID : blksByTag.keySet()) { - ArrayList lst = blksByTag.get(tagID); - FileWriter fos = null; - try { - TagFile tf = new TagFile(); - tf.values = lst.toArray(new String[lst.size()]); - fos = new FileWriter(new File(tgt, tagID + ".json")); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(tf, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - } - - public static void writeCustomTagDataFiles(Path dest, WesterosBlockConfig cfg) throws IOException { - File tgt = new File(dest.toFile(), "data/" + WesterosBlocks.MOD_ID + "/tags/blocks"); - tgt.mkdirs(); - HashMap> blksByTag = new HashMap>(); - // Declare custom tags - must be record for each - if (cfg.blockTags != null) { - for (WesterosBlockTags tag : cfg.blockTags) { - String tagid = tag.customTag.toLowerCase(); - ArrayList lst = blksByTag.get(tagid); - if (lst == null) { - lst = new ArrayList(); - blksByTag.put(tagid, lst); - } - for (String id : tag.blockNames) { - lst.add(id.toLowerCase()); - } - } - } - // Load all the custom tags from blocks - for (String blockName : WesterosBlocks.customBlocksByName.keySet()) { - Block blk = WesterosBlocks.customBlocksByName.get(blockName); - if (blk instanceof WesterosBlockLifecycle) { - WesterosBlockLifecycle wb = (WesterosBlockLifecycle) blk; - WesterosBlockDef def = wb.getWBDefinition(); - if (def.customTags != null) { - for (String tag : def.customTags) { - ArrayList lst = blksByTag.get(tag.toLowerCase()); - if (lst == null) { - WesterosBlocks.log.error("Invalid customTag " + tag + " on block " + blockName); - continue; - } - lst.add(WesterosBlocks.MOD_ID + ":" + blockName); - } - } - } - } - // And write the files for each - for (String tagID : blksByTag.keySet()) { - ArrayList lst = blksByTag.get(tagID); - FileWriter fos = null; - try { - TagFile tf = new TagFile(); - tf.values = lst.toArray(new String[lst.size()]); - fos = new FileWriter(new File(tgt, tagID + ".json")); - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - gson.toJson(tf, fos); - } finally { - if (fos != null) { - fos.close(); - } - } - } - } - public static List> customTags; - - public static void declareCustomTags(WesterosBlockConfig cfg) { - // Declare custom tags - must be record for each - if (cfg.blockTags != null) { - customTags = new ArrayList>(); - for (WesterosBlockTags tag : cfg.blockTags) { - String tagid = tag.customTag.toLowerCase(); - customTags.add(BlockTags.create(ResourceLocation.fromNamespaceAndPath(WesterosBlocks.MOD_ID, tagid))); - } - } - } - private static class TintOver { - String cond; - String txt; - } - private static Map> tintoverrides = new HashMap>(); - - public static void addTintingOverride(String blockname, String cond, String txtfile) { - List blst = tintoverrides.get(blockname); - if (blst == null) { - blst = new ArrayList(); - tintoverrides.put(blockname, blst); - } - TintOver to = new TintOver(); - to.cond = cond; - to.txt = txtfile; - blst.add(to); - } - public static void writeDynmapOverridesFile(Path dest) throws IOException { - File tgt = new File(dest.toFile(), "assets/" + WesterosBlocks.MOD_ID + "/dynmap"); - tgt.mkdirs(); - PrintStream fw = null; - try { - fw = new PrintStream(new File(tgt, "blockstateoverrides.json")); - fw.println("{"); - fw.println(" \"overrides\": {"); - fw.println(" \"" + WesterosBlocks.MOD_ID + "\": {"); - //TODO - add block state overrides - fw.println(" }"); - fw.println(" },"); - fw.println(" \"tinting\": {"); - fw.println(" \"" + WesterosBlocks.MOD_ID + "\": {"); - boolean first1 = true; - for (Entry> br : tintoverrides.entrySet()) { - if (!first1) { - fw.println(" ,"); - } - fw.println(" \"" + br.getKey() + "\": ["); - boolean first2 = true; - for (TintOver toe : br.getValue()) { - if (!first2) { - fw.println(" ,"); - } - if ((toe.cond != null) && (toe.cond.equals("") == false)) { - fw.println(" { \"state\": \"" + toe.cond + "\", \"colormap\": [ \"" + toe.txt + "\" ] }"); - } - else { - fw.println(" { \"colormap\": [ \"" + toe.txt + "\" ] }"); - } - first2 = false; - } - fw.println(" ]"); - first1 = false; - } - fw.println(" }"); - fw.println(" }"); - fw.println("}"); - } finally { - if (fw != null) fw.close(); - } - } - - // Template objects for Gson export of block state - public static class StateObject { - public Map variants; - public List multipart; - - public void addVariant(String cond, Variant v, Set stateIDs) { - if (variants == null) { - variants = new HashMap(); - } - ArrayList conds = new ArrayList(); - if (stateIDs == null) { - conds.add(cond); - } else { - for (String cval : stateIDs) { - conds.add(cond + ((cond.length() > 0) ? "," : "") + "state=" + cval); - } - } - // Add to all the matching condIDs - for (String condval : conds) { - VarOrVarList existing = variants.get(condval); // See if exists - if (existing == null) { - variants.put(condval, v); // Add single - } - else if (existing instanceof Variant) { // Only one? - VariantList vlist = new VariantList(); - vlist.add((Variant) existing); // Convert to list - vlist.add(v); - variants.put(condval, vlist); - } - else { - ((VariantList) existing).add(v); // Append to list - } - } - } - public void addStates(States st, Set stateIDs) { - if (multipart == null) { - multipart = new ArrayList(); - } - if (stateIDs == null) { - multipart.add(st); - } - else { - for (String cond : stateIDs) { - States newst = new States(st, cond); - multipart.add(newst); - } - } - } - private void addState(WhenRec rec, Apply a, String cond) { - States matchst = null; - WhenRec wr = rec; - // Add condition to whenrec - if (cond != null) { - if (rec != null) { - wr = new WhenRec(rec, cond); - } - else { - wr = new WhenRec(); - wr.state = cond; - } - } - for (States st : multipart) { - if (((st.when == null) && (wr == null)) || - ((st.when != null) && (wr != null) && st.when.equals(wr))) { - matchst = st; - break; - } - } - // Add new rec, if needed - if (matchst == null) { - matchst = new States(); - matchst.when = wr; - multipart.add(matchst); - } - // Now add our apply - matchst.apply.add(a); - } - - public void addStates(WhenRec rec, Apply a, Set stateIDs) { - if (multipart == null) { - multipart = new ArrayList(); - } - if (stateIDs == null) { - addState(rec, a, null); - } - else { - for (String cond : stateIDs) { - addState(rec, a, cond); - } - } - } - } - public static interface VarOrVarList {}; - - public static class Variant implements VarOrVarList { - public String model; - public Integer x, y, z; - public Integer weight; - public Boolean uvlock; - } - public static class VariantList extends ArrayList implements VarOrVarList { - private static final long serialVersionUID = 1L; - } - public static class States { - public List apply = new ArrayList(); - public WhenRec when; - public States() {} - public States(States orig, String cond) { - this.apply = orig.apply; - if (orig.when != null) { - this.when = new WhenRec(orig.when, cond); - } - else { - this.when = new WhenRec(); - this.when.state = cond; - } - } - } - public static class WhenRec { - String north, south, west, east, up, down, state; - public List OR; - - public WhenRec() {} - public WhenRec(WhenRec orig, String cond) { - this.north = orig.north; - this.south = orig.south; - this.east = orig.east; - this.west = orig.west; - this.up = orig.up; - this.down = orig.down; - this.OR = orig.OR; - this.state = cond; - } - public void addOR(WhenRec r) { - if (OR == null) OR = new ArrayList(); - OR.add(r); - } - private boolean isSame(String a, String b) { - if ((a == null) && (b == null)) return true; - if ((a != null) && (b != null) && a.equals(b)) return true; - return false; - } - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof WhenRec) { - WhenRec or = (WhenRec)o; - if (isSame(or.north, this.north) && - isSame(or.south, this.south) && - isSame(or.east, this.east) && - isSame(or.west, this.west) && - isSame(or.up, this.up) && - isSame(or.down, this.down) && - isSame(or.state, this.state)) { - if ((or.OR == null) && (this.OR == null)) return true; - if ((or.OR != null) && (this.OR != null) && (this.OR.equals(or.OR))) return true; - } - } - return false; - } - } - public static class Apply { - String model; - Integer x; - Integer y; - Boolean uvlock; - Integer weight; - } -} diff --git a/needsported/modelexport/ModelExportFactory.java b/needsported/modelexport/ModelExportFactory.java deleted file mode 100644 index 9ada3d07d7..0000000000 --- a/needsported/modelexport/ModelExportFactory.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.westerosblocks.needsported.modelexport; - -import java.io.File; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; - -import net.minecraft.world.level.block.Block; - -public class ModelExportFactory { - public static ModelExport forBlock(Block blk, WesterosBlockDef def, File dest) { - ModelExport me = null; - switch (def.blockType) { - case "solid": - case "soulsand": - case "sand": - me = new SolidBlockModelExport(blk, def, dest); - break; - case "sound": - me = new SoundBlockModelExport(blk, def, dest); - break; - case "stair": - me = new StairsBlockModelExport(blk, def, dest); - break; - case "leaves": - me = new LeavesBlockModelExport(blk, def, dest); - break; - case "log": - me = new LogBlockModelExport(blk, def, dest); - break; - case "plant": - case "web": - me = new CrossBlockModelExport(blk, def, dest); - break; - case "pane": - me = new PaneBlockModelExport(blk, def, dest); - break; - case "crop": - me = new CropBlockModelExport(blk, def, dest); - break; - case "door": - me = new DoorBlockModelExport(blk, def, dest); - break; - case "slab": - me = new SlabBlockModelExport(blk, def, dest); - break; - case "fence": - me = new FenceBlockModelExport(blk, def, dest); - break; - case "wall": - me = new WallBlockModelExport(blk, def, dest); - break; - case "trapdoor": - me = new TrapDoorBlockModelExport(blk, def, dest); - break; - case "torch": - me = new TorchBlockModelExport(blk, def, dest); - break; - case "fan": - me = new FanBlockModelExport(blk, def, dest); - break; - case "ladder": - me = new LadderBlockModelExport(blk, def, dest); - break; - case "fire": - me = new FireBlockModelExport(blk, def, dest); - break; - case "bed": - me = new BedBlockModelExport(blk, def, dest); - break; - case "cuboid": - case "beacon": - me = new CuboidBlockModelExport(blk, def, dest); - break; - case "cuboid-ne": - me = new CuboidNEBlockModelExport(blk, def, dest); - break; - case "cuboid-nsew": - me = new CuboidNSEWBlockModelExport(blk, def, dest); - break; - case "cuboid-16way": - me = new Cuboid16WayBlockModelExport(blk, def, dest); - break; - case "cuboid-nsew-stack": - me = new CuboidNSEWStackBlockModelExport(blk, def, dest); - break; - case "cuboid-nsewud": - me = new CuboidNSEWUDBlockModelExport(blk, def, dest); - break; - case "layer": - me = new LayerBlockModelExport(blk, def, dest); - break; - case "rail": - me = new RailBlockModelExport(blk, def, dest); - break; - case "halfdoor": - me = new HalfDoorBlockModelExport(blk, def, dest); - break; - case "cake": - me = new CakeBlockModelExport(blk, def, dest); - break; - case "furnace": - me = new FurnaceBlockModelExport(blk, def, dest); - break; - case "vines": - me = new VinesBlockModelExport(blk, def, dest); - break; - case "flowerpot": - me = new FlowerPotBlockModelExport(blk, def, dest); - break; - case "fencegate": - me = new FenceGateBlockModelExport(blk, def, dest); - break; - case "particle": - me = new ParticleBlockModelExport(blk, def, dest); - break; - } - return me; - } -} diff --git a/needsported/modelexport/TorchBlockModelExport.java b/needsported/modelexport/TorchBlockModelExport.java deleted file mode 100644 index f6a9e1db6a..0000000000 --- a/needsported/modelexport/TorchBlockModelExport.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.westerosblocks.needsported.modelexport; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; -import com.westeroscraft.westerosblocks.WesterosBlocks; - -import net.minecraft.world.level.block.Block; - -public class TorchBlockModelExport extends ModelExport { - // Template objects for Gson export of block models - public static class ModelObjectTorch { - public String parent = "westerosblocks:block/untinted/template_torch"; // Use 'torch' model for single texture - public Texture textures = new Texture(); - } - public static class ModelObjectTorchWall { - public String parent = "westerosblocks:block/untinted/template_torch_wall"; // Use 'torch_wall' model for single texture - public Texture textures = new Texture(); - } - public static class Texture { - public String torch; - } - public static class ModelObject { - public String parent = "item/generated"; - public Texture0 textures = new Texture0(); - } - public static class Texture0 { - public String layer0; - } - - public TorchBlockModelExport(Block blk, WesterosBlockDef def, File dest) { - super(blk, def, dest); - addNLSString("block." + WesterosBlocks.MOD_ID + "." + def.blockName, def.label); - } - - @Override - public void doBlockStateExport() throws IOException { - StateObject so = new StateObject(); - - Variant var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("base", 0); - so.addVariant("", var, null); - - this.writeBlockStateFile(def.blockName, so); - - // Make wall block too - so = new StateObject(); - - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", 0); - var.y = 0; - so.addVariant("facing=east", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", 0); - var.y = 90; - so.addVariant("facing=south", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", 0); - var.y = 180; - so.addVariant("facing=west", var, null); - var = new Variant(); - var.model = WesterosBlocks.MOD_ID + ":block/generated/" + getModelName("wall", 0); - var.y = 270; - so.addVariant("facing=north", var, null); - - this.writeBlockStateFile("wall_" + def.blockName, so); - } - - @Override - public void doModelExports() throws IOException { - String txt = getTextureID(def.getTextureByIndex(0)); - ModelObjectTorch mod = new ModelObjectTorch(); - mod.textures.torch = txt; - this.writeBlockModelFile(getModelName("base", 0), mod); - // Build wall block model - ModelObjectTorchWall modw = new ModelObjectTorchWall(); - modw.textures.torch = txt; - this.writeBlockModelFile(getModelName("wall", 0), modw); - - // Build simple item model that refers to block model - ModelObject mo = new ModelObject(); - mo.textures.layer0 = txt; - this.writeItemModelFile(def.blockName, mo); - } - - @Override - public void doWorldConverterMigrate() throws IOException { - String oldID = def.getLegacyBlockName(); - if (oldID == null) return; - Map oldmap = def.getLegacyBlockMap(); - addWorldConverterComment(def.legacyBlockID + "(" + def.label + ")"); - // BUild old variant map - HashMap oldstate = new HashMap(); - HashMap newstate = new HashMap(); - if (oldmap != null) { - for (String k : oldmap.keySet()) { - oldstate.put(k, oldmap.get(k)); - } - } - oldstate.put("facing", "north"); - newstate.put("facing", "north"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "south"); - newstate.put("facing", "south"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "east"); - newstate.put("facing", "east"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "west"); - newstate.put("facing", "west"); - addWorldConverterRecord(oldID, oldstate, "wall_" + def.getBlockName(), newstate); - oldstate.put("facing", "up"); - addWorldConverterRecord(oldID, oldstate, def.getBlockName(), null); - } -} diff --git a/needsported/network/ClientMessageHandler.java b/needsported/network/ClientMessageHandler.java deleted file mode 100644 index 3908e6903c..0000000000 --- a/needsported/network/ClientMessageHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.westerosblocks.needsported.network;//package com.westeroscraft.westerosblocks.network; -//import com.westeroscraft.westerosblocks.WesterosBlocks; -// -//import net.minecraft.world.level.Level; -//import net.neoforged.fml.LogicalSide; -//import net.neoforged.neoforge.common.util.LogicalSidedProvider; -// -//import java.util.Optional; -// -//public class ClientMessageHandler { -// -// /** -// * Called when PTimeMessage received. -// * CALLED BY THE NETWORK THREAD, NOT THE CLIENT THREAD. -// */ -// public static void onPTimeMessageReceived(final PTimeMessage message, -// Supplier ctxSupplier) { -// NetworkEvent.Context ctx = ctxSupplier.get(); -// LogicalSide sideReceived = ctx.getDirection().getReceptionSide(); -// ctx.setPacketHandled(true); -// -// if (sideReceived != LogicalSide.CLIENT) { -// WesterosBlocks.log.warn("PTimeMessage received on wrong side:" + ctx.getDirection().getReceptionSide()); -// return; -// } -// Optional clientWorld = LogicalSidedProvider.CLIENTWORLD.get(sideReceived); -// if (!clientWorld.isPresent()) { -// WesterosBlocks.log.warn("PTimeMessage context could not provide a ClientWorld."); -// return; -// } -// // Enqueue processing to happen on client thread next tick -// ctx.enqueueWork(() -> processPTimeMessage(clientWorld.get(), message)); -// } -// -// public static boolean ptimeRelative = true; -// public static int ptimeOffset = 0; -// -// // This message is called from the Client thread. -// // It spawns a number of Particle particles at the target location within a -// // short range around the target location -// private static void processPTimeMessage(Level worldClient, PTimeMessage message) { -// WesterosBlocks.log.info("Got PTimeMessage: relative=" + message.relative + ", time_off=" + message.time_off); -// ptimeRelative = message.relative; -// ptimeOffset = message.time_off; -// } -// -// /** -// * Called when PWeatherMessage received. -// * CALLED BY THE NETWORK THREAD, NOT THE CLIENT THREAD. -// */ -// public static void onPWeatherMessageReceived(final PWeatherMessage message, -// Supplier ctxSupplier) { -// NetworkEvent.Context ctx = ctxSupplier.get(); -// LogicalSide sideReceived = ctx.getDirection().getReceptionSide(); -// ctx.setPacketHandled(true); -// -// if (sideReceived != LogicalSide.CLIENT) { -// WesterosBlocks.log.warn("PWeatherMessage received on wrong side:" + ctx.getDirection().getReceptionSide()); -// return; -// } -// Optional clientWorld = LogicalSidedProvider.CLIENTWORLD.get(sideReceived); -// if (!clientWorld.isPresent()) { -// WesterosBlocks.log.warn("PWeatherMessage context could not provide a ClientWorld."); -// return; -// } -// // Enqueue processing to happen on client thread next tick -// ctx.enqueueWork(() -> processPWeatherMessage(clientWorld.get(), message)); -// } -// -// public static PWeatherMessage.WeatherCond weatherCond = PWeatherMessage.WeatherCond.RESET; -// public static boolean savedRain = false; -// public static float savedRainLevel = 0.0F; -// public static float savedThunderLevel = 0.0F; -// // This message is called from the Client thread. -// // It spawns a number of Particle particles at the target location within a -// // short range around the target location -// private static void processPWeatherMessage(Level worldClient, PWeatherMessage message) { -// WesterosBlocks.log.info("Got PWeatherMessage: " + message.weather); -// weatherCond = message.weather; -// switch (weatherCond) { -// case RESET: -// worldClient.getLevelData().setRaining(savedRain); -// worldClient.setRainLevel(savedRainLevel); -// worldClient.setThunderLevel(savedThunderLevel); -// break; -// case CLEAR: -// worldClient.getLevelData().setRaining(false); -// worldClient.setRainLevel(0.0F); -// worldClient.setThunderLevel(0.0F); -// break; -// case RAIN: -// worldClient.getLevelData().setRaining(true); -// worldClient.setRainLevel(1.0F); -// worldClient.setThunderLevel(0.0F); -// break; -// case THUNDER: -// worldClient.getLevelData().setRaining(true); -// worldClient.setRainLevel(1.0F); -// worldClient.setThunderLevel(1.0F); -// break; -// } -// } -// -// public static boolean isThisProtocolAcceptedByClient(String protocolVersion) { -// return WesterosBlocks.MESSAGE_PROTOCOL_VERSION.equals(protocolVersion); -// } -//} \ No newline at end of file diff --git a/needsported/network/PTimeMessage.java b/needsported/network/PTimeMessage.java deleted file mode 100644 index 746144c991..0000000000 --- a/needsported/network/PTimeMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.westerosblocks.needsported.network; - -import net.minecraft.network.FriendlyByteBuf; - -import com.westeroscraft.westerosblocks.WesterosBlocks; - -public class PTimeMessage { - public static int PTIME_MSGID = 0x01; - public boolean relative; // Indicates whether time_off is fixed (false) or relative (true) - public int time_off; // Absolute time in day, or offset, in ticks - - public PTimeMessage(boolean rel, int timeoff) { - relative = rel; - time_off = timeoff; - } - - public PTimeMessage() { - - } - - public static PTimeMessage decode(FriendlyByteBuf buf) { - try { - return new PTimeMessage(buf.readBoolean(), buf.readInt()); - } catch (IllegalArgumentException | IndexOutOfBoundsException e) { - WesterosBlocks.log.warn("Exception while reading PTimeMessage: " + e); - return null; - } - } - - public void encode(FriendlyByteBuf buf) { - buf.writeBoolean(this.relative); - buf.writeInt(this.time_off); - } - - @Override - public String toString() { - return "PTimeMessage[relative=" + relative + ",time_off=" + time_off + "]"; - } -} \ No newline at end of file diff --git a/needsported/network/PWeatherMessage.java b/needsported/network/PWeatherMessage.java deleted file mode 100644 index 284a196c30..0000000000 --- a/needsported/network/PWeatherMessage.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.westerosblocks.needsported.network; - -import net.minecraft.network.FriendlyByteBuf; - -import com.westeroscraft.westerosblocks.WesterosBlocks; - -public class PWeatherMessage { - public static int PWEATHER_MSGID = 0x02; - public enum WeatherCond { - RESET, CLEAR, RAIN, THUNDER - }; - public static final WeatherCond[] weathercondlist = WeatherCond.values(); - - public WeatherCond weather; - - public PWeatherMessage(WeatherCond wthr) { - weather = wthr; - } - - public PWeatherMessage() { - - } - - public static PWeatherMessage decode(FriendlyByteBuf buf) { - try { - int idx = buf.readInt(); - return new PWeatherMessage(weathercondlist[idx]); - } catch (IllegalArgumentException | IndexOutOfBoundsException e) { - WesterosBlocks.log.warn("Exception while reading PTimeMessage: " + e); - return null; - } - } - - public void encode(FriendlyByteBuf buf) { - buf.writeInt(this.weather.ordinal()); - } - - @Override - public String toString() { - return "PWeatherMessage[" + weather + "]"; - } -} \ No newline at end of file diff --git a/needsported/network/ServerMessageHandler.java b/needsported/network/ServerMessageHandler.java deleted file mode 100644 index 7addec4033..0000000000 --- a/needsported/network/ServerMessageHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.westerosblocks.needsported.network;//package com.westeroscraft.westerosblocks.network; -// -//import net.minecraft.server.level.ServerPlayer; -// -//import com.westeroscraft.westerosblocks.WesterosBlocks; -//import net.neoforged.fml.LogicalSide; -// -//import java.util.function.Supplier; -// -//public class ServerMessageHandler { -// -// /** -// * Called when a message is received of the appropriate type. CALLED BY THE -// * NETWORK THREAD, NOT THE SERVER THREAD -// */ -// public static void onMessageReceived(final PTimeMessage message, -// Supplier ctxSupplier) { -// // Get and mark packet handled -// NetworkEvent.Context ctx = ctxSupplier.get(); -// LogicalSide sideReceived = ctx.getDirection().getReceptionSide(); -// ctx.setPacketHandled(true); -// -// if (sideReceived != LogicalSide.SERVER) { -// WesterosBlocks.log.warn("PTimeMessage received on wrong side:" + ctx.getDirection().getReceptionSide()); -// return; -// } -// final ServerPlayer sendingPlayer = ctx.getSender(); -// if (sendingPlayer == null) { -// WesterosBlocks.log.warn("EntityPlayerMP was null when AirstrikeMessageToServer was received"); -// } -// // Enqueue processing to happen on server thread next tick -// ctx.enqueueWork(() -> processMessage(sendingPlayer, message)); -// } -// -// // This message is called from the Client thread. -// // It spawns a number of Particle particles at the target location within a -// // short range around the target location -// private static void processMessage(ServerPlayer sendingPlayer, PTimeMessage message) { -// WesterosBlocks.log.info("Got PTimeMessage"); -// return; -// } -// -// public static boolean isThisProtocolAcceptedByServer(String protocolVersion) { -// return WesterosBlocks.MESSAGE_PROTOCOL_VERSION.equals(protocolVersion); -// } -//} \ No newline at end of file diff --git a/needsported/tileentity/WCFurnaceBlockEntity.java b/needsported/tileentity/WCFurnaceBlockEntity.java deleted file mode 100644 index 1835cc7b95..0000000000 --- a/needsported/tileentity/WCFurnaceBlockEntity.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.westerosblocks.needsported.tileentity; - -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.FurnaceMenu; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.network.chat.Component; - -import com.westeroscraft.westerosblocks.WesterosBlockDef; - -import net.minecraft.core.BlockPos; - -public class WCFurnaceBlockEntity extends AbstractFurnaceBlockEntity { - public static final String ENTITYTYPE = "wcfurnacetileentity"; - public WCFurnaceBlockEntity(BlockPos pos, BlockState bs) { - super(WesterosBlockDef.getBlockEntityType(ENTITYTYPE), pos, bs, RecipeType.SMELTING); - } - - protected Component getDefaultName() { - return Component.literal("container.furnace"); - } - - protected AbstractContainerMenu createMenu(int p_59293_, Inventory p_59294_) { - return new FurnaceMenu(p_59293_, p_59294_, this, this.dataAccess); - } -}