Skip to content

Commit

Permalink
Fixed dislocators vanishing when dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Jan 4, 2024
1 parent d5aa016 commit d55241d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions Change Log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
######## 3.0.31.xxx ########
- Fix: Prevented guardian crystals from being pushed by pistons.
- Fixed dislocators vanishing when dropped.

######## 3.0.30.529 ########
- Added energy link module. (Effectively wireless charging direct from an energy core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemS

@Override
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
if (entity.getAge() >= 0) {
entity.setExtendedLifetime();
}
if (entity.level instanceof ServerLevel && TimeKeeper.getServerTick() % 20 == 0) {
if (isValid(stack) && !isPlayer(stack)) {
DislocatorSaveData.updateLinkTarget(entity.level, stack, new GroundTarget(entity));
Expand Down Expand Up @@ -199,7 +202,6 @@ private static ItemStack createP2PDislocator(UUID linkID) {
return stack;
}


@Override
public TargetPos getTargetPos(ItemStack stack, @Nullable Level world) {
if (world instanceof ServerLevel) {
Expand Down Expand Up @@ -262,9 +264,4 @@ public Rarity getRarity(ItemStack stack) {
public boolean canBeHurtBy(DamageSource source) {
return source == DamageSource.OUT_OF_WORLD;
}

@Override
public int getEntityLifespan(ItemStack itemStack, Level level) {
return -32768;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -208,7 +209,10 @@ public boolean canBeHurtBy(DamageSource source) {
}

@Override
public int getEntityLifespan(ItemStack itemStack, Level level) {
return -32768;
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
if (entity.getAge() >= 0) {
entity.setExtendedLifetime();
}
return super.onEntityItemUpdate(stack, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
Expand Down Expand Up @@ -66,8 +67,11 @@ public boolean canBeHurtBy(DamageSource source) {
}

@Override
public int getEntityLifespan(ItemStack itemStack, Level level) {
return -32768;
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
if (entity.getAge() >= 0) {
entity.setExtendedLifetime();
}
return super.onEntityItemUpdate(stack, entity);
}

@Override
Expand Down Expand Up @@ -277,7 +281,6 @@ public void setBlinkMode(ItemStack stack, boolean blink) {
stack.getOrCreateTag().putBoolean("blink", blink);
}


//Interaction Handling

public void handleClientAction(ServerPlayer player, ItemStack stack, MCDataInput input) {
Expand Down

0 comments on commit d55241d

Please sign in to comment.