Skip to content

Commit

Permalink
Merge pull request #216 from Ridanisaurus/EEV2-1.19-Dev
Browse files Browse the repository at this point in the history
Eev2 1.19 dev
  • Loading branch information
Ridanisaurus committed Jan 7, 2024
2 parents 71e703f + f0381b6 commit 82aebbd
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 51 deletions.
7 changes: 5 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Emendatus Enigmatica
#### MC 1.19.2 | Version 2.1.5
#### MC 1.19.2 | Version 2.1.6

* Fixed a bug caused by the Enigmatic Hammer's Lang datagen.
* Fixed a bug causing fluids not to appear in JEI and Modded Tanks.
* Fixed a bug where Fortune was not affecting Ore Drops as expected.
* Added support for Uniformed Count drop (similar to Vanilla Redstone).
* Fixed couple unclosed streams causing log spam. (Credit: Kanzaji)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=2.1.5
mod_version=2.1.6
curseforge_id=399630

mc_version=1.19.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,43 +94,79 @@ protected void addTables() {
if (processedType.contains("ore") && material.getProperties().getMaterialType().equals("metal")) {
if (material.getOreDrop().getMax() == 1) {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
specialDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem().asItem()))
);
} else {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
specialCountDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
if (material.getOreDrop().isUniformCount()) {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreUniformedDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
else {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreCountDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
}
}
if (processedType.contains("ore") && material.getProperties().getMaterialType().equals("gem")) {
if (material.getOreDrop().getMax() == 1) {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
specialDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("gem") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.gemMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem().asItem()))
);
} else {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
specialCountDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("gem") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.gemMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
if (material.getOreDrop().isUniformCount()) {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreUniformedDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("gem") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.gemMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
else {
if (material.getOreDrop().isUniformCount()) {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreUniformedDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("gem") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.gemMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
else {
blockLootTable.put(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
oreCountDrop(EERegistrar.oreBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("gem") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.gemMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
}
}
}
if (processedType.contains("ore") && stratum.getSampleStrata()) {
if (material.getOreDrop().getMax() == 1) {
blockLootTable.put(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
specialDrop(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
oreDrop(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem().asItem()))
);
} else {
blockLootTable.put(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
specialCountDrop(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
if (material.getOreDrop().isUniformCount()) {
blockLootTable.put(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
oreUniformedDrop(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
else {
blockLootTable.put(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
oreCountDrop(EERegistrar.oreSampleBlockTable.get(stratum.getId(), material.getId()).get(),
(processedType.contains("raw") && material.getOreDrop().getDrop().isEmpty() ? EERegistrar.rawMap.get(material.getId()).get() : material.getOreDrop().getDefaultItemDropAsItem()),
UniformGenerator.between(material.getOreDrop().getMin(), material.getOreDrop().getMax()))
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -119,7 +118,7 @@ protected static LootTable.Builder dropWhenSilkTouchWithSetCount(Block block, It
);
}

protected static LootTable.Builder specialDrop(Block block, Item item) {
protected static LootTable.Builder oreDrop(Block block, Item item) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(block).when(HAS_SILK_TOUCH).otherwise(LootItem.lootTableItem(item.asItem())
Expand All @@ -129,12 +128,23 @@ protected static LootTable.Builder specialDrop(Block block, Item item) {
);
}

protected static LootTable.Builder specialCountDrop(Block block, ItemLike item, UniformGenerator range) {
protected static LootTable.Builder oreCountDrop(Block block, ItemLike item, UniformGenerator range) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(block).when(HAS_SILK_TOUCH).otherwise(LootItem.lootTableItem(item.asItem())
.apply(SetItemCountFunction.setCount(range))
.apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))
.apply(ApplyExplosionDecay.explosionDecay())
))
);
}

protected static LootTable.Builder oreUniformedDrop(Block block, ItemLike item, UniformGenerator range) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1.0F))
.add(LootItem.lootTableItem(block).when(HAS_SILK_TOUCH).otherwise(LootItem.lootTableItem(item.asItem())
.apply(ApplyBonusCount.addUniformBonusCount(Enchantments.BLOCK_FORTUNE))
.apply(SetItemCountFunction.setCount(range))
.apply(ApplyBonusCount.addUniformBonusCount(Enchantments.BLOCK_FORTUNE))
.apply(ApplyExplosionDecay.explosionDecay())
))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.nio.file.Path;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class GeneratedPack implements PackResources {
Expand Down Expand Up @@ -78,20 +77,20 @@ public Collection<ResourceLocation> getResources(PackType type, String namespace
}

private void getChildResourceLocations(List<ResourceLocation> result, int depth, Predicate<ResourceLocation> filter, Path current, String currentRLNS, String currentRLPath) {
try {
if (!Files.exists(current) || !Files.isDirectory(current)){
return;
}
Stream<Path> list = Files.list(current);
for (Path child : list.collect(Collectors.toList())) {
if (!Files.exists(current) || !Files.isDirectory(current)){
return;
}
try (Stream<Path> list = Files.list(current)) {
for (Path child : list.toList()) {
if (!Files.isDirectory(child)) {
result.add(new ResourceLocation(currentRLNS, currentRLPath + "/" + child.getFileName()));
continue;
ResourceLocation loc = new ResourceLocation(currentRLNS, currentRLPath + "/" + child.getFileName());
if (filter.test(loc)) result.add(loc);
} else {
getChildResourceLocations(result, depth + 1, filter, child, currentRLNS, currentRLPath + "/" + child.getFileName());
}
getChildResourceLocations(result, depth + 1, filter, child, currentRLNS, currentRLPath + "/" + child.getFileName());
}
} catch (IOException ignored) {
ignored.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

Expand All @@ -105,12 +104,8 @@ public boolean hasResource(PackType type, ResourceLocation location) {
@Override
public Set<String> getNamespaces(PackType type) {
Set<String> result = new HashSet<>();
try {
Stream<Path> list = Files.list(path.resolve(type.getDirectory()));
for (Path resultingPath : list.collect(Collectors.toList())) {
result.add(resultingPath.getFileName().toString());
}

try (Stream<Path> list = Files.list(path.resolve(type.getDirectory()))) {
for (Path resultingPath : list.toList()) result.add(resultingPath.getFileName().toString());
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -119,7 +114,7 @@ public Set<String> getNamespaces(PackType type) {

@Nullable
@Override
public <T> T getMetadataSection(MetadataSectionSerializer<T> deserializer) throws IOException {
public <T> T getMetadataSection(MetadataSectionSerializer<T> deserializer) {
JsonObject jsonobject = new JsonObject();
JsonObject packObject = new JsonObject();
packObject.addProperty("pack_format", 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,32 @@ public class MaterialOreDropModel {
public static final Codec<MaterialOreDropModel> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.STRING.optionalFieldOf("drop").forGetter(i -> Optional.ofNullable(i.drop)),
Codec.INT.optionalFieldOf("min").forGetter(i -> Optional.of(i.min)),
Codec.INT.optionalFieldOf("max").forGetter(i -> Optional.of(i.max))
).apply(x, (drop, min, max) -> new MaterialOreDropModel(
Codec.INT.optionalFieldOf("max").forGetter(i -> Optional.of(i.max)),
Codec.BOOL.optionalFieldOf("uniformCount").forGetter(i -> Optional.of(i.uniformCount))
).apply(x, (drop, min, max, uniformCount) -> new MaterialOreDropModel(
drop.orElse(""),
min.orElse(1),
max.orElse(1)
max.orElse(1),
uniformCount.orElse(false)
)));

private final String drop;
private final int min;
private final int max;
private final boolean uniformCount;

public MaterialOreDropModel(String drop, int min, int max) {
public MaterialOreDropModel(String drop, int min, int max, boolean uniformCount) {
this.drop = drop;
this.min = min;
this.max = max;
this.uniformCount = uniformCount;
}

public MaterialOreDropModel() {
this.drop = "";
this.min = 1;
this.max = 1;
this.uniformCount = false;
}

public String getDrop() {
Expand All @@ -71,6 +76,10 @@ public int getMax() {
return max;
}

public boolean isUniformCount() {
return uniformCount;
}

public ItemLike getDefaultItemDropAsItem() {
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(drop));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class ColorHelper {
public static int HEXtoDEC(String hex) {
return Integer.parseInt(hex, 16);
return Integer.parseInt(hex, 16) | 0xFF000000;
}

public static Color HEXtoColor(String hex) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ issueTrackerURL="https://github.com/Ridanisaurus/Emendatus-Enigmatica/issues"

[[mods]]
modId="emendatusenigmatica"
version="1.19.2-2.1.5"
version="1.19.2-2.1.6"
displayName="Emendatus Enigmatica"
displayURL="https://github.com/Ridanisaurus/Emendatus-Enigmatica"
logoFile= "ee_logo.png"
Expand Down

0 comments on commit 82aebbd

Please sign in to comment.