mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 03:43:30 +01:00
register features more
This commit is contained in:
parent
c0bf5f0d93
commit
5db697abb1
5 changed files with 42 additions and 21 deletions
|
@ -51,7 +51,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
|
||||
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
|
||||
ret.setPos(position.x(), position.y(), position.z());
|
||||
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "tridentItem");
|
||||
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "f_37555_");
|
||||
ret.pickup = AbstractArrow.Pickup.ALLOWED;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.lang.reflect.Field;
|
|||
|
||||
public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "dataAccess");
|
||||
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "f_58311_");
|
||||
public boolean isActive;
|
||||
|
||||
public BlockEntityFurnaceHeater(BlockPos pos, BlockState state) {
|
||||
|
|
|
@ -19,11 +19,8 @@ import net.minecraft.server.level.ChunkHolder;
|
|||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
@ -37,28 +34,26 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
|
||||
public class CommonEvents {
|
||||
|
||||
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "getChunks");
|
||||
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_");
|
||||
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBiomeLoad(BiomeLoadingEvent event) {
|
||||
if (ModConfig.instance.auraBlooms.get()) {
|
||||
// TODO features might have to be registered *AGAIN* now because .placed() is another thing again oh my God
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_BLOOM.placed());
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_BLOOM);
|
||||
switch (event.getCategory()) {
|
||||
case DESERT -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_CACTUS.placed());
|
||||
case DESERT -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_CACTUS);
|
||||
case NETHER -> {
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed());
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed());
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.CRIMSON_AURA_MUSHROOM);
|
||||
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.WARPED_AURA_MUSHROOM);
|
||||
}
|
||||
case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_MUSHROOM.placed());
|
||||
case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_MUSHROOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.world.level.levelgen.feature.Feature;
|
|||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
@SuppressWarnings("FieldNamingConvention")
|
||||
public final class ModFeatures {
|
||||
|
@ -20,7 +21,6 @@ public final class ModFeatures {
|
|||
public static final class Configured {
|
||||
|
||||
public static final ConfiguredFeature<TreeConfiguration, ?> ANCIENT_TREE = ModFeatures.ANCIENT_TREE.configured(new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build());
|
||||
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> NETHER_WART_MUSHROOM = ModFeatures.NETHER_WART_MUSHROOM.configured(FeatureConfiguration.NONE);
|
||||
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_BLOOM = ModFeatures.AURA_BLOOM.configured(FeatureConfiguration.NONE);
|
||||
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_CACTUS = ModFeatures.AURA_CACTUS.configured(FeatureConfiguration.NONE);
|
||||
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> WARPED_AURA_MUSHROOM = ModFeatures.WARPED_AURA_MUSHROOM.configured(FeatureConfiguration.NONE);
|
||||
|
@ -28,4 +28,14 @@ public final class ModFeatures {
|
|||
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_MUSHROOM = ModFeatures.AURA_MUSHROOM.configured(FeatureConfiguration.NONE);
|
||||
|
||||
}
|
||||
|
||||
public static final class Placed {
|
||||
|
||||
public static final PlacedFeature AURA_BLOOM = ModFeatures.Configured.AURA_BLOOM.placed();
|
||||
public static final PlacedFeature AURA_CACTUS = ModFeatures.Configured.AURA_CACTUS.placed();
|
||||
public static final PlacedFeature WARPED_AURA_MUSHROOM = ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed();
|
||||
public static final PlacedFeature CRIMSON_AURA_MUSHROOM = ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed();
|
||||
public static final PlacedFeature AURA_MUSHROOM = ModFeatures.Configured.AURA_MUSHROOM.placed();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
|
@ -46,18 +45,22 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.FlowerPotBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class ModRegistry {
|
||||
|
@ -337,12 +340,25 @@ public final class ModRegistry {
|
|||
provider.registerTESR();
|
||||
}
|
||||
|
||||
// register features again for some reason
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), ModFeatures.Configured.AURA_BLOOM);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), ModFeatures.Configured.AURA_CACTUS);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(NaturesAura.MOD_ID, "crimson_aura_mushroom"), ModFeatures.Configured.CRIMSON_AURA_MUSHROOM);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), ModFeatures.Configured.WARPED_AURA_MUSHROOM);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), ModFeatures.Configured.AURA_MUSHROOM);
|
||||
// register features 27 more times for some reason
|
||||
for (var entry : ModFeatures.Configured.class.getFields()) {
|
||||
try {
|
||||
var feature = (ConfiguredFeature<?, ?>) entry.get(null);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, feature.feature.getRegistryName(), feature);
|
||||
} catch (IllegalAccessException e) {
|
||||
NaturesAura.LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
for (var entry : ModFeatures.Placed.class.getFields()) {
|
||||
try {
|
||||
var placed = (PlacedFeature) entry.get(null);
|
||||
// why are you making this so difficult for me
|
||||
Supplier<ConfiguredFeature<?, ?>> feature = ObfuscationReflectionHelper.getPrivateValue(PlacedFeature.class, placed, "f_191775_");
|
||||
Registry.register(BuiltinRegistries.PLACED_FEATURE, feature.get().feature.getRegistryName(), placed);
|
||||
} catch (IllegalAccessException e) {
|
||||
NaturesAura.LOGGER.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Block createFlowerPot(Block block) {
|
||||
|
|
Loading…
Reference in a new issue