Skip to content

Commit

Permalink
merge conflict; no changes to current User logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Apr 6, 2024
2 parents fa97ad0 + 827a6a9 commit b783fdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ protected Player getLookingPlayer(int maxRange, boolean mustCrouch) {
return null;
}

public void tryDumpFakePlayerInvo(WeakReference<FakePlayer> fp, ItemStackHandler out, boolean onGround) {
// TODO: this could use a refactor
public void tryDumpFakePlayerInvo(WeakReference<FakePlayer> fp, ItemStackHandler out, boolean dropItemsOnGround) {
if (out == null) {
return;
}
Expand All @@ -111,23 +112,20 @@ public void tryDumpFakePlayerInvo(WeakReference<FakePlayer> fp, ItemStackHandler
if (fpItem.isEmpty()) {
continue;
}
ModCyclic.LOGGER.info("NONEMPTY itemstack found what do we do");
if (fpItem == fp.get().getMainHandItem()) {
ModCyclic.LOGGER.info("aha continue main hand item dont doump it");
continue;
}
for (int j = 0; j < out.getSlots(); j++) {
ModCyclic.LOGGER.info(fpItem + "insert itit here" + j);
fpItem = out.insertItem(j, fpItem, false);
}
if (onGround) {
if (dropItemsOnGround) {
toDrop.add(fpItem);
}
else {
fp.get().getInventory().items.set(i, fpItem);
}
}
if (onGround) {
if (dropItemsOnGround) {
ItemStackUtil.drop(this.level, this.worldPosition.above(), toDrop);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class TileDiamondSpikes extends TileBlockEntityCyclic {

WeakReference<FakePlayer> fakePlayer;
final static boolean dropItemsOnGround = true;

public TileDiamondSpikes(BlockPos pos, BlockState state) {
super(TileRegistry.SPIKES_DIAMOND.get(), pos, state);
Expand Down Expand Up @@ -63,7 +64,7 @@ public void tick() {
fakePlayer.get().setItemInHand(InteractionHand.MAIN_HAND, sword);
}
if (level.random.nextDouble() < 0.001F) {
tryDumpFakePlayerInvo(fakePlayer, null, true);
tryDumpFakePlayerInvo(fakePlayer, null, dropItemsOnGround);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/lothrazar/cyclic/block/user/TileUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,16 @@ public void tick() {
catch (Exception e) {
ModCyclic.LOGGER.error("User action item error", e);
}
tryDumpFakePlayerInvo(fakePlayer, this.outputSlots, false);
final boolean dropItemsOnGround = false;
tryDumpFakePlayerInvo(fakePlayer, this.outputSlots, dropItemsOnGround);
}

private void depositOutputMainhand() {
var usedItem = fakePlayer.get().getItemInHand(InteractionHand.MAIN_HAND);
for (int slotId = 0; slotId < outputSlots.getSlots(); slotId++) {
if (!usedItem.isEmpty()) {
// usedItem = outputSlots.insertItem(slotId, usedItem.copy(), false);
if (outputSlots.insertItem(slotId, usedItem.copy(), true).isEmpty()) {
usedItem = outputSlots.insertItem(slotId, usedItem.copy(), false);
// userSlots.setStackInSlot(0, usedItem);
TileBlockEntityCyclic.tryEquipItem(usedItem, fakePlayer, InteractionHand.MAIN_HAND);
}
}
Expand Down

0 comments on commit b783fdc

Please sign in to comment.