Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #89

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/generated/resources/.cache/cache
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
08e56a0290a7b2bcb59afbb499abe59edef73925 data/ironstars/dimension/moon.json
59861de0d06510e486a1f004f62c6f4367e5a3ec data/ironstars/dimension/moon.json
a0bb608ed4bc527c91941856da1791896ec1c016 data/ironstars/dimension_type/moon_type.json
64dab7c693513ddd3c9e48c4f485ec5076fd8944 data/ironstars/worldgen/noise_settings/moon_noise_config.json
1d8cb64db20e84954cb026351766d8325e3646d8 data/ironstars/worldgen/biome/moon.json
690ed9183cdfa4cf1fe0e330b220d6d1fc12280a data/ironstars/worldgen/configured_feature/ore_titanium.json
ffecdcf1d9f0a8b179faae56652399378acd6f67 data/ironstars/worldgen/noise_settings/moon_noise_config.json
051c1b700adc74692b778b4d5d2f61c2e8574096 data/ironstars/worldgen/placed_feature/ore_titanium.json
5 changes: 3 additions & 2 deletions src/generated/resources/data/ironstars/dimension/moon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"generator": {
"wrapped_generator": {
"biome_source": {
"type": "ironstars:ironstars_biomes"
"biome": "ironstars:moon",
"type": "ironstars:moon_biome_source"
},
"seed": 0,
"settings": "ironstars:moon_noise_config",
"type": "minecraft:noise"
},
"type": "ironstars:structure_locating_wrapper"
"type": "ironstars:moon_generator"
}
}
44 changes: 44 additions & 0 deletions src/generated/resources/data/ironstars/worldgen/biome/moon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"carvers": {},
"features": [
[],
[],
[],
[],
[],
[],
[
"ironstars:ore_titanium"
]
],
"spawners": {
"monster": [],
"creature": [],
"ambient": [],
"axolotls": [],
"underground_water_creature": [],
"water_creature": [],
"water_ambient": [],
"misc": []
},
"spawn_costs": {},
"forge:registry_name": "ironstars:moon",
"precipitation": "none",
"temperature": -0.5,
"downfall": 0.4,
"category": "none",
"effects": {
"mood_sound": {
"sound": "ironstars:deep_space",
"tick_delay": 6000,
"block_search_extent": 8,
"offset": 2.0
},
"sky_color": 0,
"foliage_color": 12303291,
"grass_color": 12303291,
"fog_color": 12303291,
"water_color": 12303291,
"water_fog_color": 12303291
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"config": {
"targets": [
{
"target": {
"block": "ironstars:moon_rock",
"predicate_type": "minecraft:block_match"
},
"state": {
"Name": "ironstars:titanium_ore"
}
}
],
"size": 10,
"discard_chance_on_air_exposure": 0.0
},
"type": "minecraft:ore"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
"type": "minecraft:block"
},
"type": "minecraft:condition"
},
{
"if_true": {
"type": "minecraft:above_preliminary_surface"
},
"then_run": {
"result_state": {
"Name": "ironstars:moon_soil"
},
"type": "minecraft:block"
},
"type": "minecraft:condition"
}
],
"type": "minecraft:sequence"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"feature": "ironstars:ore_titanium",
"placement": [
{
"count": 16,
"type": "minecraft:count"
},
{
"type": "minecraft:in_square"
},
{
"height": {
"min_inclusive": {
"above_bottom": 0
},
"max_inclusive": {
"above_bottom": 112
},
"type": "minecraft:trapezoid"
},
"type": "minecraft:height_range"
}
]
}
4 changes: 4 additions & 0 deletions src/main/java/com/xekr/ironstars/IronStars.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import com.xekr.ironstars.registry.AllBlockEntities;
import com.xekr.ironstars.registry.AllCapabilities;
import com.xekr.ironstars.registry.AllDimensions;
import com.xekr.ironstars.registry.AllFeatures;
import com.xekr.ironstars.registry.AllFluids;
import com.xekr.ironstars.registry.AllItems;
import com.xekr.ironstars.registry.AllSounds;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
Expand All @@ -26,10 +28,12 @@ public class IronStars {
public IronStars() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(AllCapabilities::register);
AllSounds.register(bus);
AllBlocks.register(bus);
AllBlockEntities.register(bus);
AllItems.register(bus);
AllFluids.register(bus);
AllFeatures.register();
AllBiomes.register(bus);
AllDimensions.init();
AnvilRecipeTypes.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class CopperPressurePlateBlockEntity extends BlockEntity {
private long times;
public CopperPressurePlateBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) {
super(AllBlockEntities.COPPER_PRESSURE_PLATE.get(), pWorldPosition, pBlockState);
super(AllBlockEntities.COPPER_PRESSURE_PLATE, pWorldPosition, pBlockState);
}

public void tick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class TitaniumPressurePlateBlockEntity extends BlockEntity {
private long times;
public TitaniumPressurePlateBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) {
super(AllBlockEntities.TITANIUM_PRESSURE_PLATE.get(), pWorldPosition, pBlockState);
super(AllBlockEntities.TITANIUM_PRESSURE_PLATE, pWorldPosition, pBlockState);
}

public void tick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ItemEntityMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;"))
private Vec3 slowDown(Vec3 instance, double pX, double pY, double pZ) {
ItemEntity ths = (ItemEntity) (Object) this;
if (ths.level.getBlockState(ths.blockPosition()).is(AllBlocks.MAGNET_BLOCK.get())) pY /= IronStarsConfig.ItemInMagnetGravy;
if (ths.level.getBlockState(ths.blockPosition()).is(AllBlocks.MAGNET_BLOCK)) pY /= IronStarsConfig.ItemInMagnetGravy;
return instance.add(pX, pY, pZ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private static void toMagnet(Level world, BlockPos pos, CallbackInfo ci, BlockSt
BlockState blockState = world.getBlockState(targetPos);
if (!blockState.is(Blocks.IRON_BLOCK))
break;
world.setBlockAndUpdate(targetPos, AllBlocks.MAGNET_BLOCK.get().defaultBlockState());
world.setBlockAndUpdate(targetPos, AllBlocks.MAGNET_BLOCK.defaultBlockState());
targetPos = targetPos.relative(Direction.DOWN);
}
}
Expand Down
53 changes: 36 additions & 17 deletions src/main/java/com/xekr/ironstars/registry/AllBiomes.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
package com.xekr.ironstars.registry;

import com.xekr.ironstars.IronStars;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.AmbientMoodSettings;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeGenerationSettings;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class AllBiomes {
private static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, IronStars.ID);
private static final DeferredRegister<Biome> REGISTRY = DeferredRegister.create(ForgeRegistries.BIOMES, IronStars.ID);

// public static final ResourceKey<Biome> MOON = registerBiome("moon");
public static final Biome MOON = registerBiome("moon", builder -> builder
.precipitation(Biome.Precipitation.NONE)
.biomeCategory(Biome.BiomeCategory.NONE)
.temperature(-0.5f)
.temperatureAdjustment(Biome.TemperatureModifier.NONE)
.downfall(0.4f)
.specialEffects(new BiomeSpecialEffects.Builder()
.skyColor(0)
.fogColor(12303291)
.waterColor(12303291)
.waterFogColor(12303291)
.grassColorOverride(12303291)
.foliageColorOverride(12303291)
.ambientMoodSound(new AmbientMoodSettings(AllSounds.DEEP_SPACE, 6000, 8, 2.0f))
.build())
.generationSettings(new BiomeGenerationSettings.Builder().addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, AllFeatures.PLACED_TITANIUM_ORE).build())
.mobSpawnSettings(new MobSpawnSettings.Builder().build())
);

private static ResourceKey<Biome> registerBiome(String name) {
BIOMES.register(name, () -> new Biome.BiomeBuilder()
.precipitation(Biome.Precipitation.NONE)
.biomeCategory(Biome.BiomeCategory.NONE)
.downfall(0)
.temperature(0)
.specialEffects(new BiomeSpecialEffects.Builder().fogColor(0).waterColor(0).waterFogColor(0).skyColor(0).build())
.generationSettings(new BiomeGenerationSettings.Builder().build())
.mobSpawnSettings(new MobSpawnSettings.Builder().build())
.temperatureAdjustment(Biome.TemperatureModifier.NONE)
.build());
return ResourceKey.create(Registry.BIOME_REGISTRY, IronStars.id(name));
private static Biome registerBiome(String name, ReturnSelfConsumer<Biome.BiomeBuilder> consumer) {
Biome biome = consumer.accept(new Biome.BiomeBuilder()).build();
REGISTRY.register(name, () -> biome);
return biome;
}

@FunctionalInterface
interface ReturnSelfConsumer<T> {
void block(T t);

default T accept(T t) {
block(t);
return t;
}
}

public static void register(IEventBus bus) {
BIOMES.register(bus);
REGISTRY.register(bus);
}
}
16 changes: 12 additions & 4 deletions src/main/java/com/xekr/ironstars/registry/AllBlockEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.xekr.ironstars.IronStars;
import com.xekr.ironstars.blocks.entity.CopperPressurePlateBlockEntity;
import com.xekr.ironstars.blocks.entity.TitaniumPressurePlateBlockEntity;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
Expand All @@ -11,13 +13,19 @@

@SuppressWarnings("ConstantConditions")
public class AllBlockEntities {
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, IronStars.ID);
private static final DeferredRegister<BlockEntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, IronStars.ID);

public static final RegistryObject<BlockEntityType<CopperPressurePlateBlockEntity>> COPPER_PRESSURE_PLATE = BLOCK_ENTITIES.register("copper_pressure_plate", () -> BlockEntityType.Builder.of(CopperPressurePlateBlockEntity::new, AllBlocks.COPPER_PRESSURE_PLATE.get()).build(null));
public static final RegistryObject<BlockEntityType<TitaniumPressurePlateBlockEntity>> TITANIUM_PRESSURE_PLATE = BLOCK_ENTITIES.register("titanium_pressure_plate", () -> BlockEntityType.Builder.of(TitaniumPressurePlateBlockEntity::new, AllBlocks.TITANIUM_PRESSURE_PLATE.get()).build(null));
public static final BlockEntityType<CopperPressurePlateBlockEntity> COPPER_PRESSURE_PLATE = register("copper_pressure_plate", CopperPressurePlateBlockEntity::new, AllBlocks.COPPER_PRESSURE_PLATE);
public static final BlockEntityType<TitaniumPressurePlateBlockEntity> TITANIUM_PRESSURE_PLATE = register("titanium_pressure_plate", TitaniumPressurePlateBlockEntity::new, AllBlocks.TITANIUM_PRESSURE_PLATE);


private static <T extends BlockEntity> BlockEntityType<T> register(String name, BlockEntityType.BlockEntitySupplier<T> pFactory, Block... pValidBlocks) {
BlockEntityType<T> blockEntityType = BlockEntityType.Builder.of(pFactory, pValidBlocks).build(null);
REGISTRY.register(name, () -> blockEntityType);
return blockEntityType;
}

public static void register(IEventBus bus) {
BLOCK_ENTITIES.register(bus);
REGISTRY.register(bus);
}
}
Loading