Skip to content
7 changes: 0 additions & 7 deletions src/main/java/twilightforest/item/CustomDamageSwordItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.component.Tool;

//TODO data component-itize this
public class CustomDamageSwordItem extends Item implements CustomDamageProvider {
Expand All @@ -18,11 +16,6 @@ public CustomDamageSwordItem(ResourceKey<DamageType> damageType, Properties prop
this.damageType = damageType;
}

public CustomDamageSwordItem(ResourceKey<DamageType> damageType, Tier tier, Properties properties, Tool toolComponentData) {
super(tier, properties, toolComponentData);
this.damageType = damageType;
}

@Override
public DamageSource getDamageSource(LivingEntity attacker) {
return attacker.damageSources().source(this.damageType, attacker);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/item/EmptyMazeMapItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) {
itemStack.consume(1, player);
player.awardStat(Stats.ITEM_USED.get(this));
serverLevel.playSound(null, player, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, player.getSoundSource(), 1.0F, 1.0F);
ItemStack map = MazeMapItem.setupNewMap(level, Mth.floor(player.getX()), Mth.floor(player.getZ()), (byte) 0, true, false, Mth.floor(player.getY()), this.mapOres);
ItemStack map = MazeMapItem.setupNewMap(serverLevel, Mth.floor(player.getX()), Mth.floor(player.getZ()), (byte) 0, true, false, Mth.floor(player.getY()), this.mapOres);
if (itemStack.isEmpty()) {
return InteractionResult.SUCCESS.heldItemTransformedTo(map);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/twilightforest/item/MagicMapItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static ItemStack setupNewMap(ServerLevel level, int worldX, int worldZ, b
@Nullable
public static TFMagicMapData getData(ItemStack stack, Level level) {
MapId mapid = stack.get(DataComponents.MAP_ID);
// FIXME fix this after fixing TFMagicMapData
return mapid == null ? null : TFMagicMapData.getMagicMapData(level, getMapName(mapid.id()));
}

Expand Down Expand Up @@ -89,6 +90,7 @@ private static TFMagicMapData createMapData(ItemStack stack, ServerLevel level,
ColumnPos pos = getMagicMapCenter(x, z);

TFMagicMapData mapdata = new TFMagicMapData(pos.x(), pos.z(), (byte) scale, trackingPosition, unlimitedTracking, false, dimension);
// FIXME fix this after fixing TFMagicMapData
TFMagicMapData.registerMagicMapData(level, mapdata, getMapName(freeMapId.id())); // call our own register method
stack.set(DataComponents.MAP_ID, freeMapId);
return mapdata;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/twilightforest/item/MazeMapItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static ItemStack setupNewMap(ServerLevel level, int worldX, int worldZ, b
@Nullable
public static TFMazeMapData getData(ItemStack stack, Level level) {
MapId id = stack.get(DataComponents.MAP_ID);
// FIXME fix this after fixing TFMazeMapData
return id == null ? null : TFMazeMapData.getMazeMapData(level, getMapName(id.id()));
}

Expand Down Expand Up @@ -81,6 +82,7 @@ private static TFMazeMapData createMapData(ItemStack stack, ServerLevel level, i
TFMazeMapData mapdata = new TFMazeMapData(scaledX, scaledZ, (byte) scale, trackingPosition, unlimitedTracking, false, dimension);
mapdata.calculateMapCenter(level, x, y, z); // call our own map center calculation
mapdata.ore = ore;
// FIXME fix this after fixing TFMazeMapData
TFMazeMapData.registerMazeMapData(level, mapdata, getMapName(i.id())); // call our own register method
stack.set(DataComponents.MAP_ID, i);
return mapdata;
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/twilightforest/item/MoonDialItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package twilightforest.item;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.attribute.EnvironmentAttributes;
Expand All @@ -9,11 +11,9 @@
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.TooltipDisplay;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.MoonPhase;
import org.jspecify.annotations.Nullable;

import java.time.LocalDate;
import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;
Comment thread
albazavr-alba marked this conversation as resolved.
Outdated

public class MoonDialItem extends Item {
public MoonDialItem(Properties properties) {
Expand All @@ -22,14 +22,15 @@ public MoonDialItem(Properties properties) {

@Override
public void appendHoverText(ItemStack stack, TooltipContext context, TooltipDisplay display, Consumer<Component> builder, TooltipFlag flag) {
builder.accept(getMoonPhase(context.level()).withStyle(ChatFormatting.GRAY));
BlockPos pos = Minecraft.getInstance().player != null ? Minecraft.getInstance().player.blockPosition() : BlockPos.ZERO;
builder.accept(getMoonPhase(context.level(), pos).withStyle(ChatFormatting.GRAY));
}

public static MutableComponent getMoonPhase(@Nullable Level level) {
public static MutableComponent getMoonPhase(@Nullable Level level, BlockPos pos) {
String phaseType;
if (level != null && !level.dimensionType().hasFixedTime()) {
MoonPhase phase = level.environmentAttributes().getDimensionValue(EnvironmentAttributes.MOON_PHASE);
phaseType = phase.getSerializedName();
var phase = level.environmentAttributes().getValue(EnvironmentAttributes.MOON_PHASE, pos);
Comment thread
albazavr-alba marked this conversation as resolved.
Outdated
Comment thread
albazavr-alba marked this conversation as resolved.
Outdated
phaseType = String.valueOf(phase.index());
} else {
boolean aprilFools = LocalDate.of(LocalDate.now().getYear(), 4, 1).equals(LocalDate.now());
phaseType = aprilFools ? "unknown_fools" : "unknown";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;

// FIXME this class should be totally fixed
public class TFMagicMapData extends MapItemSavedData {
private static final Map<String, TFMagicMapData> CLIENT_DATA = new HashMap<>();
public final List<String> conqueredStructures = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Map;

// FIXME this class should be totally fixed
public class TFMazeMapData extends MapItemSavedData {
private static final Map<String, TFMazeMapData> CLIENT_DATA = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public Model<?> getHumanoidArmorModel(ItemStack stack, EquipmentClientInfo.Layer
@Override
public void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, Model model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) {
if (model instanceof TravellersWingsModel wingsModel)
wingsModel.setupModelAnimations(livingEntity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
wingsModel.setupModelAnimations(livingEntity, ageInTicks);
}

private boolean isModelSlim(Model<?> model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EquipmentSlot;
Expand All @@ -26,7 +27,6 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.attachment.AttachmentType;
import net.neoforged.neoforge.common.NeoForgeMod;
import net.neoforged.neoforge.network.PacketDistributor;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static void waterWalkingSplashEffect(LivingEntity livingEntity) {
}

public static boolean isBelowMaxWaterWalkingSubmergedHeight(LivingEntity livingEntity) {
double waterHeight = livingEntity.getFluidTypeHeight(NeoForgeMod.WATER_TYPE.value());
double waterHeight = livingEntity.getFluidHeight(FluidTags.WATER);
return waterHeight < WATER_WALKING_MAX_SUBMERGED_HEIGHT;
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public static void travellersVestHaste(LivingEntity livingEntity) {

public static void travellersBootsUnrestrained(LivingEntity livingEntity) {
if (TravellersModifiersManager.isModifierActive(livingEntity, TravellersModifiersManager.UNRESTRAINED_MODIFIER))
livingEntity.stuckSpeedMultiplier = Vec3.ZERO;
livingEntity.makeStuckInBlock(Blocks.AIR.defaultBlockState(), Vec3.ZERO);
}

public static boolean tryPerformSidestep(Player player, boolean isLeftSidestep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public boolean transfer(ItemStack output, CraftingInput input) {
if (dataComponentProviders.isEmpty())
return false;
if (dataComponentProviders.size() > 1) {
TwilightForestMod.LOGGER.error(String.format("A recipe with more than 2 dataComponentProviders was matched: %s. Please report to https://github.com/TeamTwilight/twilightforest/issues", input));
Comment thread
albazavr-alba marked this conversation as resolved.
TwilightForestMod.LOGGER.error("A recipe with more than 2 dataComponentProviders was matched: {}. Please report to https://github.com/TeamTwilight/twilightforest/issues", input);
return false;
}
ItemStack dataComponentProvider = dataComponentProviders.getFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void removeModifier(ItemStack stack) {
newEntries.add(entry);
}
});
stack.set(DataComponents.ATTRIBUTE_MODIFIERS, new ItemAttributeModifiers(newEntries, modifiers.showInTooltip()));
stack.set(DataComponents.ATTRIBUTE_MODIFIERS, new ItemAttributeModifiers(newEntries));
stack.remove(this.markerComponent());
}
}
Expand Down
Loading