Compare commits
No commits in common. "137502b60396712ae4e82554b276896fed09878b" and "5167a1319d93dc8592de3992f8b1a7941c0890c1" have entirely different histories.
137502b603
...
5167a1319d
47
build.gradle
47
build.gradle
@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||
id "com.github.johnrengelman.shadow" version "5.2.0"
|
||||
}
|
||||
|
||||
compileJava {
|
||||
@ -18,16 +19,6 @@ minecraft {
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'Earthcomputer Mods'
|
||||
url = 'https://dl.bintray.com/earthcomputer/mods'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
includeTransitive {
|
||||
transitive = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -36,31 +27,37 @@ dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
implementation "com.squareup.moshi:moshi:${project.moshi_version}"
|
||||
includeTransitive "com.squareup.moshi:moshi:${project.moshi_version}"
|
||||
modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}"
|
||||
|
||||
modImplementation "net.earthcomputer:libstructure:${project.libstructure_version}"
|
||||
include "net.earthcomputer:libstructure:${project.libstructure_version}"
|
||||
implementation "com.squareup.moshi:moshi:${project.moshi_version}"
|
||||
shadow "com.squareup.moshi:moshi:${project.moshi_version}"
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
configurations.includeTransitive.incoming.resolutionResult.allComponents {
|
||||
if (it.id instanceof ModuleComponentIdentifier) {
|
||||
def that = it
|
||||
dependencies {
|
||||
include group: that.id.getGroup(), name: that.id.getModule(), version: that.id.getVersion()
|
||||
}
|
||||
}
|
||||
}
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
classifier 'shadow-dev'
|
||||
}
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
||||
|
||||
task relocateShadowJar(type: ConfigureShadowRelocation) {
|
||||
target = tasks.shadowJar
|
||||
prefix = "${project.group}.${project.archivesBaseName}.shadow"
|
||||
}
|
||||
tasks.shadowJar.dependsOn tasks.relocateShadowJar
|
||||
|
||||
remapJar {
|
||||
dependsOn shadowJar
|
||||
input.set shadowJar.archiveFile.get()
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', project.version
|
||||
inputs.property 'version', mod_version
|
||||
inputs.property 'name', rootProject.name
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'fabric.mod.json'
|
||||
expand 'version': project.version, 'name': rootProject.name
|
||||
expand 'version': mod_version, 'name': rootProject.name
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
|
@ -3,19 +3,19 @@ org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version = 1.16.1
|
||||
minecraft_version = 1.15.2
|
||||
curseforge_id = 373074
|
||||
simple_minecraft_version = 1.16.1
|
||||
yarn_build = 16
|
||||
fabric_loader_version = 0.8.8+build.202
|
||||
simple_minecraft_version = 1.15.2
|
||||
yarn_build = 15
|
||||
fabric_loader_version = 0.7.10+build.191
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.27
|
||||
mod_version = 1.0.26
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = reliccraft
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_api_version = 0.14.0+build.371-1.16
|
||||
fabric_api_version = 0.5.1+build.294-1.15
|
||||
mod_menu_version = 1.10.2+build.32
|
||||
moshi_version = 1.9.2
|
||||
libstructure_version = 1.3
|
||||
|
@ -22,16 +22,17 @@ import com.thebrokenrail.reliccraft.recipe.RevealRelicRecipe;
|
||||
import com.thebrokenrail.reliccraft.recipe.TimeDilaterRecipe;
|
||||
import com.thebrokenrail.reliccraft.structure.TimeTempleFeature;
|
||||
import com.thebrokenrail.reliccraft.structure.TimeTempleGenerator;
|
||||
import net.earthcomputer.libstructure.LibStructure;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
||||
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
|
||||
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
@ -39,7 +40,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.BinomialLootTableRange;
|
||||
import net.minecraft.loot.LootTables;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.function.LootFunctionType;
|
||||
import net.minecraft.loot.function.LootFunctions;
|
||||
import net.minecraft.recipe.SpecialRecipeSerializer;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
@ -51,11 +52,17 @@ import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.decorator.Decorator;
|
||||
import net.minecraft.world.gen.decorator.DecoratorConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class RelicCraft implements ModInitializer {
|
||||
public static final String NAMESPACE = "reliccraft";
|
||||
|
||||
@ -117,13 +124,12 @@ public class RelicCraft implements ModInitializer {
|
||||
world.playSound(null, pos, INTERACT_TELEPORT_RESTRICTOR_SOUND_EFFECT, SoundCategory.BLOCKS, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public static StructureFeature<DefaultFeatureConfig> TIME_TEMPLE_STRUCTURE_FEATURE = new TimeTempleFeature(DefaultFeatureConfig.CODEC);
|
||||
public static StructureFeature<DefaultFeatureConfig> TIME_TEMPLE_STRUCTURE_FEATURE = new TimeTempleFeature(DefaultFeatureConfig::deserialize);
|
||||
public static StructurePieceType TIME_TEMPLE_STRUCTURE_PIECE = TimeTempleGenerator.Piece::new;
|
||||
public static final String TIME_TEMPLE_ID = "RelicCraft Time Temple";
|
||||
|
||||
public static ItemGroup ITEM_GROUP;
|
||||
|
||||
public final static Identifier TIME_TEMPLE_ID = new Identifier(NAMESPACE, "time_temple");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(TIME_DILATER_ITEM));
|
||||
@ -134,21 +140,20 @@ public class RelicCraft implements ModInitializer {
|
||||
TARGETED_ENDER_PEARL_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "targeted_ender_pearl"), new TargetedEnderPearlItem());
|
||||
GENERATE_RELIC_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "generate_relic"), new GenerateRelicItem());
|
||||
|
||||
Identifier entityID = new Identifier(NAMESPACE, "relic_entity");
|
||||
RELIC_ENTITY = Registry.register(Registry.ENTITY_TYPE, entityID, EntityType.Builder.create((EntityType.EntityFactory<RelicEntity>) RelicEntity::new, SpawnGroup.MISC).setDimensions(0.25f, 0.25f).build(entityID.toString()));
|
||||
RELIC_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<RelicEntity>) RelicEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
||||
|
||||
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
|
||||
if (isSelectedLootTable(id)) {
|
||||
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
|
||||
.rolls(new BinomialLootTableRange(2, 0.5f))
|
||||
.withEntry(ItemEntry.builder(ORB_ITEM).build())
|
||||
.withEntry(ItemEntry.builder(STAFF_ITEM).build())
|
||||
.withFunction(new RelicLootTableFunction.Builder().build());
|
||||
.withRolls(new BinomialLootTableRange(2, 0.5f))
|
||||
.withEntry(ItemEntry.builder(ORB_ITEM))
|
||||
.withEntry(ItemEntry.builder(STAFF_ITEM))
|
||||
.withFunction(new RelicLootTableFunction.Builder());
|
||||
|
||||
supplier.withPool(poolBuilder.build());
|
||||
supplier.withPool(poolBuilder);
|
||||
}
|
||||
});
|
||||
Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(NAMESPACE, "randomize_relic"), new LootFunctionType(new RelicLootTableFunction.Serializer()));
|
||||
LootFunctions.register(new RelicLootTableFunction.Factory());
|
||||
|
||||
REVEAL_RELIC_RECIPE = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "reveal_relic"), new SpecialRecipeSerializer<>(RevealRelicRecipe::new));
|
||||
TIME_DILATER_RECIPE = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "time_dilater"), new SpecialRecipeSerializer<>(TimeDilaterRecipe::new));
|
||||
@ -174,11 +179,25 @@ public class RelicCraft implements ModInitializer {
|
||||
TagRegistry.item(new Identifier(NAMESPACE, "advancement_trigger_items"));
|
||||
|
||||
Registry.register(Registry.STRUCTURE_PIECE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_PIECE);
|
||||
Registry.register(Registry.FEATURE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_FEATURE);
|
||||
Registry.register(Registry.STRUCTURE_FEATURE, new Identifier(NAMESPACE, "time_temple"), TIME_TEMPLE_STRUCTURE_FEATURE);
|
||||
|
||||
Feature.STRUCTURES.put(TIME_TEMPLE_ID.toLowerCase(Locale.ROOT), TIME_TEMPLE_STRUCTURE_FEATURE);
|
||||
|
||||
ConfiguredFeature<?, ?> configuredFeature = getConfiguredFeature(TIME_TEMPLE_STRUCTURE_FEATURE);
|
||||
|
||||
for (Biome biome : Registry.BIOME) {
|
||||
if (biome.getCategory() == Biome.Category.PLAINS) {
|
||||
biome.addStructureFeature(TIME_TEMPLE_STRUCTURE_FEATURE.configure(FeatureConfig.DEFAULT));
|
||||
}
|
||||
}
|
||||
LibStructure.registerStructure(TIME_TEMPLE_ID, TIME_TEMPLE_STRUCTURE_FEATURE, GenerationStep.Feature.SURFACE_STRUCTURES, new StructureConfig(32, 8, 14357618), TIME_TEMPLE_STRUCTURE_FEATURE.configure(FeatureConfig.DEFAULT));
|
||||
|
||||
FlatChunkGeneratorConfig.FEATURE_TO_GENERATION_STEP.put(configuredFeature, GenerationStep.Feature.SURFACE_STRUCTURES);
|
||||
FlatChunkGeneratorConfig.FEATURE_TO_FEATURE_CONFIG.put(configuredFeature, FeatureConfig.DEFAULT);
|
||||
FlatChunkGeneratorConfig.STRUCTURE_TO_FEATURES.put(NAMESPACE + "_time_temple", new ConfiguredFeature[]{configuredFeature});
|
||||
}
|
||||
|
||||
public static ConfiguredFeature<?, ?> getConfiguredFeature(StructureFeature<DefaultFeatureConfig> feature) {
|
||||
return feature.configure(FeatureConfig.DEFAULT).createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ActivateTeleportationBeaconCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class ActivateTeleportationBeaconCriterion extends AbstractCriterion<ActivateTeleportationBeaconCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "activate_teleportation_beacon");
|
||||
|
||||
public ActivateTeleportationBeaconCriterion() {
|
||||
@ -21,11 +20,17 @@ public class ActivateTeleportationBeaconCriterion extends AbstractCriterion<Abst
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +1,36 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ActivateTeleportationRestrictorCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class ActivateTeleportationRestrictorCriterion extends AbstractCriterion<ActivateTeleportationRestrictorCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "activate_teleportation_restrictor");
|
||||
|
||||
public ActivateTeleportationRestrictorCriterion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class DilateTimeCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class DilateTimeCriterion extends AbstractCriterion<DilateTimeCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "dilate_time");
|
||||
|
||||
public DilateTimeCriterion() {
|
||||
@ -21,11 +20,17 @@ public class DilateTimeCriterion extends AbstractCriterion<AbstractCriterionCond
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class DuplicateTimeDilaterCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class DuplicateTimeDilaterCriterion extends AbstractCriterion<DuplicateTimeDilaterCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "duplicate_time_dilater");
|
||||
|
||||
public DuplicateTimeDilaterCriterion() {
|
||||
@ -21,11 +20,17 @@ public class DuplicateTimeDilaterCriterion extends AbstractCriterion<AbstractCri
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class RevealRelicCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class RevealRelicCriterion extends AbstractCriterion<RevealRelicCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "reveal_relic");
|
||||
|
||||
public RevealRelicCriterion() {
|
||||
@ -21,11 +20,17 @@ public class RevealRelicCriterion extends AbstractCriterion<AbstractCriterionCon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -5,12 +5,10 @@ import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class UseTargetedEnderPearlCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class UseTargetedEnderPearlCriterion extends AbstractCriterion<UseTargetedEnderPearlCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "use_targeted_ender_pearl");
|
||||
|
||||
public UseTargetedEnderPearlCriterion() {
|
||||
@ -22,11 +20,17 @@ public class UseTargetedEnderPearlCriterion extends AbstractCriterion<AbstractCr
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package com.thebrokenrail.reliccraft.advancement;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class UseTeleportationBeaconCriterion extends AbstractCriterion<AbstractCriterionConditions> {
|
||||
public class UseTeleportationBeaconCriterion extends AbstractCriterion<UseTeleportationBeaconCriterion.Conditions> {
|
||||
private static final Identifier ID = new Identifier(RelicCraft.NAMESPACE, "use_teleportation_beacon");
|
||||
|
||||
public UseTeleportationBeaconCriterion() {
|
||||
@ -21,11 +20,17 @@ public class UseTeleportationBeaconCriterion extends AbstractCriterion<AbstractC
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||
return new AbstractCriterionConditions(ID, playerPredicate) {};
|
||||
public Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
||||
return new Conditions();
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player) {
|
||||
test(player, conditions -> true);
|
||||
test(player.getAdvancementTracker(), conditions -> true);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
public Conditions() {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
@ -30,10 +30,15 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
|
||||
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||
|
||||
public AbstractDragonEggHolderBlock(Settings settings) {
|
||||
super(settings.lightLevel(state -> state.get(ACTIVE) ? 7 : 0));
|
||||
super(settings);
|
||||
setDefaultState(getStateManager().getDefaultState().with(ACTIVE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLuminance(BlockState state) {
|
||||
return state.get(ACTIVE) ? 7 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView view) {
|
||||
return new DragonEggHolderBlockEntity();
|
||||
@ -47,18 +52,18 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
|
||||
Inventory inventory = (Inventory) blockEntity;
|
||||
ItemStack stack = user.getStackInHand(hand);
|
||||
|
||||
if (inventory.isValid(0, stack) && inventory.getStack(0).isEmpty()) {
|
||||
inventory.setStack(0, stack.split(1));
|
||||
if (inventory.isValidInvStack(0, stack) && inventory.getInvStack(0).isEmpty()) {
|
||||
inventory.setInvStack(0, stack.split(1));
|
||||
|
||||
if (!world.isClient()) {
|
||||
grantAdvancement(user);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
} else if (stack.isEmpty()) {
|
||||
if (!inventory.getStack(0).isEmpty()) {
|
||||
user.inventory.offerOrDrop(world, inventory.getStack(0));
|
||||
if (!inventory.getInvStack(0).isEmpty()) {
|
||||
user.inventory.offerOrDrop(world, inventory.getInvStack(0));
|
||||
|
||||
inventory.removeStack(0);
|
||||
inventory.removeInvStack(0);
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
@ -93,14 +98,14 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof Inventory) {
|
||||
ItemScatterer.spawn(world, pos, (Inventory) blockEntity);
|
||||
}
|
||||
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
super.onBlockRemoved(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +121,7 @@ public abstract class AbstractDragonEggHolderBlock extends Block implements Bloc
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
return Container.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
public abstract void tick(World world, BlockPos pos);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.thebrokenrail.reliccraft.block;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@ -10,8 +11,9 @@ import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
@ -20,16 +22,16 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
DefaultedList<ItemStack> list = DefaultedList.ofSize(size(), ItemStack.EMPTY);
|
||||
public void fromTag(CompoundTag tag) {
|
||||
super.fromTag(tag);
|
||||
DefaultedList<ItemStack> list = DefaultedList.ofSize(getInvSize(), ItemStack.EMPTY);
|
||||
Inventories.fromTag(tag, list);
|
||||
stack = list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
DefaultedList<ItemStack> list = DefaultedList.ofSize(size(), ItemStack.EMPTY);
|
||||
DefaultedList<ItemStack> list = DefaultedList.ofSize(getInvSize(), ItemStack.EMPTY);
|
||||
list.set(0, stack);
|
||||
Inventories.toTag(tag, list);
|
||||
return super.toTag(tag);
|
||||
@ -38,56 +40,56 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
private ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
public int getInvSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCountPerStack() {
|
||||
public int getInvMaxStackAmount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
public boolean isInvEmpty() {
|
||||
return stack.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(int slot) {
|
||||
public ItemStack getInvStack(int slot) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot, int amount) {
|
||||
ItemStack newStack = getStack(0).split(amount);
|
||||
public ItemStack takeInvStack(int slot, int amount) {
|
||||
ItemStack newStack = getInvStack(0).split(amount);
|
||||
markDirty();
|
||||
return newStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot) {
|
||||
ItemStack newStack = getStack(0).copy();
|
||||
setStack(0, ItemStack.EMPTY);
|
||||
public ItemStack removeInvStack(int slot) {
|
||||
ItemStack newStack = getInvStack(0).copy();
|
||||
setInvStack(0, ItemStack.EMPTY);
|
||||
return newStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, ItemStack stack) {
|
||||
public void setInvStack(int slot, ItemStack stack) {
|
||||
this.stack = stack;
|
||||
if (stack.getCount() > getMaxCountPerStack()) {
|
||||
stack.setCount(getMaxCountPerStack());
|
||||
if (stack.getCount() > getInvMaxStackAmount()) {
|
||||
stack.setCount(getInvMaxStackAmount());
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(PlayerEntity player) {
|
||||
public boolean canPlayerUseInv(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
setStack(0, ItemStack.EMPTY);
|
||||
setInvStack(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,7 +104,7 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(int slot, ItemStack stack) {
|
||||
public boolean isValidInvStack(int slot, ItemStack stack) {
|
||||
return stack.getItem() == Items.DRAGON_EGG;
|
||||
}
|
||||
|
||||
@ -118,7 +120,7 @@ public class DragonEggHolderBlockEntity extends BlockEntity implements Inventory
|
||||
if (hasWorld()) {
|
||||
assert getWorld() != null;
|
||||
BlockState state = getWorld().getBlockState(pos);
|
||||
boolean active = !getStack(0).isEmpty();
|
||||
boolean active = !getInvStack(0).isEmpty();
|
||||
if (state.get(TeleportationRestrictorBlock.ACTIVE) != active) {
|
||||
getWorld().setBlockState(getPos(), state.with(TeleportationRestrictorBlock.ACTIVE, active));
|
||||
RelicCraft.playInteractTeleportRestrictorSound(getWorld(), getPos());
|
||||
|
@ -1,18 +1,19 @@
|
||||
package com.thebrokenrail.reliccraft.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface Action {
|
||||
void execute(World world, Entity attacker, Entity target);
|
||||
void execute(World world, LivingEntity attacker, Entity target);
|
||||
|
||||
void execute(World world, Entity attacker, BlockPos pos);
|
||||
void execute(World world, LivingEntity attacker, BlockPos pos);
|
||||
|
||||
int getCost();
|
||||
|
||||
default PlayerEntity convertToPlayer(Entity entity) {
|
||||
default PlayerEntity convertToPlayer(LivingEntity entity) {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
return (PlayerEntity) entity;
|
||||
} else {
|
||||
|
@ -6,19 +6,19 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.mob.ZombieEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.thrown.PotionEntity;
|
||||
import net.minecraft.entity.thrown.ThrownPotionEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.potion.PotionUtil;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -73,28 +73,28 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (target instanceof LivingEntity) {
|
||||
((LivingEntity) target).setHealth(1f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
PotionEntity entity = new PotionEntity(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
entity.setItem(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HARMING));
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
ThrownPotionEntity entity = new ThrownPotionEntity(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
entity.setItemStack(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HARMING));
|
||||
world.spawnEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SwapBlockAction implements Action {
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
execute(world, attacker, target.getBlockPos().down());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos) && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos().down())) {
|
||||
BlockState state1 = world.getBlockState(attacker.getBlockPos().down());
|
||||
BlockState state2 = world.getBlockState(pos);
|
||||
@ -116,7 +116,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, target.getBlockPos())) {
|
||||
target.remove();
|
||||
target.kill();
|
||||
@ -125,7 +125,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
|
||||
world.setBlockState(pos, Blocks.DIRT.getDefaultState());
|
||||
}
|
||||
@ -139,16 +139,16 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
BlockPos pos = target.getBlockPos();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
world.setBlockState(pos, Blocks.NETHER_PORTAL.getDefaultState());
|
||||
target.changeDimension(((ServerWorld) world).getServer().getWorld(world.getRegistryKey() == World.NETHER ? World.OVERWORLD : World.NETHER));
|
||||
target.changeDimension(world.dimension.getType() == DimensionType.THE_NETHER ? DimensionType.OVERWORLD : DimensionType.THE_NETHER);
|
||||
world.setBlockState(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
|
||||
world.setBlockState(pos, Blocks.LAVA.getDefaultState());
|
||||
}
|
||||
@ -162,12 +162,12 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
target.changeDimension(((ServerWorld) world).getServer().getWorld(world.getRegistryKey() == World.END ? World.OVERWORLD : World.END));
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
target.changeDimension(world.dimension.getType() == DimensionType.THE_END ? DimensionType.OVERWORLD : DimensionType.THE_END);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
|
||||
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
|
||||
}
|
||||
@ -214,20 +214,20 @@ public class Actions {
|
||||
public abstract Block getConvertedBlock();
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (target instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) target;
|
||||
for (int i = 0; i < player.inventory.size(); i++) {
|
||||
ItemStack stack = player.inventory.getStack(i);
|
||||
for (int i = 0; i < player.inventory.getInvSize(); i++) {
|
||||
ItemStack stack = player.inventory.getInvStack(i);
|
||||
if (stack.getItem() == getTargetItem()) {
|
||||
player.inventory.setStack(i, new ItemStack(getConvertedItem(), stack.getCount()));
|
||||
player.inventory.setInvStack(i, new ItemStack(getConvertedItem(), stack.getCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos) && world.getBlockState(pos).getBlock() == getTargetBlock()) {
|
||||
world.setBlockState(pos, getConvertedBlock().getDefaultState());
|
||||
}
|
||||
@ -268,7 +268,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, attacker.getBlockPos())) {
|
||||
target.remove();
|
||||
target.kill();
|
||||
@ -277,7 +277,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
|
||||
world.setBlockState(pos, Blocks.BEDROCK.getDefaultState());
|
||||
}
|
||||
@ -291,23 +291,23 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (target instanceof LivingEntity) {
|
||||
((LivingEntity) target).heal(Float.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
PotionEntity entity = new PotionEntity(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
entity.setItem(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HEALING));
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
ThrownPotionEntity entity = new ThrownPotionEntity(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
entity.setItemStack(PotionUtil.setPotion(new ItemStack(Items.LINGERING_POTION), Potions.STRONG_HEALING));
|
||||
world.spawnEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ZombifyAction implements Action {
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
ZombieEntity zombie = new ZombieEntity(world);
|
||||
zombie.updatePosition(target.getX(), target.getY(), target.getZ());
|
||||
world.spawnEntity(zombie);
|
||||
@ -316,7 +316,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
ZombieEntity zombie = new ZombieEntity(world);
|
||||
zombie.updatePosition(attacker.getX(), attacker.getY(), attacker.getZ());
|
||||
world.spawnEntity(zombie);
|
||||
@ -332,7 +332,7 @@ public class Actions {
|
||||
|
||||
public static class RandomAction implements Action {
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, Entity target) {
|
||||
public void execute(World world, LivingEntity attacker, Entity target) {
|
||||
if (!target.removed) {
|
||||
target.remove();
|
||||
target.kill();
|
||||
@ -340,7 +340,7 @@ public class Actions {
|
||||
int entityID = new Random().nextInt(Registry.ENTITY_TYPE.getIds().size());
|
||||
EntityType<?> entityType = Registry.ENTITY_TYPE.get(entityID);
|
||||
if (entityType.isSummonable()) {
|
||||
Entity entity = entityType.spawn(world, null, null, convertToPlayer(attacker), target.getBlockPos(), SpawnReason.CONVERSION, false, false);
|
||||
Entity entity = entityType.spawn(world, null, null, convertToPlayer(attacker), target.getBlockPos(), SpawnType.CONVERSION, false, false);
|
||||
if (entity != null) {
|
||||
entity.updatePosition(target.getX(), target.getY(), target.getZ());
|
||||
} else {
|
||||
@ -352,7 +352,7 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(World world, Entity attacker, BlockPos pos) {
|
||||
public void execute(World world, LivingEntity attacker, BlockPos pos) {
|
||||
if (attacker instanceof PlayerEntity && world.canPlayerModifyAt((PlayerEntity) attacker, pos)) {
|
||||
int blockID = new Random().nextInt(Registry.BLOCK.getIds().size());
|
||||
Block block = Registry.BLOCK.get(blockID);
|
||||
|
@ -7,7 +7,7 @@ import com.thebrokenrail.reliccraft.item.RelicItem;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||
import net.minecraft.entity.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||
|
@ -1,20 +1,19 @@
|
||||
package com.thebrokenrail.reliccraft.item;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import com.thebrokenrail.reliccraft.mixin.ModelPredicateProviderRegistryHook;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.Inventories;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
public class DragonEggHolderBlockItem extends BlockItem {
|
||||
public DragonEggHolderBlockItem(Block block) {
|
||||
super(block, new Settings().rarity(Rarity.UNCOMMON).group(RelicCraft.ITEM_GROUP));
|
||||
ModelPredicateProviderRegistryHook.callRegister(this, new Identifier(RelicCraft.NAMESPACE, "active"), (stack, world, entity) -> {
|
||||
addPropertyGetter(new Identifier(RelicCraft.NAMESPACE, "active"), (stack, world, entity) -> {
|
||||
CompoundTag tag = stack.getSubTag("BlockEntityTag");
|
||||
if (tag != null) {
|
||||
DefaultedList<ItemStack> list = DefaultedList.ofSize(1, ItemStack.EMPTY);
|
||||
|
@ -66,7 +66,7 @@ public class GenerateRelicItem extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGlint(ItemStack stack) {
|
||||
public boolean hasEnchantmentGlint(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -70,9 +70,9 @@ public class RelicItem extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGlint(ItemStack stack) {
|
||||
public boolean hasEnchantmentGlint(ItemStack stack) {
|
||||
RelicData data = getData(stack);
|
||||
return super.hasGlint(stack) || data.enchantmentGlint;
|
||||
return super.hasEnchantmentGlint(stack) || data.enchantmentGlint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -134,7 +134,7 @@ public class RelicItem extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) {
|
||||
public boolean useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) {
|
||||
RelicData data = getData(stack);
|
||||
if (data.use.mode == RelicData.UseData.Mode.TARGET) {
|
||||
if (!user.getEntityWorld().isClient()) {
|
||||
@ -144,9 +144,9 @@ public class RelicItem extends Item {
|
||||
}
|
||||
|
||||
damage(stack, user, hand);
|
||||
return ActionResult.SUCCESS;
|
||||
return true;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.datafixer.NbtOps;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@ -17,7 +16,6 @@ import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@ -29,11 +27,10 @@ import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TargetedEnderPearlItem extends Item {
|
||||
public TargetedEnderPearlItem() {
|
||||
@ -41,7 +38,7 @@ public class TargetedEnderPearlItem extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGlint(ItemStack stack) {
|
||||
public boolean hasEnchantmentGlint(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -61,16 +58,16 @@ public class TargetedEnderPearlItem extends Item {
|
||||
|
||||
BlockPos target = new BlockPos(tag.getInt("TargetX"), tag.getInt("TargetY"), tag.getInt("TargetZ"));
|
||||
Vec3d teleportTarget = new Vec3d(target.getX() + 0.5d, target.getY() + 1.0d, target.getZ() + 0.5d);
|
||||
RegistryKey<World> dimension = World.CODEC.parse(NbtOps.INSTANCE, tag.get("TargetDimension")).result().orElse(World.OVERWORLD);
|
||||
DimensionType dimension = DimensionType.byId(new Identifier(tag.getString("TargetDimension")));
|
||||
|
||||
if (user.getEntityWorld().getRegistryKey() != dimension || dimension == null) {
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_in_different_dimension"), false);
|
||||
if (user.dimension != dimension || dimension == null) {
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_in_different_dimension"));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
} else if (((TeleportationRestrictorBlock.TeleportingEntity) user).cannotTeleport()) {
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_restricted"), false);
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_restricted"));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
} else if (world.getBlockState(target).getBlock() != RelicCraft.TELEPORTATION_BEACON_BLOCK || !world.getBlockState(target).get(AbstractDragonEggHolderBlock.ACTIVE)) {
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".missing_teleportation_beacon"), false);
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".missing_teleportation_beacon"));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
} else {
|
||||
Vec3d oldPos = user.getPos();
|
||||
@ -88,7 +85,7 @@ public class TargetedEnderPearlItem extends Item {
|
||||
stack.decrement(1);
|
||||
}
|
||||
} else {
|
||||
user.sendSystemMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_obstructed"), UUID.randomUUID());
|
||||
user.sendMessage(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".teleportation_beacon_obstructed"));
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
}
|
||||
}
|
||||
@ -113,7 +110,7 @@ public class TargetedEnderPearlItem extends Item {
|
||||
|
||||
Identifier id = new Identifier(tag.getString("TargetDimension"));
|
||||
String key = "text." + RelicCraft.NAMESPACE + ".dimension." + id.getNamespace() + '.' + id.getPath();
|
||||
MutableText dimensionText;
|
||||
Text dimensionText;
|
||||
if (Language.getInstance().hasTranslation(key)) {
|
||||
dimensionText = new TranslatableText(key);
|
||||
} else {
|
||||
|
@ -9,15 +9,16 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.MessageType;
|
||||
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.PersistentState;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@ -29,36 +30,6 @@ public class TimeDilaterItem extends Item {
|
||||
VERY_FAST
|
||||
}
|
||||
|
||||
public static final String TIME_SPEED_KEY = new Identifier(RelicCraft.NAMESPACE, "time_speed").toString();
|
||||
|
||||
public static class TimeSpeedState extends PersistentState {
|
||||
private TimeSpeed timeSpeed = TimeSpeed.NORMAL;
|
||||
|
||||
public TimeSpeedState() {
|
||||
super(TIME_SPEED_KEY);
|
||||
}
|
||||
|
||||
public void setTimeSpeed(TimeSpeed timeSpeed) {
|
||||
this.timeSpeed = timeSpeed;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public TimeSpeed getTimeSpeed() {
|
||||
return timeSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag tag) {
|
||||
timeSpeed = TimeSpeed.valueOf(tag.getString("TimeSpeed"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
tag.putString("TimeSpeed", timeSpeed.name());
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
public interface DilatedWorld {
|
||||
void setTimeSpeed(TimeSpeed speed);
|
||||
TimeSpeed getTimeSpeed();
|
||||
@ -91,7 +62,7 @@ public class TimeDilaterItem extends Item {
|
||||
}
|
||||
}
|
||||
assert world.getServer() != null;
|
||||
world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".announce_time_speed_change", user.getDisplayName(), new LiteralText("[").append(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".announce_time_speed_change." + dilatedWorld.getTimeSpeed().name().toLowerCase())).append("]").formatted(Formatting.YELLOW)), MessageType.CHAT, Util.NIL_UUID));
|
||||
world.getServer().getPlayerManager().sendToAll(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".announce_time_speed_change", user.getDisplayName(), new LiteralText("[").append(new TranslatableText("chat." + RelicCraft.NAMESPACE + ".announce_time_speed_change." + dilatedWorld.getTimeSpeed().name().toLowerCase())).append("]").formatted(Formatting.YELLOW)));
|
||||
RelicCraft.DILATE_TIME_CRITERION.trigger((ServerPlayerEntity) user);
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,11 @@ import net.minecraft.loot.condition.LootCondition;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.function.ConditionalLootFunction;
|
||||
import net.minecraft.loot.function.LootFunction;
|
||||
import net.minecraft.loot.function.LootFunctionType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public class RelicLootTableFunction extends ConditionalLootFunction {
|
||||
protected RelicLootTableFunction(LootCondition[] conditions) {
|
||||
private RelicLootTableFunction(LootCondition[] conditions) {
|
||||
super(conditions);
|
||||
}
|
||||
|
||||
@ -34,14 +32,9 @@ public class RelicLootTableFunction extends ConditionalLootFunction {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootFunctionType getType() {
|
||||
return Registry.LOOT_FUNCTION_TYPE.get(new Identifier(RelicCraft.NAMESPACE, "randomize_relic"));
|
||||
}
|
||||
|
||||
public static class Serializer extends ConditionalLootFunction.Serializer<RelicLootTableFunction> {
|
||||
public Serializer() {
|
||||
super();
|
||||
public static class Factory extends ConditionalLootFunction.Factory<RelicLootTableFunction> {
|
||||
public Factory() {
|
||||
super(new Identifier(RelicCraft.NAMESPACE, "randomize_relic"), RelicLootTableFunction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import net.minecraft.advancement.criterion.Criteria;
|
||||
import net.minecraft.advancement.criterion.Criterion;
|
||||
import net.minecraft.advancement.criterion.Criterions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Criteria.class)
|
||||
@Mixin(Criterions.class)
|
||||
public interface CriteriaRegistryHook {
|
||||
@Invoker("register")
|
||||
static <T extends Criterion<?>> T callRegister(T criterion) {
|
||||
|
@ -1,15 +0,0 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(ClientWorld.class)
|
||||
public abstract class MixinClientWorld extends MixinWorld {
|
||||
@ModifyConstant(constant = @Constant(longValue = 1L), method = "tickTime")
|
||||
public long tickTime(long value) {
|
||||
return value * TimeDilaterItem.getTimeDilationFactor(getTimeSpeed());
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.DefaultBiomeFeatures;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(DefaultBiomeFeatures.class)
|
||||
public class MixinDefaultBiomeFeatures {
|
||||
@Inject(at = @At("RETURN"), method = "addDefaultStructures")
|
||||
private static void addDefaultStructures(Biome biome, CallbackInfo info) {
|
||||
biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, RelicCraft.getConfiguredFeature(RelicCraft.TIME_TEMPLE_STRUCTURE_FEATURE));
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class MixinEnderPearlItem extends Item {
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
String dimension = world.getRegistryKey().toString();
|
||||
String dimension = Objects.requireNonNull(DimensionType.getId(world.getDimension().getType())).toString();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
PlayerEntity user = context.getPlayer();
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.feature.LakeFeature;
|
||||
import net.minecraft.world.gen.feature.SingleStateFeatureConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -23,7 +21,7 @@ import java.util.Random;
|
||||
@Mixin(LakeFeature.class)
|
||||
public class MixinLakeFeature {
|
||||
@Inject(at = @At("HEAD"), method = "generate", cancellable = true)
|
||||
public void fixTimeTemple(ServerWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, SingleStateFeatureConfig singleStateFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
public void fixTimeTemple(IWorld world, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos blockPos, SingleStateFeatureConfig singleStateFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
List<Chunk> chunksToScan = new ArrayList<>();
|
||||
chunksToScan.add(world.getChunk(blockPos));
|
||||
chunksToScan.add(world.getChunk(blockPos.add(16, 0, 16)));
|
||||
@ -36,7 +34,7 @@ public class MixinLakeFeature {
|
||||
chunksToScan.add(world.getChunk(blockPos.add(-16, 0, 16)));
|
||||
|
||||
for (Chunk chunk : chunksToScan) {
|
||||
if (!chunk.getStructureReferences(RelicCraft.TIME_TEMPLE_STRUCTURE_FEATURE).isEmpty()) {
|
||||
if (!chunk.getStructureReferences(RelicCraft.TIME_TEMPLE_ID).isEmpty()) {
|
||||
info.setReturnValue(false);
|
||||
break;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.LevelProperties;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(LevelProperties.class)
|
||||
public class MixinLevelProperties implements TimeDilaterItem.DilatedWorld {
|
||||
@Unique
|
||||
private TimeDilaterItem.TimeSpeed timeSpeed = TimeDilaterItem.TimeSpeed.NORMAL;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "<init>(Lnet/minecraft/nbt/CompoundTag;Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;)V")
|
||||
public void init(CompoundTag compoundTag, DataFixer dataFixer, int i, CompoundTag compoundTag2, CallbackInfo info) {
|
||||
try {
|
||||
timeSpeed = TimeDilaterItem.TimeSpeed.valueOf(compoundTag.getString("RelicCraftTimeSpeed"));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "updateProperties")
|
||||
public void updateProperties(CompoundTag levelTag, CompoundTag playerTag, CallbackInfo ci) {
|
||||
levelTag.putString("RelicCraftTimeSpeed", timeSpeed.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeDilaterItem.TimeSpeed getTimeSpeed() {
|
||||
return timeSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeSpeed(TimeDilaterItem.TimeSpeed timeSpeed) {
|
||||
this.timeSpeed = timeSpeed;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.LocateCommand;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(LocateCommand.class)
|
||||
public abstract class MixinLocateCommand {
|
||||
@Shadow
|
||||
private static int execute(ServerCommandSource source, String structure) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Inject(method = "register", at = @At(value = "RETURN"))
|
||||
private static void onRegister(CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo info) {
|
||||
dispatcher.register(CommandManager.literal("locate").requires(source -> source.hasPermissionLevel(2))
|
||||
.then(CommandManager.literal("RelicCraft_Time_Temple").executes(ctx -> execute(ctx.getSource(), RelicCraft.TIME_TEMPLE_ID))));
|
||||
}
|
||||
}
|
@ -15,8 +15,8 @@ public abstract class MixinServerChunkManager {
|
||||
@Shadow
|
||||
public abstract World getWorld();
|
||||
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getInt(Lnet/minecraft/world/GameRules$Key;)I"), method = "tickChunks")
|
||||
public int adjustRandomTickSpeed(GameRules gameRules, GameRules.Key<GameRules.IntRule> rule) {
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getInt(Lnet/minecraft/world/GameRules$RuleKey;)I"), method = "tickChunks")
|
||||
public int adjustRandomTickSpeed(GameRules gameRules, GameRules.RuleKey<GameRules.IntRule> rule) {
|
||||
if (rule.equals(GameRules.RANDOM_TICK_SPEED)) {
|
||||
return (int) (gameRules.getInt(rule) * TimeDilaterItem.getTimeDilationFactor(((TimeDilaterItem.DilatedWorld) getWorld()).getTimeSpeed()));
|
||||
} else {
|
||||
|
@ -1,17 +1,10 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
|
||||
import com.thebrokenrail.reliccraft.packet.UpdateTimeDilationS2CPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
@ -19,31 +12,8 @@ import java.util.function.BooleanSupplier;
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(ServerWorld.class)
|
||||
public abstract class MixinServerWorld extends MixinWorld {
|
||||
@Unique
|
||||
private TimeDilaterItem.TimeSpeedState timeSpeedState;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "tick")
|
||||
public void tick(BooleanSupplier shouldKeepTicking, CallbackInfo info) {
|
||||
UpdateTimeDilationS2CPacket.send((ServerWorld) (Object) this, getTimeSpeed());
|
||||
}
|
||||
|
||||
@ModifyConstant(constant = @Constant(longValue = 1L), method = "tickTime")
|
||||
public long tickTime(long value) {
|
||||
return value * TimeDilaterItem.getTimeDilationFactor(getTimeSpeed());
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract MinecraftServer getServer();
|
||||
|
||||
@Override
|
||||
public void setTimeSpeed(TimeDilaterItem.TimeSpeed timeSpeed) {
|
||||
TimeDilaterItem.TimeSpeedState state = getServer().getWorld(World.OVERWORLD).getPersistentStateManager().getOrCreate(TimeDilaterItem.TimeSpeedState::new, TimeDilaterItem.TIME_SPEED_KEY);
|
||||
state.setTimeSpeed(timeSpeed);
|
||||
getServer().getWorld(World.OVERWORLD).getPersistentStateManager().set(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeDilaterItem.TimeSpeed getTimeSpeed() {
|
||||
return getServer().getWorld(World.OVERWORLD).getPersistentStateManager().getOrCreate(TimeDilaterItem.TimeSpeedState::new, TimeDilaterItem.TIME_SPEED_KEY).getTimeSpeed();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.block.TeleportationRestrictorBlock;
|
||||
import net.minecraft.entity.projectile.thrown.EnderPearlEntity;
|
||||
import net.minecraft.entity.thrown.ThrownEnderpearlEntity;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -9,12 +9,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(EnderPearlEntity.class)
|
||||
@Mixin(ThrownEnderpearlEntity.class)
|
||||
public class MixinThrownEnderpearlEntity {
|
||||
@Inject(at = @At("HEAD"), method = "onCollision", cancellable = true)
|
||||
public void onCollision(HitResult hitResult, CallbackInfo info) {
|
||||
if (((TeleportationRestrictorBlock.TeleportingEntity) this).cannotTeleport()) {
|
||||
((EnderPearlEntity) (Object) this).remove();
|
||||
((ThrownEnderpearlEntity) (Object) this).remove();
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import com.thebrokenrail.reliccraft.item.TimeDilaterItem;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.LevelProperties;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(World.class)
|
||||
@ -12,19 +15,25 @@ public abstract class MixinWorld implements TimeDilaterItem.DilatedWorld {
|
||||
@Shadow
|
||||
public abstract boolean isClient();
|
||||
|
||||
@Unique
|
||||
private TimeDilaterItem.TimeSpeed timeSpeed = TimeDilaterItem.TimeSpeed.NORMAL;
|
||||
@Shadow
|
||||
@Final
|
||||
protected LevelProperties properties;
|
||||
|
||||
@Shadow
|
||||
public abstract long getTime();
|
||||
|
||||
@ModifyConstant(constant = @Constant(longValue = 1L), method = "tickTime")
|
||||
public long tickTime(long value) {
|
||||
return value * TimeDilaterItem.getTimeDilationFactor(getTimeSpeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeSpeed(TimeDilaterItem.TimeSpeed timeSpeed) {
|
||||
this.timeSpeed = timeSpeed;
|
||||
((TimeDilaterItem.DilatedWorld) properties).setTimeSpeed(timeSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeDilaterItem.TimeSpeed getTimeSpeed() {
|
||||
return timeSpeed;
|
||||
return ((TimeDilaterItem.DilatedWorld) properties).getTimeSpeed();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.thebrokenrail.reliccraft.mixin;
|
||||
|
||||
import net.minecraft.client.item.ModelPredicateProvider;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ModelPredicateProviderRegistry.class)
|
||||
public interface ModelPredicateProviderRegistryHook {
|
||||
@Invoker
|
||||
static void callRegister(Item item, Identifier id, ModelPredicateProvider provider) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -10,9 +10,9 @@ import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -11,8 +11,8 @@ import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.SpecialCraftingRecipe;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
@ -27,8 +27,8 @@ public class RevealRelicRecipe extends SpecialCraftingRecipe {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
int netherStar = 0;
|
||||
|
||||
for (int i = 0; i < craftingInventory.size(); ++i) {
|
||||
ItemStack itemStack2 = craftingInventory.getStack(i);
|
||||
for (int i = 0; i < craftingInventory.getInvSize(); ++i) {
|
||||
ItemStack itemStack2 = craftingInventory.getInvStack(i);
|
||||
if (!itemStack2.isEmpty()) {
|
||||
if (itemStack2.getItem() instanceof RelicItem) {
|
||||
if (!itemStack.isEmpty()) {
|
||||
@ -51,8 +51,8 @@ public class RevealRelicRecipe extends SpecialCraftingRecipe {
|
||||
public ItemStack craft(CraftingInventory craftingInventory) {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
|
||||
for (int i = 0; i < craftingInventory.size(); i++) {
|
||||
ItemStack itemStack2 = craftingInventory.getStack(i);
|
||||
for (int i = 0; i < craftingInventory.getInvSize(); i++) {
|
||||
ItemStack itemStack2 = craftingInventory.getInvStack(i);
|
||||
if (!itemStack2.isEmpty()) {
|
||||
Item item = itemStack2.getItem();
|
||||
if (item instanceof RelicItem) {
|
||||
@ -92,9 +92,9 @@ public class RevealRelicRecipe extends SpecialCraftingRecipe {
|
||||
|
||||
@Override
|
||||
public DefaultedList<ItemStack> getRemainingStacks(CraftingInventory inventory) {
|
||||
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
|
||||
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.getInvSize(), ItemStack.EMPTY);
|
||||
for (int i = 0; i < defaultedList.size(); i++) {
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
if (stack.getItem().hasRecipeRemainder()) {
|
||||
defaultedList.set(i, new ItemStack(stack.getItem().getRecipeRemainder()));
|
||||
} else if (stack.getItem() == Items.NETHER_STAR && !stack.damage(1, new Random(), null)) {
|
||||
|
@ -8,8 +8,9 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TimeDilaterRecipe extends ShapelessRecipe {
|
||||
@ -38,9 +39,9 @@ public class TimeDilaterRecipe extends ShapelessRecipe {
|
||||
|
||||
@Override
|
||||
public DefaultedList<ItemStack> getRemainingStacks(CraftingInventory inventory) {
|
||||
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
|
||||
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.getInvSize(), ItemStack.EMPTY);
|
||||
for (int i = 0; i < defaultedList.size(); i++) {
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
if (stack.getItem() == Items.NETHER_STAR && !stack.damage(1, new Random(), null) || stack.getItem() == RelicCraft.TIME_DILATER_ITEM) {
|
||||
defaultedList.set(i, stack.copy());
|
||||
}
|
||||
|
@ -1,52 +1,34 @@
|
||||
package com.thebrokenrail.reliccraft.structure;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
import com.thebrokenrail.reliccraft.RelicCraft;
|
||||
import net.minecraft.world.gen.feature.AbstractTempleFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class TimeTempleFeature extends StructureFeature<DefaultFeatureConfig> {
|
||||
public TimeTempleFeature(Codec<DefaultFeatureConfig> codec) {
|
||||
super(codec);
|
||||
public class TimeTempleFeature extends AbstractTempleFeature<DefaultFeatureConfig> {
|
||||
public TimeTempleFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> configFactory) {
|
||||
super(configFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureStartFactory<DefaultFeatureConfig> getStructureStartFactory() {
|
||||
return Start::new;
|
||||
}
|
||||
|
||||
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig defaultFeatureConfig) {
|
||||
int k = i >> 4;
|
||||
int m = j >> 4;
|
||||
chunkRandom.setSeed((long) (k ^ m << 4) ^ l);
|
||||
chunkRandom.nextInt();
|
||||
return chunkRandom.nextInt(5) == 0;
|
||||
}
|
||||
|
||||
public static class Start extends StructureStart<DefaultFeatureConfig> {
|
||||
public Start(StructureFeature<DefaultFeatureConfig> feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) {
|
||||
super(feature, chunkX, chunkZ, box, references, seed);
|
||||
protected int getSeedModifier() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ChunkGenerator chunkGenerator, StructureManager structureManager, int x, int z, Biome biome, DefaultFeatureConfig featureConfig) {
|
||||
int i = x * 16;
|
||||
int j = z * 16;
|
||||
BlockPos blockPos = new BlockPos(i, 90, j);
|
||||
BlockRotation blockRotation = BlockRotation.values()[random.nextInt(BlockRotation.values().length)];
|
||||
TimeTempleGenerator.addPieces(structureManager, blockPos, blockRotation, children);
|
||||
setBoundingBoxFromChildren();
|
||||
public StructureStartFactory getStructureStartFactory() {
|
||||
return TimeTempleStructureStart::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return RelicCraft.TIME_TEMPLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRadius() {
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,11 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.structure.*;
|
||||
import net.minecraft.structure.SimpleStructurePiece;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructurePiece;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.structure.processor.BlockIgnoreStructureProcessor;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
@ -15,9 +19,7 @@ import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -50,7 +52,7 @@ public class TimeTempleGenerator {
|
||||
|
||||
private void initializeStructureData(StructureManager manager) {
|
||||
Structure structure = manager.getStructureOrBlank(template);
|
||||
StructurePlacementData structurePlacementData = new StructurePlacementData().setRotation(rotation).setMirror(BlockMirror.NONE).setIgnoreEntities(true).addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS);
|
||||
StructurePlacementData structurePlacementData = new StructurePlacementData().setRotation(rotation).setMirrored(BlockMirror.NONE).setIgnoreEntities(true).addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS);
|
||||
setStructureData(structure, pos, structurePlacementData);
|
||||
}
|
||||
|
||||
@ -62,31 +64,39 @@ public class TimeTempleGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ServerWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int yHeight = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, this.pos.getX() + 5, this.pos.getZ() + 5);
|
||||
public boolean generate(IWorld world, ChunkGenerator<?> generator, Random random, BlockBox box, ChunkPos chunkPos) {
|
||||
int yHeight = 0;
|
||||
int area = 0;
|
||||
for (int x = getBoundingBox().minX; x <= getBoundingBox().maxX; x++) {
|
||||
for (int z = getBoundingBox().minZ; z <= getBoundingBox().maxZ; z++) {
|
||||
yHeight = yHeight + world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, x, z);
|
||||
area++;
|
||||
}
|
||||
}
|
||||
yHeight = yHeight / area;
|
||||
|
||||
BlockPos originalPos = pos;
|
||||
pos = pos.add(0, yHeight - 90, 0);
|
||||
|
||||
boolean result = super.generate(world, structureAccessor, chunkGenerator, random, boundingBox, chunkPos, blockPos);
|
||||
boolean result = super.generate(world, generator, random, box, chunkPos);
|
||||
|
||||
if (result) {
|
||||
for (int x = getBoundingBox().minX; x <= getBoundingBox().maxX; x++) {
|
||||
for (int y = getBoundingBox().minY; y <= getBoundingBox().maxY; y++) {
|
||||
for (int z = getBoundingBox().minZ; z <= getBoundingBox().maxZ; z++) {
|
||||
BlockPos newPos = new BlockPos(x, y, z);
|
||||
if (boundingBox.contains(newPos)) {
|
||||
BlockState state = world.getBlockState(newPos);
|
||||
BlockPos blockPos = new BlockPos(x, y, z);
|
||||
if (box.contains(blockPos)) {
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
|
||||
boolean damaged = random.nextFloat() < 0.6f;
|
||||
if (damaged) {
|
||||
if (state.getBlock() == Blocks.STONE_BRICKS) {
|
||||
boolean mossy = random.nextFloat() < 0.5f;
|
||||
world.setBlockState(newPos, convertState(state, mossy ? Blocks.MOSSY_STONE_BRICKS : Blocks.CRACKED_STONE_BRICKS), 3);
|
||||
} else if (world.getBlockState(newPos).getBlock() == Blocks.STONE_BRICK_STAIRS) {
|
||||
world.setBlockState(newPos, convertState(state, Blocks.MOSSY_STONE_BRICK_STAIRS), 3);
|
||||
} else if (world.getBlockState(newPos).getBlock() == Blocks.STONE_BRICK_SLAB) {
|
||||
world.setBlockState(newPos, convertState(state, Blocks.MOSSY_STONE_BRICK_SLAB), 3);
|
||||
world.setBlockState(blockPos, convertState(state, mossy ? Blocks.MOSSY_STONE_BRICKS : Blocks.CRACKED_STONE_BRICKS), 3);
|
||||
} else if (world.getBlockState(blockPos).getBlock() == Blocks.STONE_BRICK_STAIRS) {
|
||||
world.setBlockState(blockPos, convertState(state, Blocks.MOSSY_STONE_BRICK_STAIRS), 3);
|
||||
} else if (world.getBlockState(blockPos).getBlock() == Blocks.STONE_BRICK_SLAB) {
|
||||
world.setBlockState(blockPos, convertState(state, Blocks.MOSSY_STONE_BRICK_SLAB), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,7 +121,7 @@ public class TimeTempleGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMetadata(String metadata, BlockPos pos, WorldAccess world, Random random, BlockBox boundingBox) {
|
||||
protected void handleMetadata(String metadata, BlockPos pos, IWorld world, Random random, BlockBox boundingBox) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.thebrokenrail.reliccraft.structure;
|
||||
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
public class TimeTempleStructureStart extends StructureStart {
|
||||
public TimeTempleStructureStart(StructureFeature<?> feature, int chunkX, int chunkZ, BlockBox box, int references, long l) {
|
||||
super(feature, chunkX, chunkZ, box, references, l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(ChunkGenerator<?> chunkGenerator, StructureManager structureManager, int x, int z, Biome biome) {
|
||||
int i = x * 16;
|
||||
int j = z * 16;
|
||||
BlockPos blockPos = new BlockPos(i, 90, j);
|
||||
BlockRotation blockRotation = BlockRotation.values()[random.nextInt(BlockRotation.values().length)];
|
||||
TimeTempleGenerator.addPieces(structureManager, blockPos, blockRotation, children);
|
||||
setBoundingBoxFromChildren();
|
||||
}
|
||||
}
|
@ -29,12 +29,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.4",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.16.x"
|
||||
},
|
||||
"custom": {
|
||||
"modupdater": {
|
||||
"strategy": "curseforge",
|
||||
"projectID": 373074
|
||||
}
|
||||
"minecraft": "1.15.x"
|
||||
}
|
||||
}
|
||||
|
@ -8,19 +8,20 @@
|
||||
"mixins": [
|
||||
"CriteriaRegistryHook",
|
||||
"MixinBlockItem",
|
||||
"MixinClientWorld",
|
||||
"MixinDefaultBiomeFeatures",
|
||||
"MixinEnderDragonFight",
|
||||
"MixinEnderPearlItem",
|
||||
"MixinEntity",
|
||||
"MixinItemStack",
|
||||
"MixinLakeFeature",
|
||||
"MixinLevelProperties",
|
||||
"MixinLivingEntity",
|
||||
"MixinLocateCommand",
|
||||
"MixinNetherStarItem",
|
||||
"MixinServerChunkManager",
|
||||
"MixinServerWorld",
|
||||
"MixinThrownEnderpearlEntity",
|
||||
"MixinWorld",
|
||||
"ModelPredicateProviderRegistryHook"
|
||||
"MixinWorld"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Reference in New Issue
Block a user