Skip to content

Commit

Permalink
Merge branch '1.6-1.21.1' of https://github.com/cph101/Malum-Mod into…
Browse files Browse the repository at this point in the history
… 1.6-1.21.1
  • Loading branch information
cph101 committed Sep 30, 2024
2 parents 4a43931 + 6533e50 commit 1b6153a
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 53 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
import team.lodestar.lodestone.systems.blockentity.LodestoneBlockEntityInventory;
Expand Down Expand Up @@ -55,4 +56,10 @@ public void render(SpiritAltarBlockEntity blockEntityIn, float partialTicks, Pos
poseStack.popPose();
}
}

@Override
public AABB getRenderBoundingBox(SpiritAltarBlockEntity altar) {
var pos = altar.getBlockPos();
return new AABB(pos.getX() - 1, pos.getY(), pos.getZ() - 1, pos.getX() + 2, pos.getY() + 2, pos.getZ() + 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.world.level.*;
import net.minecraft.world.level.block.state.properties.*;
import org.joml.*;
import team.lodestar.lodestone.registry.client.*;
import team.lodestar.lodestone.systems.easing.*;
import team.lodestar.lodestone.systems.rendering.rendeertype.*;

Expand All @@ -29,7 +28,7 @@ public TotemPoleRenderer(BlockEntityRendererProvider.Context context) {
@Override
public void render(TotemPoleBlockEntity blockEntityIn, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
Direction direction = blockEntityIn.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING);
MalumSpiritType spiritType = blockEntityIn.type;
MalumSpiritType spiritType = blockEntityIn.spirit;
if (spiritType == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import net.minecraft.core.*;
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.phys.*;
import net.minecraftforge.api.distmarker.*;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import team.lodestar.lodestone.systems.multiblock.*;

import java.util.function.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.EmptyHandler;
import net.neoforged.neoforge.items.ItemHandlerHelper;
import team.lodestar.lodestone.systems.block.WaterLoggedEntityBlock;

public class SpiritAltarBlock<T extends SpiritAltarBlockEntity> extends WaterLoggedEntityBlock<T> {
Expand Down Expand Up @@ -41,7 +39,7 @@ public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p
public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) {
BlockEntity be = pLevel.getBlockEntity(pPos);
if (be instanceof SpiritAltarBlockEntity altar) {
return ItemHandlerHelper.calcRedstoneFromInventory(altar.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(new EmptyHandler()));
return ItemHandlerHelper.calcRedstoneFromInventory(altar.inventory);
}
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sammy.malum.common.block.storage.IMalumSpecialItemAccessPoint;
import com.sammy.malum.common.item.spirit.SpiritShardItem;
import com.sammy.malum.common.recipe.spirit.infusion.SpiritInfusionRecipe;
import com.sammy.malum.core.systems.recipe.SpiritIngredient;
import com.sammy.malum.registry.common.ParticleEffectTypeRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.SpiritTypeRegistry;
Expand Down Expand Up @@ -63,8 +64,8 @@ public class SpiritAltarBlockEntity extends LodestoneBlockEntity {
public Map<SpiritInfusionRecipe, AltarCraftingHelper.Ranking> possibleRecipes = new HashMap<>();
public SpiritInfusionRecipe recipe;

public LazyOptional<IItemHandler> internalInventory = LazyOptional.of(() -> new CombinedInvWrapper(inventory, extrasInventory, spiritInventory));
public LazyOptional<IItemHandler> exposedInventory = LazyOptional.of(() -> new CombinedInvWrapper(inventory, spiritInventory));
public Optional<IItemHandler> internalInventory = Optional.of(() -> new CombinedInvWrapper(inventory, extrasInventory, spiritInventory));
public Optional<IItemHandler> exposedInventory = Optional.of(() -> new CombinedInvWrapper(inventory, spiritInventory));

public SpiritAltarBlockEntity(BlockEntityType<? extends SpiritAltarBlockEntity> type, BlockPos pos, BlockState state) {
super(type, pos, state);
Expand Down Expand Up @@ -322,16 +323,16 @@ public void craft() {
ItemStack stack = inventory.getStackInSlot(0);
ItemStack outputStack = recipe.output.copy();
Vec3 itemPos = getItemPos();
if (recipe.carryOverData && inventory.getStackInSlot(0).hasTag()) {
outputStack.setTag(stack.getTag());
if (recipe.carryOverData) {
outputStack.applyComponents(stack.getComponents());
}
stack.shrink(recipe.input.count);
inventory.updateData();
for (SpiritWithCount spirit : recipe.spirits) {
for (SpiritIngredient spirit : recipe.spirits) {
for (int i = 0; i < spiritInventory.slotCount; i++) {
ItemStack spiritStack = spiritInventory.getStackInSlot(i);
if (spirit.matches(spiritStack)) {
spiritStack.shrink(spirit.count);
if (spirit.test(spiritStack)) {
spiritStack.shrink(spirit.getCount());
break;
}
}
Expand Down Expand Up @@ -414,10 +415,4 @@ public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction s
}
return super.getCapability(cap, side);
}

@Override
public AABB getRenderBoundingBox() {
var pos = worldPosition;
return new AABB(pos.getX() - 1, pos.getY(), pos.getZ() - 1, pos.getX() + 2, pos.getY() + 2, pos.getZ() + 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void addTotemPole(TotemPoleBlockEntity pole) {
this.direction = direction;
}
if (pole.isSoulwood == isSoulwood && direction.equals(this.direction)) {
if (pole.type != null) {
if (pole.spirit != null) {
totemPolePositions.add(pole.getBlockPos());
pole.riteStarting(this, totemPolePositions.size());
}
Expand Down Expand Up @@ -254,7 +254,7 @@ public List<TotemPoleBlockEntity> getTotemPoles() {
}

public List<MalumSpiritType> getSpirits() {
return getTotemPoles().stream().map(t -> t.type).toList();
return getTotemPoles().stream().map(t -> t.spirit).toList();
}

public Direction getDirection() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public boolean hasAnalogOutputSignal(BlockState pState) {
public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) {
BlockEntity be = pLevel.getBlockEntity(pPos);
if (be instanceof TotemPoleBlockEntity pole) {
return Math.min(SpiritTypeRegistry.getIndexForSpiritType(pole.type) + 1, 15);
return Math.min(SpiritTypeRegistry.getIndexForSpiritType(pole.spirit) + 1, 15);
}
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import net.minecraft.world.level.block.entity.*;
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraftforge.common.*;
import net.neoforged.neoforge.common.ItemAbilities;
import team.lodestar.lodestone.helpers.*;
import team.lodestar.lodestone.systems.blockentity.*;

Expand All @@ -33,7 +33,7 @@ public enum TotemPoleState {
ACTIVE
}

public MalumSpiritType type;
public MalumSpiritType spirit;
public TotemPoleState totemPoleState = TotemPoleState.INACTIVE;
public TotemBaseBlockEntity totemBase;
public int totemBaseYLevel;
Expand All @@ -43,8 +43,8 @@ public enum TotemPoleState {
public final Block logBlock;
public final Direction direction;

public TotemPoleBlockEntity(BlockEntityType<? extends TotemPoleBlockEntity> type, BlockPos pos, BlockState state) {
super(type, pos, state);
public TotemPoleBlockEntity(BlockEntityType<? extends TotemPoleBlockEntity> spirit, BlockPos pos, BlockState state) {
super(spirit, pos, state);
this.isSoulwood = ((TotemPoleBlock<?>) state.getBlock()).isSoulwood;
this.logBlock = ((TotemPoleBlock<?>) state.getBlock()).logBlock.get();
this.direction = state.getValue(BlockStateProperties.HORIZONTAL_FACING);
Expand All @@ -55,21 +55,20 @@ public TotemPoleBlockEntity(BlockPos pos, BlockState state) {
}

@Override
public InteractionResult onUse(Player player, InteractionHand hand) {
ItemStack held = player.getItemInHand(hand);
public ItemInteractionResult onUseWithItem(Player player, ItemStack held, InteractionHand hand) {
boolean success = false;
if (held.getItem() instanceof TotemicStaffItem && !totemPoleState.equals(TotemPoleState.ACTIVE) && !totemPoleState.equals(TotemPoleState.CHARGING)) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
totemPoleState = totemPoleState.equals(TotemPoleState.INACTIVE) ? TotemPoleState.VISUAL_ONLY : TotemPoleState.INACTIVE;
success = true;
}
else if (held.canPerformAction(ToolActions.AXE_STRIP)) {
else if (held.canPerformAction(ItemAbilities.AXE_STRIP)) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
if (type != null) {
if (spirit != null) {
level.setBlockAndUpdate(worldPosition, logBlock.defaultBlockState());
success = true;
onBreak(player);
Expand All @@ -82,37 +81,37 @@ else if (held.canPerformAction(ToolActions.AXE_STRIP)) {
level.playSound(null, worldPosition, SoundRegistry.MAJOR_BLIGHT_MOTIF.get(), SoundSource.BLOCKS, 1, 1);
}
BlockHelper.updateState(level, worldPosition);
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
return super.onUse(player, hand);
}

@Override
protected void saveAdditional(CompoundTag compound) {
if (type != null) {
compound.putString("type", type.identifier);
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
if (spirit != null) {
tag.putString("spirit", spirit.getIdentifier());
}
if (!totemPoleState.equals(TotemPoleState.INACTIVE)) {
compound.putInt("totemPoleState", totemPoleState.ordinal());
tag.putInt("state", totemPoleState.ordinal());
}
if (chargeProgress != 0) {
compound.putInt("chargeProgress", chargeProgress);
tag.putInt("chargeProgress", chargeProgress);
}
if (totemBaseYLevel != 0) {
compound.putInt("totemBaseYLevel", totemBaseYLevel);
tag.putInt("totemBaseYLevel", totemBaseYLevel);
}
super.saveAdditional(compound);
super.saveAdditional(tag, registries);
}

@Override
public void load(CompoundTag compound) {
if (compound.contains("type")) {
type = SpiritHarvestHandler.getSpiritType(compound.getString("type"));
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider pRegistries) {
if (tag.contains("spirit")) {
spirit = SpiritHarvestHandler.getSpiritType(tag.getString("spirit"));
}
totemPoleState = compound.contains("totemPoleState") ? TotemPoleState.values()[compound.getInt("totemPoleState")] : TotemPoleState.INACTIVE;
chargeProgress = compound.getInt("chargeProgress");
totemBaseYLevel = compound.getInt("totemBaseYLevel");
super.load(compound);
totemPoleState = tag.contains("state") ? TotemPoleState.values()[tag.getInt("state")] : TotemPoleState.INACTIVE;
chargeProgress = tag.getInt("chargeProgress");
totemBaseYLevel = tag.getInt("totemBaseYLevel");
super.loadAdditional(tag, pRegistries);
}

@Override
Expand All @@ -133,7 +132,7 @@ public void tick() {
chargeProgress = chargeProgress < cap ? chargeProgress + 1 : cap;
}
if (level.isClientSide) {
if (type != null && totemPoleState.equals(TotemPoleState.ACTIVE)) {
if (spirit != null && totemPoleState.equals(TotemPoleState.ACTIVE)) {
TotemParticleEffects.activeTotemPoleParticles(this);
}
}
Expand All @@ -143,7 +142,7 @@ public void setSpirit(MalumSpiritType type) {
level.playSound(null, worldPosition, SoundRegistry.TOTEM_ENGRAVE.get(), SoundSource.BLOCKS, 1, Mth.nextFloat(level.random, 0.9f, 1.1f));
level.playSound(null, worldPosition, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1, Mth.nextFloat(level.random, 0.9f, 1.1f));
ParticleEffectTypeRegistry.TOTEM_POLE_ACTIVATED.createPositionedEffect(level, new PositionEffectData(worldPosition));
this.type = type;
this.spirit = type;
this.chargeProgress = 10;
BlockHelper.updateState(level, worldPosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void tick(Level level) {
int offset = totemTakeoverTimer / 4;
BlockPos totemPos = sourcePos.above(offset);
if (level.getBlockEntity(totemPos) instanceof TotemPoleBlockEntity totemPoleTile) {
MalumSpiritType type = totemPoleTile.type;
MalumSpiritType type = totemPoleTile.spirit;
BlockState state = BlockHelper.setBlockStateWithExistingProperties(level, totemPos, SOULWOOD_TOTEM_POLE.get().defaultBlockState(), 3);
TotemPoleBlockEntity newTotemPole = new TotemPoleBlockEntity(totemPos, state);
newTotemPole.setLevel(level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class TotemParticleEffects {

public static void activeTotemPoleParticles(TotemPoleBlockEntity totemPoleBlockEntity) {
MalumSpiritType spiritType = totemPoleBlockEntity.type;
MalumSpiritType spiritType = totemPoleBlockEntity.spirit;
Level level = totemPoleBlockEntity.getLevel();
long gameTime = level.getGameTime();
var random = level.random;
Expand Down Expand Up @@ -42,7 +42,7 @@ public static void activeTotemPoleParticles(TotemPoleBlockEntity totemPoleBlockE
}

public static void activateTotemPoleParticles(TotemPoleBlockEntity totemPoleBlockEntity) {
MalumSpiritType spiritType = totemPoleBlockEntity.type;
MalumSpiritType spiritType = totemPoleBlockEntity.spirit;
Level level = totemPoleBlockEntity.getLevel();
long gameTime = level.getGameTime();
var random = level.random;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1b6153a

Please sign in to comment.