Skip to content

Commit

Permalink
Implement workaround for fuel log spam bug
Browse files Browse the repository at this point in the history
See #23; a proper fix needs to rework how we represent custom cakes.
  • Loading branch information
Exaxxion committed Jun 1, 2021
1 parent 6de8d04 commit 9edf024
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/main/java/jackyy/dimensionaledibles/block/BlockCustomCake.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import jackyy.dimensionaledibles.item.*;
import jackyy.dimensionaledibles.registry.*;
import jackyy.dimensionaledibles.util.*;
import mcjty.theoneprobe.api.*;
import mcp.mobius.waila.api.*;
import net.minecraft.block.*;
import net.minecraft.block.state.*;
import net.minecraft.creativetab.*;
Expand All @@ -20,8 +22,10 @@

import javax.annotation.*;

import static jackyy.dimensionaledibles.DimensionalEdibles.logger;
import static net.minecraftforge.common.DimensionManager.isDimensionRegistered;
import java.util.*;

import static jackyy.dimensionaledibles.DimensionalEdibles.*;
import static net.minecraftforge.common.DimensionManager.*;

public class BlockCustomCake extends BlockCakeBase implements ITileEntityProvider {

Expand Down Expand Up @@ -222,4 +226,36 @@ public ModConfig.CustomCoords customCoords(int dim) {
@Override
@Nonnull
public ItemStack defaultFuel() { return ItemStack.EMPTY; }

/*
These overrides work around the bug causing log spam in tooltips when
looking at a cake. We should still consider splitting up custom cakes
into separate objects per dimension as hot-swapping state is brittle.
*/
@Override
public void addProbeInfo(ProbeMode mode,
IProbeInfo probeInfo,
EntityPlayer player,
World world,
IBlockState blockState,
IProbeHitData data) {

int dim = getDimension(world, data.getPos());
if(!isDimensionRegistered(dim))
return;
this.cakeDimension = dim;
super.addProbeInfo(mode, probeInfo, player, world, blockState, data);
}

@Override
public List<String> getWailaBody(ItemStack itemStack,
List<String> currentTip,
IWailaDataAccessor accessor,
IWailaConfigHandler config) {
int dim = getDimension(accessor.getWorld(), accessor.getPosition());
if(!isDimensionRegistered(dim))
return Collections.emptyList();
this.cakeDimension = dim;
return super.getWailaBody(itemStack, currentTip, accessor, config);
}
}

0 comments on commit 9edf024

Please sign in to comment.