mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Refactor damage types
- Replace DamageTypeData with DamageTypeBuilder and CreateDamageSources; make DamageType- and DamageSource-related code more like vanilla - Fix generated DamageType tags assigning all entries as optional - Combine DamageTypeDataProvider and WorldgenDataProvider into GeneratedEntriesProvider
This commit is contained in:
parent
7021a17226
commit
9a70cfff41
@ -1,10 +0,0 @@
|
||||
// 1.20.1 2023-07-04T18:31:12.3273263 Create's Damage Type Data
|
||||
030ede1044384c4117ac1e491bf5c78bbd2842f5 data/create/damage_type/crush.json
|
||||
92b0416950ffeb3ba68811e587177c2f8811c2c5 data/create/damage_type/cuckoo_surprise.json
|
||||
d2a4fdb64f4ba817e13a7b20c73fd1ca34b825fc data/create/damage_type/fan_fire.json
|
||||
d6f22959336e7dd19fc8593c5bad134462f51616 data/create/damage_type/fan_lava.json
|
||||
c884779ba4426b688795c97b01299db17b481fdc data/create/damage_type/mechanical_drill.json
|
||||
afdc8574e8e915dac5693f368e9c1260714ad111 data/create/damage_type/mechanical_roller.json
|
||||
43cfce97a9326a1a7ce95f91a052586610b9686c data/create/damage_type/mechanical_saw.json
|
||||
58ab7a8eed0841f05b4b1373ba159e3e6503b7c3 data/create/damage_type/potato_cannon.json
|
||||
4dae2c0fc9fe6749649ef06dd3b7baaa9bd5e807 data/create/damage_type/run_over.json
|
@ -1,4 +0,0 @@
|
||||
// 1.20.1 2023-08-23T16:37:58.1179329 Tags for minecraft:damage_type mod id create
|
||||
d33fa726908e2795b379ae6226a71ecfd9a5dc40 data/minecraft/tags/damage_type/bypasses_armor.json
|
||||
62231dbbc4e6a21bafe1b3cdb3c86d06ff647ec7 data/minecraft/tags/damage_type/is_explosion.json
|
||||
ad45c55a9cc7883cfcd8b208f735c739f599e1d0 data/minecraft/tags/damage_type/is_fire.json
|
@ -0,0 +1,4 @@
|
||||
// 1.20.1 2023-08-25T18:36:29.7642425 Create's Damage Type Tags
|
||||
7884716b2f4bb1330ff215366bb4bab06e4728c2 data/minecraft/tags/damage_type/bypasses_armor.json
|
||||
1fcad1f89265fba8bdb05b03a1dfcc88d7b7a550 data/minecraft/tags/damage_type/is_explosion.json
|
||||
08324c61115b72bb8a6370d7f34d84d9a31afd16 data/minecraft/tags/damage_type/is_fire.json
|
@ -1,4 +1,13 @@
|
||||
// 1.20.1 2023-07-04T18:31:12.4140931 Create's Worldgen Data
|
||||
// 1.20.1 2023-08-25T18:36:29.766244 Create's Generated Registry Entries
|
||||
030ede1044384c4117ac1e491bf5c78bbd2842f5 data/create/damage_type/crush.json
|
||||
92b0416950ffeb3ba68811e587177c2f8811c2c5 data/create/damage_type/cuckoo_surprise.json
|
||||
d2a4fdb64f4ba817e13a7b20c73fd1ca34b825fc data/create/damage_type/fan_fire.json
|
||||
d6f22959336e7dd19fc8593c5bad134462f51616 data/create/damage_type/fan_lava.json
|
||||
c884779ba4426b688795c97b01299db17b481fdc data/create/damage_type/mechanical_drill.json
|
||||
afdc8574e8e915dac5693f368e9c1260714ad111 data/create/damage_type/mechanical_roller.json
|
||||
43cfce97a9326a1a7ce95f91a052586610b9686c data/create/damage_type/mechanical_saw.json
|
||||
58ab7a8eed0841f05b4b1373ba159e3e6503b7c3 data/create/damage_type/potato_cannon.json
|
||||
4dae2c0fc9fe6749649ef06dd3b7baaa9bd5e807 data/create/damage_type/run_over.json
|
||||
f650826db97d0562230ae0bd965ccbad4c696eff data/create/forge/biome_modifier/striated_ores_nether.json
|
||||
d401f270f1ba0e5d6940aeb8f72ebb3a02dd055e data/create/forge/biome_modifier/striated_ores_overworld.json
|
||||
ed82e4fd3dba36cf2fd81a196cc6670ae0c6da9f data/create/forge/biome_modifier/zinc_ore.json
|
@ -1,24 +1,9 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"id": "create:mechanical_saw",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:mechanical_drill",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:fan_fire",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:crush",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:fan_lava",
|
||||
"required": false
|
||||
}
|
||||
"create:crush",
|
||||
"create:fan_fire",
|
||||
"create:fan_lava",
|
||||
"create:mechanical_drill",
|
||||
"create:mechanical_saw"
|
||||
]
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"id": "create:cuckoo_surprise",
|
||||
"required": false
|
||||
}
|
||||
"create:cuckoo_surprise"
|
||||
]
|
||||
}
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"id": "create:fan_fire",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:fan_lava",
|
||||
"required": false
|
||||
}
|
||||
"create:fan_fire",
|
||||
"create:fan_lava"
|
||||
]
|
||||
}
|
@ -1,54 +1,39 @@
|
||||
package com.simibubi.create;
|
||||
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeData;
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeBuilder;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.damagesource.DamageEffects;
|
||||
import net.minecraft.world.damagesource.DamageScaling;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
|
||||
public class AllDamageTypes {
|
||||
public static final DamageTypeData CUCKOO_SURPRISE = DamageTypeData.builder()
|
||||
.simpleId("cuckoo_surprise")
|
||||
.exhaustion(0.1f)
|
||||
.scaling(DamageScaling.ALWAYS)
|
||||
.tag(DamageTypeTags.IS_EXPLOSION)
|
||||
.build();
|
||||
public static final DamageTypeData CRUSH = DamageTypeData.builder()
|
||||
.simpleId("crush")
|
||||
.scaling(DamageScaling.ALWAYS)
|
||||
.tag(DamageTypeTags.BYPASSES_ARMOR)
|
||||
.build();
|
||||
public static final DamageTypeData DRILL = DamageTypeData.builder()
|
||||
.simpleId("mechanical_drill")
|
||||
.tag(DamageTypeTags.BYPASSES_ARMOR)
|
||||
.build();
|
||||
public static final DamageTypeData FAN_FIRE = DamageTypeData.builder()
|
||||
.simpleId("fan_fire")
|
||||
.effects(DamageEffects.BURNING)
|
||||
.tag(DamageTypeTags.IS_FIRE, DamageTypeTags.BYPASSES_ARMOR)
|
||||
.build();
|
||||
public static final DamageTypeData FAN_LAVA = DamageTypeData.builder()
|
||||
.simpleId("fan_lava")
|
||||
.effects(DamageEffects.BURNING)
|
||||
.tag(DamageTypeTags.IS_FIRE, DamageTypeTags.BYPASSES_ARMOR)
|
||||
.build();
|
||||
public static final DamageTypeData SAW = DamageTypeData.builder()
|
||||
.simpleId("mechanical_saw")
|
||||
.tag(DamageTypeTags.BYPASSES_ARMOR)
|
||||
.build();
|
||||
public static final DamageTypeData ROLLER = DamageTypeData.builder()
|
||||
.simpleId("mechanical_roller")
|
||||
.build();
|
||||
public static final DamageTypeData POTATO_CANNON = DamageTypeData.builder()
|
||||
.simpleId("potato_cannon")
|
||||
.build();
|
||||
public static final DamageTypeData RUN_OVER = DamageTypeData.builder()
|
||||
.simpleId("run_over")
|
||||
.build();
|
||||
public static final ResourceKey<DamageType>
|
||||
CRUSH = key("crush"),
|
||||
CUCKOO_SURPRISE = key("cuckoo_surprise"),
|
||||
FAN_FIRE = key("fan_fire"),
|
||||
FAN_LAVA = key("fan_lava"),
|
||||
DRILL = key("mechanical_drill"),
|
||||
ROLLER = key("mechanical_roller"),
|
||||
SAW = key("mechanical_saw"),
|
||||
POTATO_CANNON = key("potato_cannon"),
|
||||
RUN_OVER = key("run_over");
|
||||
|
||||
private static ResourceKey<DamageType> key(String name) {
|
||||
return ResourceKey.create(Registries.DAMAGE_TYPE, Create.asResource(name));
|
||||
}
|
||||
|
||||
public static void bootstrap(BootstapContext<DamageType> ctx) {
|
||||
DamageTypeData.allInNamespace(Create.ID).forEach(data -> data.register(ctx));
|
||||
new DamageTypeBuilder(CRUSH).scaling(DamageScaling.ALWAYS).register(ctx);
|
||||
new DamageTypeBuilder(CUCKOO_SURPRISE).scaling(DamageScaling.ALWAYS).exhaustion(0.1f).register(ctx);
|
||||
new DamageTypeBuilder(FAN_FIRE).effects(DamageEffects.BURNING).register(ctx);
|
||||
new DamageTypeBuilder(FAN_LAVA).effects(DamageEffects.BURNING).register(ctx);
|
||||
new DamageTypeBuilder(DRILL).register(ctx);
|
||||
new DamageTypeBuilder(ROLLER).register(ctx);
|
||||
new DamageTypeBuilder(SAW).register(ctx);
|
||||
new DamageTypeBuilder(POTATO_CANNON).register(ctx);
|
||||
new DamageTypeBuilder(RUN_OVER).register(ctx);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.simibubi.create;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -26,9 +27,9 @@ import com.simibubi.create.content.trains.bogey.BogeySizes;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.block.CopperRegistries;
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeDataProvider;
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeTagGen;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.DamageTypeTagGen;
|
||||
import com.simibubi.create.foundation.data.GeneratedEntriesProvider;
|
||||
import com.simibubi.create.foundation.data.LangMerger;
|
||||
import com.simibubi.create.foundation.data.RecipeSerializerTagGen;
|
||||
import com.simibubi.create.foundation.data.TagGen;
|
||||
@ -45,8 +46,8 @@ import com.simibubi.create.infrastructure.command.ServerLagger;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllFeatures;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllPlacementModifiers;
|
||||
import com.simibubi.create.infrastructure.worldgen.WorldgenDataProvider;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@ -178,6 +179,7 @@ public class Create {
|
||||
TagGen.datagen();
|
||||
DataGenerator gen = event.getGenerator();
|
||||
PackOutput output = gen.getPackOutput();
|
||||
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
|
||||
|
||||
if (event.includeClient()) {
|
||||
gen.addProvider(true, AllSoundEvents.provider(gen));
|
||||
@ -185,16 +187,17 @@ public class Create {
|
||||
}
|
||||
|
||||
if (event.includeServer()) {
|
||||
gen.addProvider(true, new RecipeSerializerTagGen(output, event.getLookupProvider(), event.getExistingFileHelper()));
|
||||
GeneratedEntriesProvider generatedEntriesProvider = new GeneratedEntriesProvider(output, lookupProvider);
|
||||
lookupProvider = generatedEntriesProvider.getRegistryProvider();
|
||||
gen.addProvider(true, generatedEntriesProvider);
|
||||
|
||||
gen.addProvider(true, new RecipeSerializerTagGen(output, lookupProvider, event.getExistingFileHelper()));
|
||||
gen.addProvider(true, new DamageTypeTagGen(output, lookupProvider, event.getExistingFileHelper()));
|
||||
gen.addProvider(true, new AllAdvancements(output));
|
||||
gen.addProvider(true, new StandardRecipeGen(output));
|
||||
gen.addProvider(true, new MechanicalCraftingRecipeGen(output));
|
||||
gen.addProvider(true, new SequencedAssemblyRecipeGen(output));
|
||||
ProcessingRecipeGen.registerAll(gen, output);
|
||||
gen.addProvider(true, WorldgenDataProvider.makeFactory(event.getLookupProvider()));
|
||||
gen.addProvider(true, DamageTypeDataProvider.makeFactory(event.getLookupProvider()));
|
||||
gen.addProvider(true,
|
||||
new DamageTypeTagGen(output, event.getLookupProvider(), event.getExistingFileHelper()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllMovementBehaviours;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity.ContraptionRotationState;
|
||||
@ -31,6 +30,7 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.collision.ContinuousOBBCollider.ContinuousSeparationManifold;
|
||||
import com.simibubi.create.foundation.collision.Matrix3d;
|
||||
import com.simibubi.create.foundation.collision.OrientedBB;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
@ -530,7 +530,7 @@ public class ContraptionCollider {
|
||||
if (diffMotion.length() <= 0.35f || contraptionMotion.length() <= 0.35f)
|
||||
return entityMotion;
|
||||
|
||||
DamageSource source = AllDamageTypes.RUN_OVER.source(world, contraptionEntity);
|
||||
DamageSource source = CreateDamageSources.runOver(world, contraptionEntity);
|
||||
double damage = diffMotion.length();
|
||||
if (entity.getClassification(false) == MobCategory.MONSTER)
|
||||
damage *= 2;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.simibubi.create.content.contraptions;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
@ -43,7 +43,7 @@ public class TrainCollisionPacket extends SimplePacketBase {
|
||||
if (!(entity instanceof CarriageContraptionEntity cce))
|
||||
return;
|
||||
|
||||
player.hurt(AllDamageTypes.RUN_OVER.source(level, cce), damage);
|
||||
player.hurt(CreateDamageSources.runOver(level, cce), damage);
|
||||
player.level().playSound(player, entity.blockPosition(), SoundEvents.PLAYER_ATTACK_CRIT, SoundSource.NEUTRAL,
|
||||
1, .75f);
|
||||
});
|
||||
|
@ -12,7 +12,6 @@ import javax.annotation.Nullable;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.content.contraptions.actors.roller.RollerBlockEntity.RollingMode;
|
||||
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.pulley.PulleyContraption;
|
||||
@ -31,6 +30,7 @@ import com.simibubi.create.content.trains.entity.TravellingPoint.ITrackSelector;
|
||||
import com.simibubi.create.content.trains.entity.TravellingPoint.SteerDirection;
|
||||
import com.simibubi.create.content.trains.graph.TrackEdge;
|
||||
import com.simibubi.create.content.trains.graph.TrackGraph;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
@ -108,7 +108,7 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||
|
||||
@Override
|
||||
protected DamageSource getDamageSource(Level level) {
|
||||
return AllDamageTypes.ROLLER.source(level);
|
||||
return CreateDamageSources.roller(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,10 +2,10 @@ package com.simibubi.create.content.equipment.potatoCannon;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllEnchantments;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.particle.AirParticleData;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
@ -317,7 +317,7 @@ public class PotatoProjectileEntity extends AbstractHurtingProjectile implements
|
||||
}
|
||||
|
||||
private DamageSource causePotatoDamage() {
|
||||
return AllDamageTypes.POTATO_CANNON.source(level(), getOwner(), this);
|
||||
return CreateDamageSources.potatoCannon(level(), getOwner(), this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -2,10 +2,10 @@ package com.simibubi.create.content.kinetics.clock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
@ -104,7 +104,7 @@ public class CuckooClockBlockEntity extends KineticBlockEntity {
|
||||
if (animationType == Animation.SURPRISE && Mth.equal(animationProgress.getValue(), 50)) {
|
||||
Vec3 center = VecHelper.getCenterOf(worldPosition);
|
||||
level.destroyBlock(worldPosition, false);
|
||||
DamageSource damageSource = AllDamageTypes.CUCKOO_SURPRISE.source(level);
|
||||
DamageSource damageSource = CreateDamageSources.cuckooSurprise(level);
|
||||
level.explode(null, damageSource, null, center.x, center.y, center.z, 3, false,
|
||||
ExplosionInteraction.BLOCK);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@ -58,14 +59,16 @@ public class CrushingWheelBlockEntity extends KineticBlockEntity {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void crushingIsFortunate(LootingLevelEvent event) {
|
||||
if (!AllDamageTypes.CRUSH.is(event.getDamageSource()))
|
||||
DamageSource damageSource = event.getDamageSource();
|
||||
if (damageSource == null || !damageSource.is(AllDamageTypes.CRUSH))
|
||||
return;
|
||||
event.setLootingLevel(2); //This does not currently increase mob drops. It seems like this only works for damage done by an entity.
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleCrushedMobDrops(LivingDropsEvent event) {
|
||||
if (!AllDamageTypes.CRUSH.is(event.getSource()))
|
||||
DamageSource damageSource = event.getSource();
|
||||
if (damageSource == null || !damageSource.is(AllDamageTypes.CRUSH))
|
||||
return;
|
||||
Vec3 outSpeed = Vec3.ZERO;
|
||||
for (ItemEntity outputItem : event.getDrops()) {
|
||||
|
@ -5,13 +5,13 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingInventory;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.sound.SoundScapes;
|
||||
import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup;
|
||||
@ -231,7 +231,7 @@ public class CrushingWheelControllerBlockEntity extends SmartBlockEntity {
|
||||
processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z);
|
||||
}
|
||||
}
|
||||
processingEntity.hurt(AllDamageTypes.CRUSH.source(level), crusherDamage);
|
||||
processingEntity.hurt(CreateDamageSources.crush(level), crusherDamage);
|
||||
if (!processingEntity.isAlive()) {
|
||||
processingEntity.setPos(entityOutPos.x, entityOutPos.y, entityOutPos.z);
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.simibubi.create.AllBlockEntityTypes;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.content.kinetics.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.placement.IPlacementHelper;
|
||||
import com.simibubi.create.foundation.placement.PlacementHelpers;
|
||||
import com.simibubi.create.foundation.placement.PlacementOffset;
|
||||
@ -67,7 +67,7 @@ public class DrillBlock extends DirectionalKineticBlock implements IBE<DrillBloc
|
||||
withBlockEntityDo(worldIn, pos, be -> {
|
||||
if (be.getSpeed() == 0)
|
||||
return;
|
||||
entityIn.hurt(AllDamageTypes.DRILL.source(worldIn), (float) getDamage(be.getSpeed()));
|
||||
entityIn.hurt(CreateDamageSources.drill(worldIn), (float) getDamage(be.getSpeed()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,13 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.render.ActorInstance;
|
||||
import com.simibubi.create.content.contraptions.render.ContraptionMatrices;
|
||||
import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@ -58,7 +58,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||
|
||||
@Override
|
||||
protected DamageSource getDamageSource(Level level) {
|
||||
return AllDamageTypes.DRILL.source(level);
|
||||
return CreateDamageSources.drill(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,13 +11,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllRecipeTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.kinetics.fan.processing.HauntingRecipe.HauntingWrapper;
|
||||
import com.simibubi.create.content.kinetics.fan.processing.SplashingRecipe.SplashingWrapper;
|
||||
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.processing.burner.LitBlazeBurnerBlock;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.recipe.RecipeApplier;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
@ -223,7 +223,7 @@ public class AllFanProcessingTypes {
|
||||
|
||||
if (!entity.fireImmune()) {
|
||||
entity.setSecondsOnFire(10);
|
||||
entity.hurt(AllDamageTypes.FAN_LAVA.source(level), 4);
|
||||
entity.hurt(CreateDamageSources.fanLava(level), 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,7 +409,7 @@ public class AllFanProcessingTypes {
|
||||
|
||||
if (!entity.fireImmune()) {
|
||||
entity.setSecondsOnFire(2);
|
||||
entity.hurt(AllDamageTypes.FAN_FIRE.source(level), 2);
|
||||
entity.hurt(CreateDamageSources.fanFire(level), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.simibubi.create.AllBlockEntityTypes;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock;
|
||||
import com.simibubi.create.content.kinetics.drill.DrillBlock;
|
||||
import com.simibubi.create.foundation.block.IBE;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.placement.IPlacementHelper;
|
||||
import com.simibubi.create.foundation.placement.PlacementHelpers;
|
||||
import com.simibubi.create.foundation.placement.PlacementOffset;
|
||||
@ -161,7 +161,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IBE<SawBloc
|
||||
withBlockEntityDo(worldIn, pos, be -> {
|
||||
if (be.getSpeed() == 0)
|
||||
return;
|
||||
entityIn.hurt(AllDamageTypes.SAW.source(worldIn), (float) DrillBlock.getDamage(be.getSpeed()));
|
||||
entityIn.hurt(CreateDamageSources.saw(worldIn), (float) DrillBlock.getDamage(be.getSpeed()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@ package com.simibubi.create.content.kinetics.saw;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.render.ContraptionMatrices;
|
||||
import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour;
|
||||
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
|
||||
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
|
||||
import com.simibubi.create.foundation.utility.TreeCutter;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
@ -104,6 +104,6 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||
|
||||
@Override
|
||||
protected DamageSource getDamageSource(Level level) {
|
||||
return AllDamageTypes.SAW.source(level);
|
||||
return CreateDamageSources.saw(level);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.simibubi.create.foundation.damageTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
|
||||
public class CreateDamageSources {
|
||||
public static DamageSource crush(Level level) {
|
||||
return source(AllDamageTypes.CRUSH, level);
|
||||
}
|
||||
|
||||
public static DamageSource cuckooSurprise(Level level) {
|
||||
return source(AllDamageTypes.CUCKOO_SURPRISE, level);
|
||||
}
|
||||
|
||||
public static DamageSource fanFire(Level level) {
|
||||
return source(AllDamageTypes.FAN_FIRE, level);
|
||||
}
|
||||
|
||||
public static DamageSource fanLava(Level level) {
|
||||
return source(AllDamageTypes.FAN_LAVA, level);
|
||||
}
|
||||
|
||||
public static DamageSource drill(Level level) {
|
||||
return source(AllDamageTypes.DRILL, level);
|
||||
}
|
||||
|
||||
public static DamageSource roller(Level level) {
|
||||
return source(AllDamageTypes.ROLLER, level);
|
||||
}
|
||||
|
||||
public static DamageSource saw(Level level) {
|
||||
return source(AllDamageTypes.SAW, level);
|
||||
}
|
||||
|
||||
public static DamageSource potatoCannon(Level level, Entity causingEntity, Entity directEntity) {
|
||||
return source(AllDamageTypes.POTATO_CANNON, level, causingEntity, directEntity);
|
||||
}
|
||||
|
||||
public static DamageSource runOver(Level level, Entity entity) {
|
||||
return source(AllDamageTypes.RUN_OVER, level, entity);
|
||||
}
|
||||
|
||||
private static DamageSource source(ResourceKey<DamageType> key, LevelReader level) {
|
||||
Registry<DamageType> registry = level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE);
|
||||
return new DamageSource(registry.getHolderOrThrow(key));
|
||||
}
|
||||
|
||||
private static DamageSource source(ResourceKey<DamageType> key, LevelReader level, @Nullable Entity entity) {
|
||||
Registry<DamageType> registry = level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE);
|
||||
return new DamageSource(registry.getHolderOrThrow(key), entity);
|
||||
}
|
||||
|
||||
private static DamageSource source(ResourceKey<DamageType> key, LevelReader level, @Nullable Entity causingEntity, @Nullable Entity directEntity) {
|
||||
Registry<DamageType> registry = level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE);
|
||||
return new DamageSource(registry.getHolderOrThrow(key), causingEntity, directEntity);
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.simibubi.create.foundation.damageTypes;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.damagesource.CombatEntry;
|
||||
import net.minecraft.world.damagesource.CombatTracker;
|
||||
import net.minecraft.world.damagesource.DamageEffects;
|
||||
import net.minecraft.world.damagesource.DamageScaling;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.damagesource.DeathMessageType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class DamageTypeBuilder {
|
||||
protected final ResourceKey<DamageType> key;
|
||||
|
||||
protected String msgId;
|
||||
protected DamageScaling scaling;
|
||||
protected float exhaustion = 0.0f;
|
||||
protected DamageEffects effects;
|
||||
protected DeathMessageType deathMessageType;
|
||||
|
||||
public DamageTypeBuilder(ResourceKey<DamageType> key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message ID. this is used for death message lang keys.
|
||||
*
|
||||
* @see #deathMessageType(DeathMessageType)
|
||||
*/
|
||||
public DamageTypeBuilder msgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DamageTypeBuilder simpleMsgId() {
|
||||
return msgId(key.location().getNamespace() + "." + key.location().getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scaling of this type. This determines whether damage is increased based on difficulty or not.
|
||||
*/
|
||||
public DamageTypeBuilder scaling(DamageScaling scaling) {
|
||||
this.scaling = scaling;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exhaustion of this type. This is the amount of hunger that will be consumed when an entity is damaged.
|
||||
*/
|
||||
public DamageTypeBuilder exhaustion(float exhaustion) {
|
||||
this.exhaustion = exhaustion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the effects of this type. This determines the sound that plays when damaged.
|
||||
*/
|
||||
public DamageTypeBuilder effects(DamageEffects effects) {
|
||||
this.effects = effects;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the death message type of this damage type. This determines how a death message lang key is assembled.
|
||||
* <ul>
|
||||
* <li>{@link DeathMessageType#DEFAULT}: {@link DamageSource#getLocalizedDeathMessage}</li>
|
||||
* <li>{@link DeathMessageType#FALL_VARIANTS}: {@link CombatTracker#getFallMessage(CombatEntry, Entity)}</li>
|
||||
* <li>{@link DeathMessageType#INTENTIONAL_GAME_DESIGN}: "death.attack." + msgId, wrapped in brackets, linking to MCPE-28723</li>
|
||||
* </ul>
|
||||
*/
|
||||
public DamageTypeBuilder deathMessageType(DeathMessageType deathMessageType) {
|
||||
this.deathMessageType = deathMessageType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DamageType build() {
|
||||
if (msgId == null) {
|
||||
simpleMsgId();
|
||||
}
|
||||
if (scaling == null) {
|
||||
scaling(DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER);
|
||||
}
|
||||
if (effects == null) {
|
||||
effects(DamageEffects.HURT);
|
||||
}
|
||||
if (deathMessageType == null) {
|
||||
deathMessageType(DeathMessageType.DEFAULT);
|
||||
}
|
||||
return new DamageType(msgId, scaling, exhaustion, effects, deathMessageType);
|
||||
}
|
||||
|
||||
public DamageType register(BootstapContext<DamageType> ctx) {
|
||||
DamageType type = build();
|
||||
ctx.register(key, type);
|
||||
return type;
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
package com.simibubi.create.foundation.damageTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.utility.WorldAttached;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.damagesource.CombatEntry;
|
||||
import net.minecraft.world.damagesource.CombatTracker;
|
||||
import net.minecraft.world.damagesource.DamageEffects;
|
||||
import net.minecraft.world.damagesource.DamageScaling;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageSources;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraft.world.damagesource.DeathMessageType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
/**
|
||||
* An extension of {@link DamageType} that contains extra data, functionality, and utility.
|
||||
* @see DamageType
|
||||
* @see DamageSource
|
||||
* @see DamageSources
|
||||
*/
|
||||
public class DamageTypeData {
|
||||
private static final List<DamageTypeData> all = new ArrayList<>();
|
||||
|
||||
public final ResourceKey<DamageType> key;
|
||||
public final ResourceLocation id;
|
||||
public final DamageType type;
|
||||
public final Collection<TagKey<DamageType>> tags;
|
||||
|
||||
private Holder<DamageType> holder;
|
||||
|
||||
private final WorldAttached<DamageSource> staticSources;
|
||||
|
||||
protected DamageTypeData(ResourceKey<DamageType> key, DamageType type, Collection<TagKey<DamageType>> tags) {
|
||||
this.key = key;
|
||||
this.id = key.location();
|
||||
this.type = type;
|
||||
this.tags = tags;
|
||||
this.staticSources = new WorldAttached<>(level -> new DamageSource(getHolder(level)));
|
||||
}
|
||||
|
||||
public DamageSource source(LevelAccessor level) {
|
||||
return staticSources.get(level);
|
||||
}
|
||||
|
||||
public DamageSource source(LevelAccessor level, @Nullable Entity entity) {
|
||||
return new DamageSource(getHolder(level), entity);
|
||||
}
|
||||
|
||||
public DamageSource source(LevelAccessor level, @Nullable Entity cause, @Nullable Entity direct) {
|
||||
return new DamageSource(getHolder(level), cause, direct);
|
||||
}
|
||||
|
||||
private Holder<DamageType> getHolder(LevelAccessor level) {
|
||||
if (this.holder == null) {
|
||||
Registry<DamageType> registry = level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE);
|
||||
this.holder = registry.getHolderOrThrow(key);
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
public boolean is(@Nullable DamageSource source) {
|
||||
return source != null && is(source.type());
|
||||
}
|
||||
|
||||
public boolean is(DamageType type) {
|
||||
return this.type.equals(type);
|
||||
}
|
||||
|
||||
public void register(BootstapContext<DamageType> ctx) {
|
||||
ctx.register(this.key, this.type);
|
||||
}
|
||||
|
||||
public static Stream<DamageTypeData> allInNamespace(String namespace) {
|
||||
return all.stream().filter(data -> data.id.getNamespace().equals(namespace));
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
// required
|
||||
private String msgId;
|
||||
private ResourceLocation location;
|
||||
// defaulted
|
||||
private float exhaustion = 0;
|
||||
private DamageScaling scaling = DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER;
|
||||
private DamageEffects effects = DamageEffects.HURT;
|
||||
private DeathMessageType deathMessageType = DeathMessageType.DEFAULT;
|
||||
private final List<TagKey<DamageType>> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Set the ResourceLocation or ID of this type. This is a required field.
|
||||
*/
|
||||
public Builder location(ResourceLocation location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder location(String path) {
|
||||
return location(Create.asResource(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set both the location and msgId of this type from one ResourceLocation.
|
||||
* The msgId is set to "namespace.path".
|
||||
*/
|
||||
public Builder simpleId(ResourceLocation location) {
|
||||
location(location);
|
||||
return msgId(location.getNamespace() + '.' + location.getPath());
|
||||
}
|
||||
|
||||
public Builder simpleId(String path) {
|
||||
return simpleId(Create.asResource(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message ID. this is used for death message lang keys. This is a required field.
|
||||
*
|
||||
* @see #deathMessageType(DeathMessageType)
|
||||
*/
|
||||
public Builder msgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exhaustion of this type. This is the amount of hunger that will be consumed when an entity is damaged.
|
||||
*/
|
||||
public Builder exhaustion(float exhaustion) {
|
||||
this.exhaustion = exhaustion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scaling of this type. This determines whether damage is increased based on difficulty or not.
|
||||
*/
|
||||
public Builder scaling(DamageScaling scaling) {
|
||||
this.scaling = scaling;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the effects of this type. This determines the sound that plays when damaged.
|
||||
*/
|
||||
public Builder effects(DamageEffects effects) {
|
||||
this.effects = effects;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the death message type of this damage type. This determines how a death message lang key is assembled.
|
||||
* <ul>
|
||||
* <li>{@link DeathMessageType#DEFAULT}: {@link DamageSource#getLocalizedDeathMessage}</li>
|
||||
* <li>{@link DeathMessageType#FALL_VARIANTS}: {@link CombatTracker#getFallMessage(CombatEntry, Entity)}</li>
|
||||
* <li>{@link DeathMessageType#INTENTIONAL_GAME_DESIGN}: "death.attack." + msgId, wrapped in brackets, linking to MCPE-28723</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
public Builder deathMessageType(DeathMessageType type) {
|
||||
this.deathMessageType = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final Builder tag(TagKey<DamageType>... tags) {
|
||||
Collections.addAll(this.tags, tags);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DamageTypeData build() {
|
||||
if (location == null) {
|
||||
throw new IllegalArgumentException("location is required");
|
||||
}
|
||||
if (msgId == null) {
|
||||
throw new IllegalArgumentException("msgId is required");
|
||||
}
|
||||
|
||||
DamageTypeData data = new DamageTypeData(
|
||||
ResourceKey.create(Registries.DAMAGE_TYPE, location),
|
||||
new DamageType(msgId, scaling, exhaustion, effects, deathMessageType),
|
||||
tags
|
||||
);
|
||||
all.add(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.simibubi.create.foundation.damageTypes;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.core.HolderLookup.Provider;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
|
||||
|
||||
public class DamageTypeDataProvider extends DatapackBuiltinEntriesProvider {
|
||||
private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
|
||||
.add(Registries.DAMAGE_TYPE, AllDamageTypes::bootstrap);
|
||||
|
||||
public DamageTypeDataProvider(PackOutput output, CompletableFuture<Provider> registries) {
|
||||
super(output, registries, BUILDER, Set.of(Create.ID));
|
||||
}
|
||||
|
||||
public static DataProvider.Factory<DamageTypeDataProvider> makeFactory(CompletableFuture<Provider> registries) {
|
||||
return output -> new DamageTypeDataProvider(output, registries);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "Create's Damage Type Data";
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.simibubi.create.foundation.damageTypes;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.HolderLookup.Provider;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
public class DamageTypeTagGen extends TagsProvider<DamageType> {
|
||||
private final String namespace;
|
||||
|
||||
public DamageTypeTagGen(String namespace, PackOutput pOutput,
|
||||
CompletableFuture<HolderLookup.Provider> pLookupProvider, ExistingFileHelper existingFileHelper) {
|
||||
super(pOutput, Registries.DAMAGE_TYPE, pLookupProvider, namespace, existingFileHelper);
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
public DamageTypeTagGen(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pLookupProvider,
|
||||
ExistingFileHelper existingFileHelper) {
|
||||
this(Create.ID, pOutput, pLookupProvider, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags(@NotNull Provider provider) {
|
||||
Multimap<TagKey<DamageType>, ResourceKey<DamageType>> tagsToTypes = HashMultimap.create();
|
||||
DamageTypeData.allInNamespace(namespace)
|
||||
.forEach(data -> data.tags.forEach(tag -> tagsToTypes.put(tag, data.key)));
|
||||
tagsToTypes.asMap()
|
||||
.forEach((tag, keys) -> {
|
||||
TagAppender<DamageType> appender = tag(tag);
|
||||
keys.forEach(key -> appender.addOptional(key.location())); // FIXME: 1.20 usind add() results in datagen failure, is this approach correct?
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.world.damagesource.DamageType;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
public class DamageTypeTagGen extends TagsProvider<DamageType> {
|
||||
public DamageTypeTagGen(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(output, Registries.DAMAGE_TYPE, lookupProvider, Create.ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags(HolderLookup.Provider provider) {
|
||||
tag(DamageTypeTags.BYPASSES_ARMOR)
|
||||
.add(AllDamageTypes.CRUSH, AllDamageTypes.FAN_FIRE, AllDamageTypes.FAN_LAVA, AllDamageTypes.DRILL, AllDamageTypes.SAW);
|
||||
tag(DamageTypeTags.IS_FIRE)
|
||||
.add(AllDamageTypes.FAN_FIRE, AllDamageTypes.FAN_LAVA);
|
||||
tag(DamageTypeTags.IS_EXPLOSION)
|
||||
.add(AllDamageTypes.CUCKOO_SURPRISE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Create's Damage Type Tags";
|
||||
}
|
||||
}
|
@ -1,36 +1,36 @@
|
||||
package com.simibubi.create.infrastructure.worldgen;
|
||||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.simibubi.create.AllDamageTypes;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllBiomeModifiers;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllConfiguredFeatures;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllPlacedFeatures;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.RegistrySetBuilder.RegistryBootstrap;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class WorldgenDataProvider extends DatapackBuiltinEntriesProvider {
|
||||
public class GeneratedEntriesProvider extends DatapackBuiltinEntriesProvider {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
|
||||
.add(Registries.DAMAGE_TYPE, AllDamageTypes::bootstrap)
|
||||
.add(Registries.CONFIGURED_FEATURE, (RegistryBootstrap) AllConfiguredFeatures::bootstrap)
|
||||
.add(Registries.PLACED_FEATURE, AllPlacedFeatures::bootstrap)
|
||||
.add(ForgeRegistries.Keys.BIOME_MODIFIERS, AllBiomeModifiers::bootstrap);
|
||||
|
||||
public WorldgenDataProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
|
||||
public GeneratedEntriesProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
|
||||
super(output, registries, BUILDER, Set.of(Create.ID));
|
||||
}
|
||||
|
||||
public static DataProvider.Factory<WorldgenDataProvider> makeFactory(CompletableFuture<HolderLookup.Provider> registries) {
|
||||
return output -> new WorldgenDataProvider(output, registries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Create's Worldgen Data";
|
||||
return "Create's Generated Registry Entries";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user