Bump forge, reorganize gog seed inject so the table is separate from the loot modifier

This commit is contained in:
Vincent Lee committed 2020-07-14 10:15:09 -05:00
1 parent 4b8d5c2a33
commit e71a62f0f8
11 files changed
+79 -78

No files matched your search

@@ -22,11 +22,4 @@ public class BlockModPane extends PaneBlock {
public BlockModPane(Properties props) {
super(props);
}
@Override
public boolean canBeConnectedTo(BlockState state, IBlockReader world, BlockPos pos, Direction facing) {
Block block = world.getBlockState(pos.offset(facing)).getBlock();
return block == ModBlocks.elfGlass || block == ModBlocks.manaGlass || block == ModBlocks.bifrostPerm
|| super.canBeConnectedTo(state, world, pos, facing);
}
}
@@ -126,11 +126,10 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower {
int range = getRange();
int rangeY = getRangeY();
BlockStateMatcher matcher = BlockStateMatcher.forBlock(Blocks.STONE);
for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-range, -rangeY, -range),
getEffectivePos().add(range, rangeY, range))) {
BlockState state = getWorld().getBlockState(pos);
if (state.getBlock().isReplaceableOreGen(state, getWorld(), pos, matcher)) {
if (state.getBlock() == Blocks.STONE) {
possibleCoords.add(pos.toImmutable());
}
}
@@ -107,7 +107,7 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE),
getEffectivePos().add(RANGE, RANGE_Y, RANGE))) {
BlockState state = getWorld().getBlockState(pos);
if (state.getBlock().isReplaceableOreGen(state, getWorld(), pos, getReplaceMatcher())) {
if (getReplaceMatcher().test(state)) {
possibleCoords.add(pos.toImmutable());
}
}
@@ -8,17 +8,14 @@
*/
package vazkii.botania.common.core.loot;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.conditions.ILootCondition;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.loot.LootModifier;
@@ -26,31 +23,30 @@ import javax.annotation.Nonnull;
import java.util.List;
public class AddRandomItemModifier extends LootModifier {
private final List<ItemStack> items;
/**
* Global loot modifier that calls another loot table and appends all of the yielded stacks to the existing loot
*/
public class CallTableModifier extends LootModifier {
private final ResourceLocation tableId;
protected AddRandomItemModifier(ILootCondition[] conditionsIn, List<ItemStack> items) {
protected CallTableModifier(ILootCondition[] conditionsIn, ResourceLocation table) {
super(conditionsIn);
this.items = items;
this.tableId = table;
}
@Nonnull
@Override
protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
ItemStack stack = items.get(context.getRandom().nextInt(items.size()));
generatedLoot.add(stack.copy());
LootTable table = context.getWorld().getServer().getLootTableManager().getLootTableFromLocation(tableId);
table.generate(context, generatedLoot::add);
return generatedLoot;
}
public static class Serializer extends GlobalLootModifierSerializer<AddRandomItemModifier> {
public static class Serializer extends GlobalLootModifierSerializer<CallTableModifier> {
@Override
public AddRandomItemModifier read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) {
JsonArray items = JSONUtils.getJsonArray(object, "items");
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
for (JsonElement item : items) {
builder.add(CraftingHelper.getItemStack(item.getAsJsonObject(), true));
}
return new AddRandomItemModifier(ailootcondition, builder.build());
public CallTableModifier read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) {
String table = JSONUtils.getString(object, "table");
return new CallTableModifier(ailootcondition, new ResourceLocation(table));
}
}
}
@@ -35,7 +35,7 @@ public class DisposeModifier extends LootModifier {
public static void register(RegistryEvent.Register<GlobalLootModifierSerializer<?>> evt) {
evt.getRegistry().register(new Serializer().setRegistryName(prefix("dispose")));
evt.getRegistry().register(new AddRandomItemModifier.Serializer().setRegistryName(prefix("add_item")));
evt.getRegistry().register(new CallTableModifier.Serializer().setRegistryName(prefix("call_table")));
}
@Nonnull
@@ -72,8 +72,7 @@ public class EntityEnderAirBottle extends ThrowableEntity implements IRendersAsI
for (BlockPos bPos : BlockPos.getAllInBoxMutable(pos.add(-range, -rangeY, -range),
pos.add(range, rangeY, range))) {
BlockState state = world.getBlockState(bPos);
Block block = state.getBlock();
if (block.isReplaceableOreGen(state, world, bPos, BlockStateMatcher.forBlock(Blocks.STONE))) {
if (state.getBlock() == Blocks.STONE) {
possibleCoords.add(bPos.toImmutable());
}
}