mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-30 00:57:55 +00:00
Be a little more robust in turtle item rendering
See #1328. Also some holiday cleanup, because my commit discipline is terrible.
This commit is contained in:
@@ -15,7 +15,6 @@ import dan200.computercraft.client.render.TurtleBlockEntityRenderer;
|
|||||||
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
|
||||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||||
import dan200.computercraft.shared.util.Holiday;
|
import dan200.computercraft.shared.util.Holiday;
|
||||||
import dan200.computercraft.shared.util.HolidayUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -71,13 +70,16 @@ public final class TurtleModelParts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Combination getCombination(ItemStack stack) {
|
public Combination getCombination(ItemStack stack) {
|
||||||
var turtle = (TurtleItem) stack.getItem();
|
var christmas = Holiday.getCurrent() == Holiday.CHRISTMAS;
|
||||||
|
|
||||||
|
if (!(stack.getItem() instanceof TurtleItem turtle)) {
|
||||||
|
return new Combination(false, null, null, null, christmas, false);
|
||||||
|
}
|
||||||
|
|
||||||
var colour = turtle.getColour(stack);
|
var colour = turtle.getColour(stack);
|
||||||
var leftUpgrade = turtle.getUpgrade(stack, TurtleSide.LEFT);
|
var leftUpgrade = turtle.getUpgrade(stack, TurtleSide.LEFT);
|
||||||
var rightUpgrade = turtle.getUpgrade(stack, TurtleSide.RIGHT);
|
var rightUpgrade = turtle.getUpgrade(stack, TurtleSide.RIGHT);
|
||||||
var overlay = turtle.getOverlay(stack);
|
var overlay = turtle.getOverlay(stack);
|
||||||
var christmas = HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS;
|
|
||||||
var label = turtle.getLabel(stack);
|
var label = turtle.getLabel(stack);
|
||||||
var flip = label != null && (label.equals("Dinnerbone") || label.equals("Grumm"));
|
var flip = label != null && (label.equals("Dinnerbone") || label.equals("Grumm"));
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
|||||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||||
import dan200.computercraft.shared.util.DirectionUtil;
|
import dan200.computercraft.shared.util.DirectionUtil;
|
||||||
import dan200.computercraft.shared.util.Holiday;
|
import dan200.computercraft.shared.util.Holiday;
|
||||||
import dan200.computercraft.shared.util.HolidayUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
@@ -112,7 +111,7 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
|
|||||||
renderModel(transform, buffer, lightmapCoord, overlayLight, getTurtleModel(family, colour != -1), colour == -1 ? null : new int[]{ colour });
|
renderModel(transform, buffer, lightmapCoord, overlayLight, getTurtleModel(family, colour != -1), colour == -1 ? null : new int[]{ colour });
|
||||||
|
|
||||||
// Render the overlay
|
// Render the overlay
|
||||||
var overlayModel = getTurtleOverlayModel(overlay, HolidayUtil.getCurrentHoliday() == Holiday.CHRISTMAS);
|
var overlayModel = getTurtleOverlayModel(overlay, Holiday.getCurrent() == Holiday.CHRISTMAS);
|
||||||
if (overlayModel != null) {
|
if (overlayModel != null) {
|
||||||
renderModel(transform, buffer, lightmapCoord, overlayLight, overlayModel, null);
|
renderModel(transform, buffer, lightmapCoord, overlayLight, overlayModel, null);
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@ import dan200.computercraft.shared.container.InventoryDelegate;
|
|||||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||||
import dan200.computercraft.shared.util.BlockEntityHelpers;
|
import dan200.computercraft.shared.util.BlockEntityHelpers;
|
||||||
import dan200.computercraft.shared.util.Holiday;
|
import dan200.computercraft.shared.util.Holiday;
|
||||||
import dan200.computercraft.shared.util.HolidayUtil;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
@@ -739,7 +738,7 @@ public class TurtleBrain implements TurtleAccessInternal {
|
|||||||
// Advance valentines day easter egg
|
// Advance valentines day easter egg
|
||||||
if (world.isClientSide && animation == TurtleAnimation.MOVE_FORWARD && animationProgress == 4) {
|
if (world.isClientSide && animation == TurtleAnimation.MOVE_FORWARD && animationProgress == 4) {
|
||||||
// Spawn love pfx if valentines day
|
// Spawn love pfx if valentines day
|
||||||
var currentHoliday = HolidayUtil.getCurrentHoliday();
|
var currentHoliday = Holiday.getCurrent();
|
||||||
if (currentHoliday == Holiday.VALENTINES) {
|
if (currentHoliday == Holiday.VALENTINES) {
|
||||||
var position = getVisualPosition(1.0f);
|
var position = getVisualPosition(1.0f);
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
|
@@ -5,10 +5,30 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.shared.util;
|
package dan200.computercraft.shared.util;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.Month;
|
||||||
|
|
||||||
public enum Holiday {
|
public enum Holiday {
|
||||||
NONE,
|
NONE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 14th February.
|
||||||
|
*/
|
||||||
VALENTINES,
|
VALENTINES,
|
||||||
APRIL_FOOLS_DAY,
|
|
||||||
HALLOWEEN,
|
/**
|
||||||
CHRISTMAS,
|
* 24th-26th December.
|
||||||
|
*
|
||||||
|
* @see net.minecraft.client.renderer.blockentity.ChestRenderer
|
||||||
|
*/
|
||||||
|
CHRISTMAS;
|
||||||
|
|
||||||
|
public static Holiday getCurrent() {
|
||||||
|
var calendar = LocalDateTime.now();
|
||||||
|
var month = calendar.getMonth();
|
||||||
|
var day = calendar.getDayOfMonth();
|
||||||
|
if (month == Month.FEBRUARY && day == 14) return VALENTINES;
|
||||||
|
if (month == Month.DECEMBER && day >= 24 && day <= 26) return CHRISTMAS;
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
||||||
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
|
|
||||||
* Send enquiries to dratcliffe@gmail.com
|
|
||||||
*/
|
|
||||||
package dan200.computercraft.shared.util;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public final class HolidayUtil {
|
|
||||||
private HolidayUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Holiday getCurrentHoliday() {
|
|
||||||
return getHoliday(Calendar.getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Holiday getHoliday(Calendar calendar) {
|
|
||||||
var month = calendar.get(Calendar.MONTH);
|
|
||||||
var day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
||||||
if (month == Calendar.FEBRUARY && day == 14) return Holiday.VALENTINES;
|
|
||||||
if (month == Calendar.APRIL && day == 1) return Holiday.APRIL_FOOLS_DAY;
|
|
||||||
if (month == Calendar.OCTOBER && day == 31) return Holiday.HALLOWEEN;
|
|
||||||
if (month == Calendar.DECEMBER && day >= 24 && day <= 30) return Holiday.CHRISTMAS;
|
|
||||||
return Holiday.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user