Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Merge branch 'dev/1.15' into release/1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviathevampire committed Jun 9, 2020
2 parents 4ff1571 + f7161e1 commit 0a62ac4
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 78 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ 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 = 17
beta_version = 18

changelog = Fix some issue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -46,16 +44,6 @@ public class RandomlyAddingAnythingClient implements ClientModInitializer {
private static final Map<Identifier, Map.Entry<DimensionMaterial, RAABlockItem.BlockType>> 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);
Expand Down Expand Up @@ -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")));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,31 +44,31 @@ public boolean generate(IWorld world, ChunkGenerator<? extends ChunkGeneratorCon
JsonObject fossil6 = null;
JsonObject fossil7 = null;
try {
Resource towerBasePath = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil01.json"));
Resource towerBasePath = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil01.json"));
fossil1 = new Gson().fromJson(new InputStreamReader(towerBasePath.getInputStream()), JsonObject.class);
JsonObject finalTowerBase = fossil1;

Resource towerWallsPath = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil02.json"));
Resource towerWallsPath = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil02.json"));
fossil2 = new Gson().fromJson(new InputStreamReader(towerWallsPath.getInputStream()), JsonObject.class);
JsonObject finalTowerWalls = fossil2;

Resource towerStairsPath = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil03.json"));
Resource towerStairsPath = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil03.json"));
fossil3 = new Gson().fromJson(new InputStreamReader(towerStairsPath.getInputStream()), JsonObject.class);
JsonObject finalTowerStairs = fossil3;

Resource towerLaddersPath = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil04.json"));
Resource towerLaddersPath = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil04.json"));
fossil4 = new Gson().fromJson(new InputStreamReader(towerLaddersPath.getInputStream()), JsonObject.class);
JsonObject finalTowerLadders = fossil4;

Resource towerPillarPath = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil05.json"));
Resource towerPillarPath = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil05.json"));
fossil5 = new Gson().fromJson(new InputStreamReader(towerPillarPath.getInputStream()), JsonObject.class);
JsonObject finalTowerPillar = fossil5;

Resource fossil6Path = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil06.json"));
Resource fossil6Path = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil06.json"));
fossil6 = new Gson().fromJson(new InputStreamReader(fossil6Path.getInputStream()), JsonObject.class);
JsonObject finalFossil6 = fossil6;

Resource fossil7Path = MinecraftClient.getInstance().getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil07.json"));
Resource fossil7Path = ((ServerWorld)world.getWorld()).getServer().getDataManager().getResource(new Identifier("raa:structures/fossils/fossil07.json"));
fossil7 = new Gson().fromJson(new InputStreamReader(fossil7Path.getInputStream()), JsonObject.class);
JsonObject finalFossil7 = fossil7;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import io.github.vampirestudios.raa.utils.Rands;
import io.github.vampirestudios.raa.utils.Utils;
import io.github.vampirestudios.raa.utils.WorldStructureManipulation;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.loot.LootTables;
import net.minecraft.resource.Resource;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
Expand All @@ -23,20 +20,17 @@
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.function.Function;

public class TowerFeature extends Feature<DefaultFeatureConfig> {
private JsonConverter converter = new JsonConverter();
private final JsonConverter converter = new JsonConverter();
private Map<String, JsonConverter.StructureValues> structures;

public TowerFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function) {
Expand All @@ -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<String, String> currBlockProp = piece.getBlockProperties().get(piece.getBlockStates().get(i));
Map<String, String> currBlockProp = piece.getBlockProperties().get(piece.getBlockStates().get(i));

//Rotate
currBlockPos = WorldStructureManipulation.rotatePos(rotation, currBlockPos, piece.getSize());
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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");
Expand Down Expand Up @@ -194,7 +188,7 @@ private static void placeRoom(IWorld world, BlockPos pos, Map<String, JsonConver
"0 0 0, 0 0 1; 0 0 0; 0 0 0; 0 0 0; 0 0 0; " +
"0 0 0, 0 0 1; 0 1 0; 0 0 0, 0 1 0; 0 0 0, 0 1 0";
String centerPropsString = "facing:SOUTH type:SINGLE, NULL; facing:UP; facing:SOUTH; NULL; NULL, NULL; " +
"facing:SOUTH type:SINGLE, NULL; west:TRUE east:TRUE; facing:WEST; face:FLOOR facing:WEST; armor:ALL; " +
"facing:SOUTH type:SINGLE, NULL; west:TRUE east:TRUE; facing:WEST; face:FLOOR facing:WEST; head:5 chest:5 legs:5 feet:5 weapon:4; " +
"facing:SOUTH type:SINGLE, NULL; attachment:SINGLE_WALL facing:NORTH; distance:0, NULL; distance:0, NULL";

List<List<String>> cornerBlocks = new ArrayList<>();
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/github/vampirestudios/raa/utils/JsonConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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);
Expand All @@ -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);
});
}
Expand All @@ -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));
});
}

Expand Down
Loading

0 comments on commit 0a62ac4

Please sign in to comment.