From 42111db7f49759bf2b99efb2d3e19bd60fa3a2fc Mon Sep 17 00:00:00 2001 From: oliviathevampire Date: Mon, 6 Apr 2020 17:45:30 +0200 Subject: [PATCH 1/3] fixed structures crashing with turkish --- .../raa/utils/JsonConverter.java | 20 +++++++++---------- .../raa/utils/WorldStructureManipulation.java | 14 ++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/github/vampirestudios/raa/utils/JsonConverter.java b/src/main/java/io/github/vampirestudios/raa/utils/JsonConverter.java index a6811549..e6c95cf9 100644 --- a/src/main/java/io/github/vampirestudios/raa/utils/JsonConverter.java +++ b/src/main/java/io/github/vampirestudios/raa/utils/JsonConverter.java @@ -31,7 +31,7 @@ public StructureValues loadStructure(JsonObject structureJson) { JsonArray array = JsonHelper.getArray(structureJsonObject, "value"); array.forEach(jsonElement -> { JsonObject jsonObject = jsonElement.getAsJsonObject(); - String name = JsonHelper.getString(jsonObject, "name"); + String name = JsonHelper.getString(jsonObject, "name").toLowerCase(Locale.ENGLISH); JsonObject valueArray = JsonHelper.getObject(jsonObject, "value"); if (name.equals("size")) { @@ -51,7 +51,7 @@ public StructureValues loadStructure(JsonObject structureJson) { JsonArray blockProperties = jsonElement1.getAsJsonArray(); blockProperties.forEach(jsonElement2 -> { JsonObject blockProperty = jsonElement2.getAsJsonObject(); - String propertyName = JsonHelper.getString(blockProperty, "name"); + String propertyName = JsonHelper.getString(blockProperty, "name").toLowerCase(Locale.ENGLISH); if (propertyName.equals("state")) { int state = JsonHelper.getInt(blockProperty, "value"); structure.setBlockStates(state); @@ -76,18 +76,18 @@ public StructureValues loadStructure(JsonObject structureJson) { JsonArray paletteProperties = jsonElement1.getAsJsonArray(); paletteProperties.forEach(jsonElement2 -> { JsonObject paletteProperty = jsonElement2.getAsJsonObject(); - String propertyName = JsonHelper.getString(paletteProperty, "name"); - if (propertyName.equals("Name")) { + String propertyName = JsonHelper.getString(paletteProperty, "name").toLowerCase(Locale.ENGLISH); + if (propertyName.equals("name")) { structure.setBlockProperties(blockPropertyMap); - String blockId = JsonHelper.getString(paletteProperty, "value"); + String blockId = JsonHelper.getString(paletteProperty, "value").toLowerCase(Locale.ENGLISH); structure.setBlockTypes(blockId); } - if (propertyName.equals("Properties")) { + if (propertyName.equals("properties")) { JsonArray properties = JsonHelper.getArray(paletteProperty, "value"); properties.forEach(jsonElement3 -> { JsonObject blockProperties = jsonElement3.getAsJsonObject(); - String blockPropertyName = JsonHelper.getString(blockProperties, "name"); - String propertyValue = JsonHelper.getString(blockProperties, "value"); + String blockPropertyName = JsonHelper.getString(blockProperties, "name").toLowerCase(Locale.ENGLISH); + String propertyValue = JsonHelper.getString(blockProperties, "value").toLowerCase(Locale.ENGLISH); blockPropertyMap.put(blockPropertyName, propertyValue); }); } @@ -114,8 +114,8 @@ public StructureValues loadStructure(JsonObject structureJson) { if (JsonHelper.hasArray(structureJson, "palette")) { JsonArray blocksArray = JsonHelper.getArray(structureJson, "palette"); blocksArray.forEach(jsonElement -> { - Identifier identifier = Identifier.tryParse(jsonElement.getAsJsonObject().get("name").getAsString()); - structure.setBlockTypes(Objects.requireNonNull(identifier).toString()); + Identifier identifier = Identifier.tryParse(jsonElement.getAsJsonObject().get("name").getAsString().toLowerCase(Locale.ENGLISH)); + structure.setBlockTypes(Objects.requireNonNull(identifier).toString().toLowerCase(Locale.ENGLISH)); }); } diff --git a/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java b/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java index 771418f2..310fd5bf 100644 --- a/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java +++ b/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java @@ -175,21 +175,21 @@ public static void placeBlock(IWorld world, BlockPos pos, String block, Map Date: Wed, 8 Apr 2020 22:36:37 +0200 Subject: [PATCH 2/3] fixed some bugs - Fixed storage blocks crashing because they use dimension color on other layers - Fixed fossiles causing crashes on servers --- gradle.properties | 2 +- .../raa/RandomlyAddingAnythingClient.java | 15 +---- .../raa/client/DimensionalOreBakedModel.java | 8 +-- .../raa/generation/feature/FossilFeature.java | 16 ++--- .../raa/generation/feature/TowerFeature.java | 20 +++--- .../raa/utils/WorldStructureManipulation.java | 61 +++++++++++++------ 6 files changed, 62 insertions(+), 60 deletions(-) diff --git a/gradle.properties b/gradle.properties index e2ef4f8b..ec636628 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ fabric_version=0.5.1+build.294-1.15 mod_version = 2.1.2 maven_group = io.github.vampirestudios.raa archives_base_name = raa -beta_version = 17 +beta_version = 18 changelog = Fix some issue diff --git a/src/main/java/io/github/vampirestudios/raa/RandomlyAddingAnythingClient.java b/src/main/java/io/github/vampirestudios/raa/RandomlyAddingAnythingClient.java index 2bd80015..c00d9f7e 100644 --- a/src/main/java/io/github/vampirestudios/raa/RandomlyAddingAnythingClient.java +++ b/src/main/java/io/github/vampirestudios/raa/RandomlyAddingAnythingClient.java @@ -20,7 +20,6 @@ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.impl.client.rendering.ColorProviderRegistryImpl; import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.model.BakedModel; @@ -30,7 +29,6 @@ import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.SpriteIdentifier; -import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.util.Identifier; @@ -46,16 +44,6 @@ public class RandomlyAddingAnythingClient implements ClientModInitializer { private static final Map> DIMENSION_MATERIAL_ORE_IDENTIFIERS = new HashMap<>(); public static void initColoring() { - ColorProviderRegistry.ITEM.register((stack, layer) -> { - if (MinecraftClient.getInstance().world != null) { - return MinecraftClient.getInstance().world.getBiomeAccess().getBiome(MinecraftClient.getInstance().player.getBlockPos()) - .getGrassColorAt(MinecraftClient.getInstance().player.getBlockPos().getX(), MinecraftClient.getInstance().player.getBlockPos().getZ()); - } else { - BlockState blockState_1 = ((BlockItem) stack.getItem()).getBlock().getDefaultState(); - return MinecraftClient.getInstance().getBlockColorMap().getColor(blockState_1, MinecraftClient.getInstance().world, MinecraftClient.getInstance().player.getBlockPos()); - } - }, Items.GRASS_BLOCK); - ColorProviderRegistry.ITEM.register((stack, var2) -> MinecraftClient.getInstance().world.getBiomeAccess().getBiome(Objects.requireNonNull(MinecraftClient.getInstance().player).getBlockPos()).getFoliageColor(), Items.OAK_LEAVES, Items.SPRUCE_LEAVES, Items.BIRCH_LEAVES, Items.JUNGLE_LEAVES, Items.ACACIA_LEAVES, Items.DARK_OAK_LEAVES, Items.FERN, Items.LARGE_FERN, Items.GRASS, Items.TALL_GRASS, Items.VINE); @@ -511,8 +499,7 @@ public void onInitializeClient() { Registry.BLOCK.get(Utils.appendToPath(id, "_block")), Registry.ITEM.get(Utils.appendToPath(id, "_shears")) ); - ColorProviderRegistry.BLOCK.register((blockstate, blockview, blockpos, layer) -> - layer == 0 ? material.getDimensionData().getDimensionColorPalette().getStoneColor() : material.getColor(), + ColorProviderRegistry.BLOCK.register((blockstate, blockview, blockpos, layer) -> material.getColor(), Registry.BLOCK.get(Utils.appendToPath(id, "_block"))); }); diff --git a/src/main/java/io/github/vampirestudios/raa/client/DimensionalOreBakedModel.java b/src/main/java/io/github/vampirestudios/raa/client/DimensionalOreBakedModel.java index accc997d..09fcd3da 100644 --- a/src/main/java/io/github/vampirestudios/raa/client/DimensionalOreBakedModel.java +++ b/src/main/java/io/github/vampirestudios/raa/client/DimensionalOreBakedModel.java @@ -28,6 +28,7 @@ import net.minecraft.world.World; import java.util.Collections; +import java.util.Objects; import java.util.Random; import java.util.function.Supplier; @@ -50,14 +51,13 @@ private Mesh mesh() { MeshBuilder builder = renderer.meshBuilder(); QuadEmitter emitter = builder.getEmitter(); - Identifier diemnsionId = new Identifier(dimensionMaterial.getId().getNamespace(), dimensionMaterial.getId().getPath().split("_")[0]); - DimensionData dimensionData = Dimensions.DIMENSIONS.get(diemnsionId); + Identifier dimensionIdentifier = new Identifier(dimensionMaterial.getId().getNamespace(), dimensionMaterial.getId().getPath().split("_")[0]); + DimensionData dimensionData = Dimensions.DIMENSIONS.get(dimensionIdentifier); RenderMaterial mat = renderer.materialFinder().disableAo(0, false).blendMode(0, BlendMode.CUTOUT_MIPPED).disableDiffuse(0, false).find(); - int color = dimensionData.getDimensionColorPalette().getStoneColor(); + int color = Objects.requireNonNull(dimensionData).getDimensionColorPalette().getStoneColor(); Sprite sprite = MinecraftClient.getInstance().getSpriteAtlas(SpriteAtlasTexture.BLOCK_ATLAS_TEX) .apply(dimensionData.getTexturesInformation().getStoneTexture()); -// System.out.println(sprite.getId().toString()); emitter.square(Direction.SOUTH, 0, 0, 1, 1, 0) .material(mat) diff --git a/src/main/java/io/github/vampirestudios/raa/generation/feature/FossilFeature.java b/src/main/java/io/github/vampirestudios/raa/generation/feature/FossilFeature.java index 65ac3de6..f4d09f80 100644 --- a/src/main/java/io/github/vampirestudios/raa/generation/feature/FossilFeature.java +++ b/src/main/java/io/github/vampirestudios/raa/generation/feature/FossilFeature.java @@ -8,8 +8,8 @@ import io.github.vampirestudios.raa.utils.Utils; import io.github.vampirestudios.raa.utils.WorldStructureManipulation; import net.minecraft.block.Blocks; -import net.minecraft.client.MinecraftClient; import net.minecraft.resource.Resource; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; @@ -44,31 +44,31 @@ public boolean generate(IWorld world, ChunkGenerator { - private JsonConverter converter = new JsonConverter(); + private final JsonConverter converter = new JsonConverter(); private Map structures; public TowerFeature(Function, ? extends DefaultFeatureConfig> function) { @@ -47,7 +41,7 @@ private static void placePiece(IWorld world, BlockPos pos, int rotation, JsonCon for (int i = 0; i < piece.getBlockPositions().size(); i++) { Vec3i currBlockPos = piece.getBlockPositions().get(i); String currBlockType = piece.getBlockTypes().get(piece.getBlockStates().get(i)); -// Map currBlockProp = piece.getBlockProperties().get(piece.getBlockStates().get(i)); + Map currBlockProp = piece.getBlockProperties().get(piece.getBlockStates().get(i)); //Rotate currBlockPos = WorldStructureManipulation.rotatePos(rotation, currBlockPos, piece.getSize()); @@ -59,9 +53,9 @@ private static void placePiece(IWorld world, BlockPos pos, int rotation, JsonCon if (currBlockType.equals("minecraft:stone_bricks")) { WorldStructureManipulation.placeBlock(world, pos.add(currBlockPos), "raa:" + (world.getDimension().getType().getSuffix()).substring(4) + "_stone_bricks", new HashMap<>(), rotation); } else if (currBlockType.equals("minecraft:ladder")) { - WorldStructureManipulation.placeBlock(world, pos.add(currBlockPos), currBlockType, new HashMap<>(), 4 - rotation); + WorldStructureManipulation.placeBlock(world, pos.add(currBlockPos), currBlockType, currBlockProp, (6 - rotation) % 4); } else { - WorldStructureManipulation.placeBlock(world, pos.add(currBlockPos), currBlockType, new HashMap<>(), rotation); + WorldStructureManipulation.placeBlock(world, pos.add(currBlockPos), currBlockType, currBlockProp, rotation); } } } @@ -111,7 +105,7 @@ private static void placeDecoration(IWorld world, BlockPos pos, int rotation, Li } else { standRotation = 45f; } - WorldStructureManipulation.spawnEntity(world, pos.add(currPos), "minecraft:" + currBlock, standRotation); + WorldStructureManipulation.spawnEntity(world, pos.add(currPos), "minecraft:armor_stand", currProps, standRotation % 360 - 180); //Spawn block } else { @@ -123,7 +117,7 @@ private static void placeDecoration(IWorld world, BlockPos pos, int rotation, Li "oak_sapling", "lily_of_the_valley", "jungle_sapling", "fern", "dead_bush", "dark_oak_sapling", "dandelion", "cactus", "brown_mushroom", "blue_orchid", "birch_sapling", "bamboo", "azure_bluet", "allium", "acacia_sapling", "cornflower"}; currBlock += plants[new Random().nextInt(plants.length)]; - } else if (currBlock.equals("iron_bars")) { + } else if (currBlock.equals("iron_bars") && currProps.get("west") == null) { if (x == z && y == 0) { currProps.put("north", "TRUE"); currProps.put("west", "TRUE"); @@ -194,7 +188,7 @@ private static void placeRoom(IWorld world, BlockPos pos, Map> cornerBlocks = new ArrayList<>(); diff --git a/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java b/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java index 310fd5bf..6bdc1b0a 100644 --- a/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java +++ b/src/main/java/io/github/vampirestudios/raa/utils/WorldStructureManipulation.java @@ -148,17 +148,21 @@ public static void placeBlock(IWorld world, BlockPos pos, String block, Map directions = Arrays.asList("FALSE", "FALSE", "FALSE", "FALSE"); - String axis = "x"; + if (properties.get("facing") != null) { facing = properties.get("facing"); if (!facing.equals("UP") && !facing.equals("DOWN")) { facing = rotateDir(rotation, facing); } } + + List directions = Arrays.asList("FALSE", "FALSE", "FALSE", "FALSE"); if (properties.get("north") != null || properties.get("west") != null || properties.get("south") != null || properties.get("east") != null) { directions = rotateWall(rotation, Arrays.asList(properties.get("north"), properties.get("west"), properties.get("south"), properties.get("east"))); } + + //Rotate axis property + String axis = "x"; if (properties.get("axis") != null) { axis = properties.get("axis"); axis = (rotation % 2 == 0) ? axis : (axis.equals("x")) ? "z" : (axis.equals("z")) ? "x" : axis; @@ -172,7 +176,7 @@ public static void placeBlock(IWorld world, BlockPos pos, String block, Map properties, float rotation) { if (entity.equals("minecraft:armor_stand")) { Entity armorStand = EntityType.ARMOR_STAND.create(world.getWorld()); @@ -271,12 +273,31 @@ public static void spawnEntity(IWorld world, BlockPos pos, String entity, float new ItemStack(Items.IRON_BOOTS), new ItemStack(Items.DIAMOND_BOOTS) ); + List weapons = ImmutableList.of( + new ItemStack(Items.STONE_SWORD), + new ItemStack(Items.GOLDEN_SWORD), + new ItemStack(Items.IRON_SWORD), + new ItemStack(Items.DIAMOND_SWORD) + ); Objects.requireNonNull(armorStand).refreshPositionAndAngles(pos, rotation, 0f); + + if (properties.get("head") != null && !Rands.chance(4)) { + armorStand.equipStack(EquipmentSlot.HEAD, helmets.get(Rands.randInt(Integer.parseInt(properties.get("head"))))); + } + if (properties.get("chest") != null && !Rands.chance(4)) { + armorStand.equipStack(EquipmentSlot.CHEST, chestplates.get(Rands.randInt(Integer.parseInt(properties.get("chest"))))); + } + if (properties.get("legs") != null && !Rands.chance(4)) { + armorStand.equipStack(EquipmentSlot.LEGS, leggings.get(Rands.randInt(Integer.parseInt(properties.get("legs"))))); + } + if (properties.get("feet") != null && !Rands.chance(4)) { + armorStand.equipStack(EquipmentSlot.FEET, boots.get(Rands.randInt(Integer.parseInt(properties.get("feet"))))); + } + if (properties.get("weapon") != null && !Rands.chance(3)) { + armorStand.equipStack(EquipmentSlot.MAINHAND, weapons.get(Rands.randInt(Integer.parseInt(properties.get("weapon"))))); + } + world.spawnEntity(armorStand); - armorStand.equipStack(EquipmentSlot.HEAD, Rands.list(helmets)); - armorStand.equipStack(EquipmentSlot.CHEST, Rands.list(chestplates)); - armorStand.equipStack(EquipmentSlot.LEGS, Rands.list(leggings)); - armorStand.equipStack(EquipmentSlot.FEET, Rands.list(boots)); } } From f7161e117e09247b86674036864df2a6aeb7046b Mon Sep 17 00:00:00 2001 From: oliviathevampire Date: Tue, 9 Jun 2020 18:59:24 +0200 Subject: [PATCH 3/3] updated version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ec636628..68ac4b45 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ loader_version=0.7.9+build.190 fabric_version=0.5.1+build.294-1.15 # Mod Properties -mod_version = 2.1.2 +mod_version = 2.1.3 maven_group = io.github.vampirestudios.raa archives_base_name = raa beta_version = 18