mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Merge 1.14
This commit is contained in:
commit
30472c4d80
3 files changed
+34
-21
No files matched your search
@@ -19,6 +19,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.api.mana.TileSignature;
|
||||
import vazkii.botania.client.render.tile.RenderTileRedString;
|
||||
@@ -27,8 +28,12 @@ import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
import vazkii.patchouli.client.book.gui.GuiBook;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
|
||||
public final class ClientTickHandler {
|
||||
|
||||
@@ -40,6 +45,7 @@ public final class ClientTickHandler {
|
||||
public static float partialTicks = 0;
|
||||
public static float delta = 0;
|
||||
public static float total = 0;
|
||||
private static final Field RENDER_PARTIAL_TICKS_PAUSED = ObfuscationReflectionHelper.findField(Minecraft.class, "field_193996_ah");
|
||||
|
||||
private static void calcDelta() {
|
||||
float oldTotal = total;
|
||||
@@ -49,9 +55,20 @@ public final class ClientTickHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void renderTick(TickEvent.RenderTickEvent event) {
|
||||
if(event.phase == TickEvent.Phase.START)
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if(event.phase == TickEvent.Phase.START) {
|
||||
partialTicks = event.renderTickTime;
|
||||
else {
|
||||
|
||||
if (mc.isGamePaused()) {
|
||||
// If game is paused, need to use the saved value. The event is always fired with the "true" value which
|
||||
// keeps updating when paused. See RenderTickEvent fire site for details
|
||||
try {
|
||||
partialTicks = (float) RENDER_PARTIAL_TICKS_PAUSED.get(mc);
|
||||
} catch (IllegalAccessException ignored) {
|
||||
// fall back to jittery one
|
||||
}
|
||||
}
|
||||
} else {
|
||||
calcDelta();
|
||||
}
|
||||
}
|
||||
@@ -67,8 +84,7 @@ public final class ClientTickHandler {
|
||||
SubTileVinculotus.existingFlowers.clear();
|
||||
}
|
||||
|
||||
Screen gui = Minecraft.getInstance().currentScreen;
|
||||
if(gui == null || !gui.isPauseScreen()) {
|
||||
if(!Minecraft.getInstance().isGamePaused()) {
|
||||
ticksInGame++;
|
||||
partialTicks = 0;
|
||||
|
||||
@@ -88,6 +104,7 @@ public final class ClientTickHandler {
|
||||
}
|
||||
|
||||
int ticksToOpen = 10;
|
||||
Screen gui = Minecraft.getInstance().currentScreen;
|
||||
if(gui instanceof GuiBook && ((GuiBook) gui).book.getBookItem().getItem() == ModItems.lexicon) {
|
||||
if(ticksWithLexicaOpen < 0)
|
||||
ticksWithLexicaOpen = 0;
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.NBTDynamicOps;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.state.properties.PistonType;
|
||||
import net.minecraft.tileentity.PistonTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
@@ -77,8 +78,9 @@ public class BlockPistonRelay extends BlockMod implements IWandable {
|
||||
|
||||
@Override
|
||||
public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) {
|
||||
if(!world.isRemote)
|
||||
if(!world.isRemote) {
|
||||
mapCoords(world.getDimension().getType(), pos, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void mapCoords(DimensionType type, BlockPos pos, int time) {
|
||||
@@ -97,8 +99,11 @@ public class BlockPistonRelay extends BlockMod implements IWandable {
|
||||
return coordsToCheck.getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
private Block getBlockAt(GlobalPos key) {
|
||||
return getStateAt(key).getBlock();
|
||||
private TileEntity getTeAt(GlobalPos key) {
|
||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||
if(server == null)
|
||||
return null;
|
||||
return server.getWorld(key.getDimension()).getTileEntity(key.getPos());
|
||||
}
|
||||
|
||||
private BlockState getStateAt(GlobalPos key) {
|
||||
@@ -194,11 +199,10 @@ public class BlockPistonRelay extends BlockMod implements IWandable {
|
||||
if(checkedCoords.contains(s))
|
||||
continue;
|
||||
|
||||
Block block = getBlockAt(s);
|
||||
if(block == Blocks.MOVING_PISTON) {
|
||||
BlockState state = getStateAt(s);
|
||||
BlockState state = getStateAt(s);
|
||||
if(state.getBlock() == Blocks.MOVING_PISTON) {
|
||||
boolean sticky = PistonType.STICKY == state.get(MovingPistonBlock.TYPE);
|
||||
Direction dir = state.get(MovingPistonBlock.FACING);
|
||||
Direction dir = ((PistonTileEntity) getTeAt(s)).getMotionDirection();
|
||||
|
||||
if(getTimeInCoords(s) == 0) {
|
||||
BlockPos newPos;
|
||||
@@ -207,9 +211,9 @@ public class BlockPistonRelay extends BlockMod implements IWandable {
|
||||
{
|
||||
int x = s.getPos().getX(), y = s.getPos().getY(), z = s.getPos().getZ();
|
||||
BlockPos pos = s.getPos();
|
||||
if(world.isAirBlock(pos.offset(dir)))
|
||||
if(world.isAirBlock(pos.offset(dir))) {
|
||||
world.setBlockState(pos.offset(dir), ModBlocks.pistonRelay.getDefaultState());
|
||||
else if(!world.isRemote) {
|
||||
} else {
|
||||
ItemStack stack = new ItemStack(ModBlocks.pistonRelay);
|
||||
world.addEntity(new ItemEntity(world, x + dir.getXOffset(), y + dir.getYOffset(), z + dir.getZOffset(), stack));
|
||||
}
|
||||
|
||||
-8
@@ -52,14 +52,6 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, getManaPerDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull BlockState state, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) {
|
||||
if(state.getBlockHardness(world, pos) != 0F)
|
||||
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext ctx) {
|
||||
|
||||
Reference in new issue
Block a user