mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-11 13:04:05 +01:00
Get things running, fix forge/mc dependencies and extendo grip
This commit is contained in:
parent
3be810a9eb
commit
e5179598e3
@ -36,6 +36,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
@ -81,6 +82,7 @@ public class Create {
|
||||
AllMovementBehaviours.register();
|
||||
|
||||
modEventBus.addListener(Create::init);
|
||||
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, Create::onBiomeLoad);
|
||||
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register);
|
||||
modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register);
|
||||
modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register);
|
||||
@ -107,7 +109,10 @@ public class Create {
|
||||
|
||||
AllPackets.registerPackets();
|
||||
AllTriggers.register();
|
||||
AllWorldFeatures.reload();
|
||||
}
|
||||
|
||||
public static void onBiomeLoad(BiomeLoadingEvent event) {
|
||||
AllWorldFeatures.reload(event);
|
||||
}
|
||||
|
||||
public static CreateRegistrate registrate() {
|
||||
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.curiosities.tools;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
@ -22,7 +22,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
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.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@ -41,22 +41,23 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
@EventBusSubscriber
|
||||
public class ExtendoGripItem extends Item {
|
||||
|
||||
static Multimap<Attribute, AttributeModifier> rangeModifier;
|
||||
static Multimap<Attribute, AttributeModifier> doubleRangeModifier;
|
||||
static LazyValue<Multimap<Attribute, AttributeModifier>> rangeModifier =
|
||||
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 {
|
||||
// Holding an ExtendoGrip
|
||||
rangeModifier = HashMultimap.create();
|
||||
rangeModifier.put(ForgeMod.REACH_DISTANCE.get(),
|
||||
new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 3,
|
||||
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));
|
||||
}
|
||||
static LazyValue<Multimap<Attribute, AttributeModifier>> doubleRangeModifier =
|
||||
new LazyValue<Multimap<Attribute, AttributeModifier>>(() ->
|
||||
// Holding two ExtendoGrips o.O
|
||||
ImmutableMultimap.of(
|
||||
ForgeMod.REACH_DISTANCE.get(),
|
||||
new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 5,
|
||||
AttributeModifier.Operation.ADDITION))
|
||||
);
|
||||
|
||||
public ExtendoGripItem(Properties properties) {
|
||||
super(properties.maxStackSize(1)
|
||||
@ -85,13 +86,13 @@ public class ExtendoGripItem extends Item {
|
||||
|
||||
if (holdingExtendo != wasHoldingExtendo) {
|
||||
if (!holdingExtendo) {
|
||||
player.getAttributes().removeModifiers(rangeModifier);
|
||||
player.getAttributes().removeModifiers(rangeModifier.getValue());
|
||||
persistentData.remove(marker);
|
||||
} else {
|
||||
if (player instanceof ServerPlayerEntity)
|
||||
AllTriggers.EXTENDO.trigger((ServerPlayerEntity) player);
|
||||
player.getAttributes()
|
||||
.addTemporaryModifiers(rangeModifier);
|
||||
.addTemporaryModifiers(rangeModifier.getValue());
|
||||
persistentData.putBoolean(marker, true);
|
||||
}
|
||||
}
|
||||
@ -99,13 +100,13 @@ public class ExtendoGripItem extends Item {
|
||||
if (holdingDualExtendo != wasHoldingDualExtendo) {
|
||||
if (!holdingDualExtendo) {
|
||||
player.getAttributes()
|
||||
.removeModifiers(doubleRangeModifier);
|
||||
.removeModifiers(doubleRangeModifier.getValue());
|
||||
persistentData.remove(dualMarker);
|
||||
} else {
|
||||
if (player instanceof ServerPlayerEntity)
|
||||
AllTriggers.GIGA_EXTENDO.trigger((ServerPlayerEntity) player);
|
||||
player.getAttributes()
|
||||
.addTemporaryModifiers(doubleRangeModifier);
|
||||
.addTemporaryModifiers(doubleRangeModifier.getValue());
|
||||
persistentData.putBoolean(dualMarker, true);
|
||||
}
|
||||
}
|
||||
@ -147,7 +148,6 @@ public class ExtendoGripItem extends Item {
|
||||
mc.pointedEntity = entity1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -14,18 +14,6 @@ public class CWorldGen extends ConfigBase {
|
||||
AllWorldFeatures.fillConfig(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload() {
|
||||
AllWorldFeatures.reload();
|
||||
super.onReload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
AllWorldFeatures.reload();
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "worldgen.v" + AllWorldFeatures.forcedUpdateVersion;
|
||||
|
@ -17,6 +17,7 @@ import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public enum AllWorldFeatures {
|
||||
@ -43,32 +44,24 @@ public enum AllWorldFeatures {
|
||||
public static final int forcedUpdateVersion = 1;
|
||||
|
||||
public IFeature feature;
|
||||
private Map<Biome, ConfiguredFeature<?, ?>> featureInstances;
|
||||
|
||||
AllWorldFeatures(IFeature feature) {
|
||||
this.feature = feature;
|
||||
this.featureInstances = new HashMap<>();
|
||||
this.feature.setId(Lang.asId(name()));
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
public static void reload(BiomeLoadingEvent event) {
|
||||
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())
|
||||
continue;
|
||||
if (biome.getCategory() == Category.NETHER)
|
||||
continue;
|
||||
Optional<ConfiguredFeature<?, ?>> createFeature = entry.feature.createFeature(event);
|
||||
if (!createFeature.isPresent())
|
||||
continue;
|
||||
|
||||
if (entry.featureInstances.containsKey(biome))
|
||||
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());
|
||||
}
|
||||
event.getGeneration().feature(entry.feature.getGenerationStage(), createFeature.get());
|
||||
}
|
||||
|
||||
// // Debug contained ore features
|
||||
|
@ -5,10 +5,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||
|
||||
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;
|
||||
|
||||
public class ChanceOreFeature extends OreFeature<ChanceRangeConfig> {
|
||||
public class ChanceOreFeature extends OreFeature<ChanceConfig> {
|
||||
|
||||
private ConfigFloat clusterChance;
|
||||
|
||||
@ -23,9 +23,9 @@ public class ChanceOreFeature extends OreFeature<ChanceRangeConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pair<Placement<ChanceRangeConfig>, ChanceRangeConfig> getPlacement() {
|
||||
return Pair.of(Placement.CHANCE_RANGE,
|
||||
new ChanceRangeConfig(clusterChance.getF(), minHeight.get(), 0, maxHeight.get() - minHeight.get()));
|
||||
protected Pair<Placement<ChanceConfig>, ChanceConfig> getPlacement() {
|
||||
return Pair.of(Placement.CHANCE,
|
||||
// TODO 1.16 worldgen verify this
|
||||
new ChanceConfig((int) (1 / clusterChance.getF())));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
package com.simibubi.create.foundation.worldgen;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||
|
||||
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.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
|
||||
public class CountedOreFeature extends OreFeature<CountRangeConfig> {
|
||||
public class CountedOreFeature extends OreFeature<NoPlacementConfig> {
|
||||
|
||||
private ConfigInt clusterCount;
|
||||
|
||||
@ -23,9 +28,14 @@ public class CountedOreFeature extends OreFeature<CountRangeConfig> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pair<Placement<CountRangeConfig>, CountRangeConfig> getPlacement() {
|
||||
return Pair.of(Placement.COUNT_RANGE,
|
||||
new CountRangeConfig(clusterCount.get(), minHeight.get(), 0, maxHeight.get() - minHeight.get()));
|
||||
protected Pair<Placement<NoPlacementConfig>, NoPlacementConfig> getPlacement() {
|
||||
return Pair.of(Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome) {
|
||||
return super.createFeature(biome)
|
||||
// TODO 1.16 worldgen verify this
|
||||
.map(cf -> cf.repeat(clusterCount.get()));
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package com.simibubi.create.foundation.worldgen;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStage.Decoration;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
|
||||
public interface IFeature {
|
||||
|
||||
@ -13,7 +13,7 @@ public interface IFeature {
|
||||
|
||||
public void addToConfig(ForgeConfigSpec.Builder builder);
|
||||
|
||||
public Optional<ConfiguredFeature<?, ?>> createFeature(Biome biome);
|
||||
public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome);
|
||||
|
||||
public Decoration getGenerationStage();
|
||||
|
||||
|
@ -17,7 +17,9 @@ import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
import net.minecraft.world.gen.placement.IPlacementConfig;
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.TopSolidRangeConfig;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
|
||||
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
|
||||
public Optional<ConfiguredFeature<?, ?>> createFeature(Biome biome) {
|
||||
public Optional<ConfiguredFeature<?, ?>> createFeature(BiomeLoadingEvent biome) {
|
||||
if (specificCategory != null && biome.getCategory() != specificCategory)
|
||||
return Optional.empty();
|
||||
if (!canGenerate())
|
||||
@ -68,8 +70,12 @@ public abstract class OreFeature<T extends IPlacementConfig> extends ConfigBase
|
||||
ConfiguredFeature<?, ?> createdFeature = Feature.ORE
|
||||
.configure(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, block.get()
|
||||
.getDefaultState(), clusterSize.get()))
|
||||
.createDecoratedFeature(placement.getKey()
|
||||
.configure(placement.getValue()));
|
||||
.decorate(placement.getKey()
|
||||
.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);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[28,)"
|
||||
loaderVersion="[34,)"
|
||||
#issueTrackerURL=""
|
||||
license="MIT"
|
||||
|
||||
[[mods]]
|
||||
modId="create"
|
||||
@ -14,13 +15,13 @@ Technology that empowers the player.'''
|
||||
[[dependencies.create]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[31.2.0,)"
|
||||
versionRange="[34.0.0,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.create]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.15.2,1.16)"
|
||||
versionRange="[1.16.3,1.17)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
Loading…
Reference in New Issue
Block a user