Skip to content

Commit

Permalink
sonorous staff can now be repaired and enchanted
Browse files Browse the repository at this point in the history
  • Loading branch information
NewJumper committed Oct 17, 2024
1 parent 913e335 commit 5a514da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2024-09-03T18:26:51.3070092 Tags for minecraft:item mod id deeperdarker
// 1.21 2024-10-17T10:27:49.2110636 Tags for minecraft:item mod id deeperdarker
9d236ad52ffab14efb6405a34d837dafff77e363 data/c/tags/item/ores.json
ec4e45d46ce1593f9bb4b226a1e3d143bc0942c6 data/c/tags/item/ores/coal.json
dc2be5311ef04baad7565936ffafc6dcea324cf1 data/c/tags/item/ores/copper.json
Expand All @@ -23,7 +23,7 @@ ec4e45d46ce1593f9bb4b226a1e3d143bc0942c6 data/minecraft/tags/item/coal_ores.json
dc2be5311ef04baad7565936ffafc6dcea324cf1 data/minecraft/tags/item/copper_ores.json
84c6024e42063deecc27f59b5a97328b415f4a05 data/minecraft/tags/item/diamond_ores.json
41a0ed1cf9fcf4b0f4e41d3155f010eb069e2edc data/minecraft/tags/item/emerald_ores.json
d0b6527a3244189c04b06295e1dc213419922973 data/minecraft/tags/item/enchantable/durability.json
7b02b576df083630e66072bf2d0f07f1e6ac4a26 data/minecraft/tags/item/enchantable/durability.json
d0b6527a3244189c04b06295e1dc213419922973 data/minecraft/tags/item/enchantable/equippable.json
7dbce4cb80be16ec44f3472f112147a1d7ba8e61 data/minecraft/tags/item/fence_gates.json
81a54dc6ee81c739615aa27a3e28b941ba65077e data/minecraft/tags/item/flowers.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"deeperdarker:soul_elytra"
"deeperdarker:soul_elytra",
"deeperdarker:sonorous_staff"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kyanite.deeperdarker.content.items;

import com.kyanite.deeperdarker.content.DDItems;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
Expand Down Expand Up @@ -86,6 +87,11 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI
}
}

@Override
public boolean isValidRepairItem(ItemStack stack, ItemStack repairCandidate) {
return repairCandidate.is(DDItems.SOUL_CRYSTAL);
}

@Override
public boolean isFoil(ItemStack stack) {
return super.isFoil(stack) || (stack.has(DataComponents.CUSTOM_DATA) && stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag().getBoolean("charged"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static ItemAttributeModifiers createAttributes() {

@Override
public boolean isValidRepairItem(ItemStack toRepair, ItemStack repair) {
return repair.is(DDItems.SOUL_CRYSTAL.get());
return repair.is(DDItems.SOUL_CRYSTAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void addTags(HolderLookup.@NotNull Provider provider) {
tag(ItemTags.CHEST_ARMOR).add(DDItems.RESONARIUM_CHESTPLATE.get(), DDItems.WARDEN_CHESTPLATE.get());
tag(ItemTags.LEG_ARMOR).add(DDItems.RESONARIUM_LEGGINGS.get(), DDItems.WARDEN_LEGGINGS.get());
tag(ItemTags.FOOT_ARMOR).add(DDItems.RESONARIUM_BOOTS.get(), DDItems.WARDEN_BOOTS.get());
tag(ItemTags.DURABILITY_ENCHANTABLE).add(DDItems.SOUL_ELYTRA.get());
tag(ItemTags.DURABILITY_ENCHANTABLE).add(DDItems.SOUL_ELYTRA.get(), DDItems.SONOROUS_STAFF.get());
tag(ItemTags.EQUIPPABLE_ENCHANTABLE).add(DDItems.SOUL_ELYTRA.get());

tag(DDTags.Items.RESONARIUM_ARMOR).add(DDItems.RESONARIUM_HELMET.get(), DDItems.RESONARIUM_CHESTPLATE.get(), DDItems.RESONARIUM_LEGGINGS.get(), DDItems.RESONARIUM_BOOTS.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class OthersideTeleporter {
private static final int PORTAL_HEIGHT = DeeperDarkerConfig.othersidePortalHeight;

public static DimensionTransition getExitPortal(ServerLevel destLevel, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder destBorder) {
Optional<BlockPos> existingPortalPos = findClosestPortalPosition(destLevel, exitPos, destBorder);
Optional<BlockPos> existingPortalPos = findExistingPortal(destLevel, exitPos, destBorder);
BlockUtil.FoundRectangle portal;
DimensionTransition.PostDimensionTransition transition;

Expand Down Expand Up @@ -64,10 +64,10 @@ public static DimensionTransition getExitPortal(ServerLevel destLevel, Entity en
transition = DimensionTransition.PLAY_PORTAL_SOUND.then(DimensionTransition.PLACE_PORTAL_TICKET);
}

return getDimensionTransitionFromExit(entity, pos, portal, destLevel, transition);
return transitionFromExit(entity, pos, portal, destLevel, transition);
}

private static Optional<BlockPos> findClosestPortalPosition(ServerLevel level, BlockPos exitPos, WorldBorder worldBorder) {
private static Optional<BlockPos> findExistingPortal(ServerLevel level, BlockPos exitPos, WorldBorder worldBorder) {
PoiManager poimanager = level.getPoiManager();
poimanager.ensureLoadedAndValid(level, exitPos, 128);
return poimanager.getInSquare(poi -> poi.is(OthersideDimension.OTHERSIDE_PORTAL), exitPos, 128, PoiManager.Occupancy.ANY)
Expand All @@ -77,23 +77,23 @@ private static Optional<BlockPos> findClosestPortalPosition(ServerLevel level, B
.min(Comparator.<BlockPos>comparingDouble(pos -> pos.distSqr(exitPos)).thenComparingInt(Vec3i::getY));
}

private static DimensionTransition getDimensionTransitionFromExit(Entity entity, BlockPos pos, BlockUtil.FoundRectangle rectangle, ServerLevel level, DimensionTransition.PostDimensionTransition postTransition) {
private static DimensionTransition transitionFromExit(Entity entity, BlockPos pos, BlockUtil.FoundRectangle rectangle, ServerLevel level, DimensionTransition.PostDimensionTransition postTransition) {
BlockState state = entity.level().getBlockState(pos);
Direction.Axis axis;
Vec3 vec3;
if(state.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) {
axis = state.getValue(BlockStateProperties.HORIZONTAL_AXIS);
BlockUtil.FoundRectangle portal = BlockUtil.getLargestRectangleAround(pos, axis, MAX_WIDTH, Direction.Axis.Y, MAX_HEIGHT, p_351016_ -> entity.level().getBlockState(p_351016_) == state);
BlockUtil.FoundRectangle portal = BlockUtil.getLargestRectangleAround(pos, axis, MAX_WIDTH, Direction.Axis.Y, MAX_HEIGHT, blockPos -> entity.level().getBlockState(blockPos) == state);
vec3 = entity.getRelativePortalPosition(axis, portal);
} else {
axis = Direction.Axis.X;
vec3 = new Vec3(0.5, 0.0, 0.0);
}

return createDimensionTransition(level, rectangle, axis, vec3, entity, entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), postTransition);
return createTransition(level, rectangle, axis, vec3, entity, entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), postTransition);
}

private static DimensionTransition createDimensionTransition(ServerLevel level, BlockUtil.FoundRectangle rectangle, Direction.Axis axis, Vec3 offset, Entity entity, Vec3 speed, float yRot, float xRot, DimensionTransition.PostDimensionTransition postTransition) {
private static DimensionTransition createTransition(ServerLevel level, BlockUtil.FoundRectangle rectangle, Direction.Axis axis, Vec3 offset, Entity entity, Vec3 speed, float yRot, float xRot, DimensionTransition.PostDimensionTransition postTransition) {
BlockPos cornerPos = rectangle.minCorner;
BlockState cornerState = level.getBlockState(cornerPos);
Direction.Axis axis1 = cornerState.getOptionalValue(BlockStateProperties.HORIZONTAL_AXIS).orElse(Direction.Axis.X);
Expand Down

0 comments on commit 5a514da

Please sign in to comment.