Get things running, fix forge/mc dependencies and extendo grip

This commit is contained in:
tterrag 2020-10-03 17:12:32 -04:00
parent 3be810a9eb
commit e5179598e3
9 changed files with 74 additions and 71 deletions

View file

@ -36,6 +36,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@ -81,6 +82,7 @@ public class Create {
AllMovementBehaviours.register(); AllMovementBehaviours.register();
modEventBus.addListener(Create::init); modEventBus.addListener(Create::init);
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, Create::onBiomeLoad);
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register); modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register);
modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register); modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register);
modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register); modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register);
@ -107,7 +109,10 @@ public class Create {
AllPackets.registerPackets(); AllPackets.registerPackets();
AllTriggers.register(); AllTriggers.register();
AllWorldFeatures.reload(); }
public static void onBiomeLoad(BiomeLoadingEvent event) {
AllWorldFeatures.reload(event);
} }
public static CreateRegistrate registrate() { public static CreateRegistrate registrate() {

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.curiosities.tools;
import java.util.UUID; import java.util.UUID;
import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
@ -22,7 +22,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.Rarity; import net.minecraft.item.Rarity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.LazyValue;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -41,22 +41,23 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@EventBusSubscriber @EventBusSubscriber
public class ExtendoGripItem extends Item { public class ExtendoGripItem extends Item {
static Multimap<Attribute, AttributeModifier> rangeModifier; static LazyValue<Multimap<Attribute, AttributeModifier>> rangeModifier =
static Multimap<Attribute, AttributeModifier> doubleRangeModifier; new LazyValue<Multimap<Attribute, AttributeModifier>>(() ->
// Holding an ExtendoGrip
ImmutableMultimap.of(
ForgeMod.REACH_DISTANCE.get(),
new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 3,
AttributeModifier.Operation.ADDITION))
);
static { static LazyValue<Multimap<Attribute, AttributeModifier>> doubleRangeModifier =
// Holding an ExtendoGrip new LazyValue<Multimap<Attribute, AttributeModifier>>(() ->
rangeModifier = HashMultimap.create(); // Holding two ExtendoGrips o.O
rangeModifier.put(ForgeMod.REACH_DISTANCE.get(), ImmutableMultimap.of(
new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 3, ForgeMod.REACH_DISTANCE.get(),
AttributeModifier.Operation.ADDITION)); new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 5,
AttributeModifier.Operation.ADDITION))
// Holding two ExtendoGrips o.O );
doubleRangeModifier = HashMultimap.create();
doubleRangeModifier.put(ForgeMod.REACH_DISTANCE.get(),
new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 5,
AttributeModifier.Operation.ADDITION));
}
public ExtendoGripItem(Properties properties) { public ExtendoGripItem(Properties properties) {
super(properties.maxStackSize(1) super(properties.maxStackSize(1)
@ -85,13 +86,13 @@ public class ExtendoGripItem extends Item {
if (holdingExtendo != wasHoldingExtendo) { if (holdingExtendo != wasHoldingExtendo) {
if (!holdingExtendo) { if (!holdingExtendo) {
player.getAttributes().removeModifiers(rangeModifier); player.getAttributes().removeModifiers(rangeModifier.getValue());
persistentData.remove(marker); persistentData.remove(marker);
} else { } else {
if (player instanceof ServerPlayerEntity) if (player instanceof ServerPlayerEntity)
AllTriggers.EXTENDO.trigger((ServerPlayerEntity) player); AllTriggers.EXTENDO.trigger((ServerPlayerEntity) player);
player.getAttributes() player.getAttributes()
.addTemporaryModifiers(rangeModifier); .addTemporaryModifiers(rangeModifier.getValue());
persistentData.putBoolean(marker, true); persistentData.putBoolean(marker, true);
} }
} }
@ -99,13 +100,13 @@ public class ExtendoGripItem extends Item {
if (holdingDualExtendo != wasHoldingDualExtendo) { if (holdingDualExtendo != wasHoldingDualExtendo) {
if (!holdingDualExtendo) { if (!holdingDualExtendo) {
player.getAttributes() player.getAttributes()
.removeModifiers(doubleRangeModifier); .removeModifiers(doubleRangeModifier.getValue());
persistentData.remove(dualMarker); persistentData.remove(dualMarker);
} else { } else {
if (player instanceof ServerPlayerEntity) if (player instanceof ServerPlayerEntity)
AllTriggers.GIGA_EXTENDO.trigger((ServerPlayerEntity) player); AllTriggers.GIGA_EXTENDO.trigger((ServerPlayerEntity) player);
player.getAttributes() player.getAttributes()
.addTemporaryModifiers(doubleRangeModifier); .addTemporaryModifiers(doubleRangeModifier.getValue());
persistentData.putBoolean(dualMarker, true); persistentData.putBoolean(dualMarker, true);
} }
} }
@ -147,7 +148,6 @@ public class ExtendoGripItem extends Item {
mc.pointedEntity = entity1; mc.pointedEntity = entity1;
} }
} }
} }
@SubscribeEvent @SubscribeEvent

View file

@ -14,18 +14,6 @@ public class CWorldGen extends ConfigBase {
AllWorldFeatures.fillConfig(builder); AllWorldFeatures.fillConfig(builder);
} }
@Override
public void onReload() {
AllWorldFeatures.reload();
super.onReload();
}
@Override
public void onLoad() {
AllWorldFeatures.reload();
super.onLoad();
}
@Override @Override
public String getName() { public String getName() {
return "worldgen.v" + AllWorldFeatures.forcedUpdateVersion; return "worldgen.v" + AllWorldFeatures.forcedUpdateVersion;

View file

@ -17,6 +17,7 @@ import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.Biome.Category; import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
public enum AllWorldFeatures { public enum AllWorldFeatures {
@ -43,32 +44,24 @@ public enum AllWorldFeatures {
public static final int forcedUpdateVersion = 1; public static final int forcedUpdateVersion = 1;
public IFeature feature; public IFeature feature;
private Map<Biome, ConfiguredFeature<?, ?>> featureInstances;
AllWorldFeatures(IFeature feature) { AllWorldFeatures(IFeature feature) {
this.feature = feature; this.feature = feature;
this.featureInstances = new HashMap<>();
this.feature.setId(Lang.asId(name())); this.feature.setId(Lang.asId(name()));
} }
public static void reload() { public static void reload(BiomeLoadingEvent event) {
for (AllWorldFeatures entry : AllWorldFeatures.values()) { for (AllWorldFeatures entry : AllWorldFeatures.values()) {
for (Biome biome : ForgeRegistries.BIOMES) { if (event.getName() == Biomes.THE_VOID.getRegistryName())
continue;
if (event.getCategory() == Category.NETHER)
continue;
if (biome.getRegistryName() == Biomes.THE_VOID.getRegistryName()) Optional<ConfiguredFeature<?, ?>> createFeature = entry.feature.createFeature(event);
continue; if (!createFeature.isPresent())
if (biome.getCategory() == Category.NETHER) continue;
continue;
if (entry.featureInstances.containsKey(biome)) event.getGeneration().feature(entry.feature.getGenerationStage(), createFeature.get());
biome.getFeatures(entry.feature.getGenerationStage()).remove(entry.featureInstances.remove(biome));
Optional<ConfiguredFeature<?, ?>> createFeature = entry.feature.createFeature(biome);
if (!createFeature.isPresent())
continue;
entry.featureInstances.put(biome, createFeature.get());
biome.addFeature(entry.feature.getGenerationStage(), createFeature.get());
}
} }
// // Debug contained ore features // // Debug contained ore features

View file

@ -5,10 +5,10 @@ import org.apache.commons.lang3.tuple.Pair;
import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.world.gen.placement.ChanceRangeConfig; import net.minecraft.world.gen.placement.ChanceConfig;
import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.gen.placement.Placement;
public class ChanceOreFeature extends OreFeature<ChanceRangeConfig> { public class ChanceOreFeature extends OreFeature<ChanceConfig> {
private ConfigFloat clusterChance; private ConfigFloat clusterChance;
@ -23,9 +23,9 @@ public class ChanceOreFeature extends OreFeature<ChanceRangeConfig> {
} }
@Override @Override
protected Pair<Placement<ChanceRangeConfig>, ChanceRangeConfig> getPlacement() { protected Pair<Placement<ChanceConfig>, ChanceConfig> getPlacement() {
return Pair.of(Placement.CHANCE_RANGE, return Pair.of(Placement.CHANCE,
new ChanceRangeConfig(clusterChance.getF(), minHeight.get(), 0, maxHeight.get() - minHeight.get())); // TODO 1.16 worldgen verify this
new ChanceConfig((int) (1 / clusterChance.getF())));
} }
} }

View file

@ -1,14 +1,19 @@
package com.simibubi.create.foundation.worldgen; package com.simibubi.create.foundation.worldgen;
import java.util.Optional;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.world.gen.placement.CountRangeConfig; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.placement.NoPlacementConfig;
import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.event.world.BiomeLoadingEvent;
public class CountedOreFeature extends OreFeature<CountRangeConfig> { public class CountedOreFeature extends OreFeature<NoPlacementConfig> {
private ConfigInt clusterCount; private ConfigInt clusterCount;
@ -23,9 +28,14 @@ public class CountedOreFeature extends OreFeature<CountRangeConfig> {
} }
@Override @Override
protected Pair<Placement<CountRangeConfig>, CountRangeConfig> getPlacement() { protected Pair<Placement<NoPlacementConfig>, NoPlacementConfig> getPlacement() {
return Pair.of(Placement.COUNT_RANGE, return Pair.of(Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG);
new CountRangeConfig(clusterCount.get(), minHeight.get(), 0, maxHeight.get() - minHeight.get()));
} }
@Override
public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome) {
return super.createFeature(biome)
// TODO 1.16 worldgen verify this
.map(cf -> cf.repeat(clusterCount.get()));
}
} }

View file

@ -2,10 +2,10 @@ package com.simibubi.create.foundation.worldgen;
import java.util.Optional; import java.util.Optional;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage.Decoration; import net.minecraft.world.gen.GenerationStage.Decoration;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.world.BiomeLoadingEvent;
public interface IFeature { public interface IFeature {
@ -13,7 +13,7 @@ public interface IFeature {
public void addToConfig(ForgeConfigSpec.Builder builder); public void addToConfig(ForgeConfigSpec.Builder builder);
public Optional<ConfiguredFeature<?, ?>> createFeature(Biome biome); public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome);
public Decoration getGenerationStage(); public Decoration getGenerationStage();

View file

@ -17,7 +17,9 @@ import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.IPlacementConfig; import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.placement.TopSolidRangeConfig;
import net.minecraftforge.common.ForgeConfigSpec.Builder; import net.minecraftforge.common.ForgeConfigSpec.Builder;
import net.minecraftforge.event.world.BiomeLoadingEvent;
public abstract class OreFeature<T extends IPlacementConfig> extends ConfigBase implements IFeature { public abstract class OreFeature<T extends IPlacementConfig> extends ConfigBase implements IFeature {
@ -58,7 +60,7 @@ public abstract class OreFeature<T extends IPlacementConfig> extends ConfigBase
} }
@Override @Override
public Optional<ConfiguredFeature<?, ?>> createFeature(Biome biome) { public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome) {
if (specificCategory != null && biome.getCategory() != specificCategory) if (specificCategory != null && biome.getCategory() != specificCategory)
return Optional.empty(); return Optional.empty();
if (!canGenerate()) if (!canGenerate())
@ -68,8 +70,12 @@ public abstract class OreFeature<T extends IPlacementConfig> extends ConfigBase
ConfiguredFeature<?, ?> createdFeature = Feature.ORE ConfiguredFeature<?, ?> createdFeature = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, block.get() .configure(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, block.get()
.getDefaultState(), clusterSize.get())) .getDefaultState(), clusterSize.get()))
.createDecoratedFeature(placement.getKey() .decorate(placement.getKey()
.configure(placement.getValue())); .configure(placement.getValue()))
.decorate(Placement.RANGE
// TODO 1.16 worldgen verify this
.configure(new TopSolidRangeConfig(minHeight.get(), 0, maxHeight.get() - minHeight.get())))
.spreadHorizontally();
return Optional.of(createdFeature); return Optional.of(createdFeature);
} }

View file

@ -1,6 +1,7 @@
modLoader="javafml" modLoader="javafml"
loaderVersion="[28,)" loaderVersion="[34,)"
#issueTrackerURL="" #issueTrackerURL=""
license="MIT"
[[mods]] [[mods]]
modId="create" modId="create"
@ -14,13 +15,13 @@ Technology that empowers the player.'''
[[dependencies.create]] [[dependencies.create]]
modId="forge" modId="forge"
mandatory=true mandatory=true
versionRange="[31.2.0,)" versionRange="[34.0.0,)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.create]] [[dependencies.create]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.15.2,1.16)" versionRange="[1.16.3,1.17)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"