mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
Compare commits
5 commits
d82640a843
...
ea83a876f8
Author | SHA1 | Date | |
---|---|---|---|
ea83a876f8 | |||
fbbf793e36 | |||
a24d73dc77 | |||
d334272467 | |||
d3023d9661 |
6 changed files with 37 additions and 35 deletions
|
@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '36.2'
|
version = '36.3'
|
||||||
group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = 'NaturesAura'
|
archivesBaseName = 'NaturesAura'
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.api.misc.WeatherType;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -52,7 +53,7 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
|
||||||
if (this.processTime > 0) {
|
if (this.processTime > 0) {
|
||||||
if (this.processTime % 20 == 0) {
|
if (this.processTime % 20 == 0) {
|
||||||
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
|
||||||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * this.itemAmount);
|
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * Mth.ceil(this.itemAmount * 0.75F));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.processTime--;
|
this.processTime--;
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
@Override
|
@Override
|
||||||
public void onRemovedFromWorld() {
|
public void onRemovedFromWorld() {
|
||||||
super.onRemovedFromWorld();
|
super.onRemovedFromWorld();
|
||||||
this.setInhibitedEffect(null);
|
// we pass a null effect because we want to remove our effect from the world
|
||||||
this.updatePowderListStatus();
|
this.updatePowderListStatus(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +92,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (this.powderListDirty)
|
if (this.powderListDirty)
|
||||||
this.updatePowderListStatus();
|
this.updatePowderListStatus(this.getInhibitedEffect());
|
||||||
|
|
||||||
if (this.level.isClientSide) {
|
if (this.level.isClientSide) {
|
||||||
if (this.level.getGameTime() % 5 == 0) {
|
if (this.level.getGameTime() % 5 == 0) {
|
||||||
|
@ -199,18 +199,17 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
return this.getColor();
|
return this.getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePowderListStatus() {
|
private void updatePowderListStatus(ResourceLocation inhibitedEffect) {
|
||||||
var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders;
|
var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders;
|
||||||
if (this.lastEffect != null) {
|
if (this.lastEffect != null) {
|
||||||
var oldList = powders.get(this.lastEffect);
|
var oldList = powders.get(this.lastEffect);
|
||||||
oldList.removeIf(t -> this.getEyePosition().equals(t.getA()));
|
oldList.removeIf(t -> this.getEyePosition().equals(t.getA()));
|
||||||
}
|
}
|
||||||
var effect = this.getInhibitedEffect();
|
if (inhibitedEffect != null) {
|
||||||
if (effect != null) {
|
var newList = powders.get(inhibitedEffect);
|
||||||
var newList = powders.get(effect);
|
|
||||||
newList.add(new Tuple<>(this.getEyePosition(), this.getAmount()));
|
newList.add(new Tuple<>(this.getEyePosition(), this.getAmount()));
|
||||||
}
|
}
|
||||||
this.powderListDirty = false;
|
this.powderListDirty = false;
|
||||||
this.lastEffect = effect;
|
this.lastEffect = inhibitedEffect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,23 +326,20 @@ public class ClientEvents {
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
|
|
||||||
if (!heldOcular.isEmpty()) {
|
if (!heldOcular.isEmpty()) {
|
||||||
var scale = 0.75F;
|
|
||||||
stack.pushPose();
|
stack.pushPose();
|
||||||
stack.scale(scale, scale, scale);
|
//stack.scale(scale, scale, scale);
|
||||||
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
|
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
|
||||||
var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55;
|
var stackY = conf < 2 ? 10 : res.getGuiScaledHeight() - 60;
|
||||||
for (var effect : SHOWING_EFFECTS.values()) {
|
for (var effect : SHOWING_EFFECTS.values()) {
|
||||||
var theX = (int) (stackX / scale);
|
|
||||||
var theY = (int) (stackY / scale);
|
|
||||||
var itemStack = effect.getA();
|
var itemStack = effect.getA();
|
||||||
Helper.renderItemInGui(itemStack, theX, theY, 1F);
|
Helper.renderItemInGui(itemStack, stackX, stackY, 1F);
|
||||||
if (effect.getB()) {
|
if (effect.getB()) {
|
||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
RenderSystem.setShaderTexture(0, OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
|
Screen.blit(stack, stackX, stackY, 240, 0, 16, 16, 256, 256);
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
}
|
}
|
||||||
stackY += 8;
|
stackY += 12;
|
||||||
}
|
}
|
||||||
stack.popPose();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@ package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
|
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
|
||||||
import de.ellpeck.naturesaura.entities.ModEntities;
|
import de.ellpeck.naturesaura.entities.ModEntities;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.HolderSet;
|
import net.minecraft.core.HolderSet;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -15,13 +16,13 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||||
|
|
||||||
public class ItemStructureFinder extends ItemImpl {
|
public class ItemStructureFinder extends ItemImpl {
|
||||||
|
|
||||||
private final Holder<ConfiguredStructureFeature<?, ?>> structureName;
|
private final ResourceKey<ConfiguredStructureFeature<?, ?>> structure;
|
||||||
private final int color;
|
private final int color;
|
||||||
private final int radius;
|
private final int radius;
|
||||||
|
|
||||||
public ItemStructureFinder(String baseName, Holder<ConfiguredStructureFeature<?, ?>> structureName, int color, int radius) {
|
public ItemStructureFinder(String baseName, ResourceKey<ConfiguredStructureFeature<?, ?>> structure, int color, int radius) {
|
||||||
super(baseName);
|
super(baseName);
|
||||||
this.structureName = structureName;
|
this.structure = structure;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
@ -30,17 +31,20 @@ public class ItemStructureFinder extends ItemImpl {
|
||||||
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
|
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
|
||||||
var stack = playerIn.getItemInHand(handIn);
|
var stack = playerIn.getItemInHand(handIn);
|
||||||
if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) {
|
if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) {
|
||||||
var holderSet = HolderSet.direct(this.structureName);
|
var registry = levelIn.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
|
||||||
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false);
|
var holderSet = registry.getHolder(this.structure).map(HolderSet::direct).orElse(null);
|
||||||
if (pos != null) {
|
if (holderSet != null) {
|
||||||
var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
|
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false);
|
||||||
entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());
|
if (pos != null) {
|
||||||
entity.setItem(stack);
|
var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
|
||||||
entity.getEntityData().set(EntityStructureFinder.COLOR, this.color);
|
entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());
|
||||||
entity.signalTo(pos.getFirst().above(64));
|
entity.setItem(stack);
|
||||||
levelIn.addFreshEntity(entity);
|
entity.getEntityData().set(EntityStructureFinder.COLOR, this.color);
|
||||||
|
entity.signalTo(pos.getFirst().above(64));
|
||||||
|
levelIn.addFreshEntity(entity);
|
||||||
|
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
||||||
|
|
|
@ -48,6 +48,7 @@ import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
|
||||||
import net.minecraft.world.level.material.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||||
|
@ -219,9 +220,9 @@ public final class ModRegistry {
|
||||||
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST),
|
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST),
|
||||||
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS),
|
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS),
|
||||||
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET),
|
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET),
|
||||||
new ItemStructureFinder("fortress_finder", StructureFeatures.FORTRESS, 0xba2800, 1024),
|
new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024),
|
||||||
new ItemStructureFinder("end_city_finder", StructureFeatures.END_CITY, 0xca5cd6, 1024),
|
new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024),
|
||||||
new ItemStructureFinder("outpost_finder", StructureFeatures.PILLAGER_OUTPOST, 0xab9f98, 2048),
|
new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048),
|
||||||
new ItemBreakPrevention(),
|
new ItemBreakPrevention(),
|
||||||
new ItemPetReviver(),
|
new ItemPetReviver(),
|
||||||
new ItemNetheriteFinder()
|
new ItemNetheriteFinder()
|
||||||
|
|
Loading…
Reference in a new issue