mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 05:02:30 +00:00
Merge 1.14
This commit is contained in:
commit
a2f8de9075
29 files changed
+80
-88
No files matched your search
@@ -46,7 +46,6 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
|
||||
int sizeLastCheck = -1;
|
||||
TileEntity linkedPool = null;
|
||||
public int knownMana = -1;
|
||||
|
||||
BlockPos cachedPoolCoordinates = null;
|
||||
|
||||
@@ -152,7 +151,6 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
return false;
|
||||
}
|
||||
|
||||
knownMana = mana;
|
||||
SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT);
|
||||
if (evt != null) {
|
||||
player.playSound(evt, 0.1F, 1F);
|
||||
@@ -244,7 +242,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
public void renderHUD(Minecraft mc) {
|
||||
String name = I18n.format(getBlockState().getBlock().getTranslationKey());
|
||||
int color = getColor();
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,6 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
|
||||
int sizeLastCheck = -1;
|
||||
protected TileEntity linkedCollector = null;
|
||||
public int knownMana = -1;
|
||||
public int passiveDecayTicks;
|
||||
|
||||
BlockPos cachedCollectorCoordinates = null;
|
||||
@@ -206,7 +205,6 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
sync();
|
||||
}
|
||||
|
||||
knownMana = getMana();
|
||||
SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT);
|
||||
if (evt != null) {
|
||||
player.playSound(evt, 0.1F, 1F);
|
||||
@@ -297,7 +295,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
public void renderHUD(Minecraft mc) {
|
||||
String name = I18n.format(getBlockState().getBlock().getTranslationKey());
|
||||
int color = getColor();
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -49,7 +50,7 @@ import java.util.Properties;
|
||||
|
||||
public final class ContributorFancinessHandler extends LayerRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> {
|
||||
|
||||
public static final Map<String, ItemStack> flowerMap = new HashMap<>();
|
||||
private static volatile Map<String, ItemStack> flowerMap = Collections.emptyMap();
|
||||
private static boolean startedLoading = false;
|
||||
|
||||
private static final ImmutableMap<String, String> LEGACY_FLOWER_NAMES = ImmutableMap.<String, String>builder()
|
||||
@@ -82,8 +83,11 @@ public final class ContributorFancinessHandler extends LayerRenderer<AbstractCli
|
||||
firstStart();
|
||||
|
||||
name = name.toLowerCase();
|
||||
if (player.isWearing(PlayerModelPart.CAPE) && flowerMap.containsKey(name)) {
|
||||
renderFlower(ms, buffers, player, flowerMap.get(name));
|
||||
if (player.isWearing(PlayerModelPart.CAPE)) {
|
||||
ItemStack flower = getFlower(name);
|
||||
if (!flower.isEmpty()) {
|
||||
renderFlower(ms, buffers, player, flower);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,8 +99,12 @@ public final class ContributorFancinessHandler extends LayerRenderer<AbstractCli
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getFlower(String name) {
|
||||
return flowerMap.getOrDefault(name, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public static void load(Properties props) {
|
||||
flowerMap.clear();
|
||||
Map<String, ItemStack> m = new HashMap<>();
|
||||
for (String key : props.stringPropertyNames()) {
|
||||
String value = props.getProperty(key);
|
||||
|
||||
@@ -105,7 +113,7 @@ public final class ContributorFancinessHandler extends LayerRenderer<AbstractCli
|
||||
if (i < 0 || i >= 16) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
flowerMap.put(key, new ItemStack(ModBlocks.getFlower(DyeColor.byId(i))));
|
||||
m.put(key, new ItemStack(ModBlocks.getFlower(DyeColor.byId(i))));
|
||||
} catch (NumberFormatException e) {
|
||||
String rawName = value.toLowerCase(Locale.ROOT);
|
||||
String flowerName = LEGACY_FLOWER_NAMES.getOrDefault(rawName, rawName);
|
||||
@@ -113,9 +121,10 @@ public final class ContributorFancinessHandler extends LayerRenderer<AbstractCli
|
||||
Item item = ModTags.Items.SPECIAL_FLOWERS.getAllElements().stream()
|
||||
.filter(flower -> flower.getRegistryName().getPath().equals(flowerName))
|
||||
.findFirst().orElse(Items.POPPY);
|
||||
flowerMap.put(key, new ItemStack(item));
|
||||
m.put(key, new ItemStack(item));
|
||||
}
|
||||
}
|
||||
flowerMap = m;
|
||||
}
|
||||
|
||||
private static void renderGoldfish(MatrixStack ms, IRenderTypeBuffer buffers, int light, PlayerEntity player) {
|
||||
|
||||
@@ -363,14 +363,7 @@ public final class HUDHandler {
|
||||
x = mc.getWindow().getScaledWidth() / 2 - 51;
|
||||
y += 10;
|
||||
|
||||
renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana);
|
||||
|
||||
if (mana < 0) {
|
||||
String text = I18n.format("botaniamisc.statusUnknown");
|
||||
x = mc.getWindow().getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2;
|
||||
y -= 1;
|
||||
mc.fontRenderer.drawString(text, x, y, color);
|
||||
}
|
||||
renderManaBar(x, y, color, 1F, mana, maxMana);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class TooltipHandler {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public static void onTooltipEvent(ItemTooltipEvent event) {
|
||||
if (event.getItemStack().hasTag() && ItemNBTHelper.getBoolean(event.getItemStack(), ItemKeepIvy.TAG_KEEP, false)) {
|
||||
if (ItemKeepIvy.hasIvy(event.getItemStack())) {
|
||||
event.getToolTip().add(new TranslationTextComponent("botaniamisc.hasKeepIvy"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,8 +366,8 @@ public class RenderTileTinyPotato extends TileEntityRenderer<TileTinyPotato> {
|
||||
|
||||
ms.translate(1.5, -4, -2.5);
|
||||
renderBlock(ms, buffers, light, overlay, Blocks.CAKE);
|
||||
} else if (ContributorFancinessHandler.flowerMap.containsKey(name)) {
|
||||
ItemStack icon = ContributorFancinessHandler.flowerMap.getOrDefault(name, ItemStack.EMPTY);
|
||||
} else {
|
||||
ItemStack icon = ContributorFancinessHandler.getFlower(name);
|
||||
if (!icon.isEmpty()) {
|
||||
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180));
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180));
|
||||
|
||||
@@ -116,7 +116,9 @@ public class BlockGhostRail extends AbstractRailBlock {
|
||||
AbstractMinecartEntity c = iter.next();
|
||||
BlockPos entPos = new BlockPos(c);
|
||||
|
||||
if (!c.isAlive() || !c.isAddedToWorld() || !c.world.isBlockLoaded(entPos)) {
|
||||
if (!c.isAlive() || !c.isAddedToWorld() || !c.world.isBlockLoaded(entPos)
|
||||
|| c.getPersistentData().getInt(TAG_FLOAT_TICKS) <= 0) {
|
||||
c.noClip = false;
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
private static final int MAX_MANA_DILLUTED = 10000;
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
private static final String TAG_KNOWN_MANA = "knownMana";
|
||||
private static final String TAG_OUTPUTTING = "outputting";
|
||||
private static final String TAG_COLOR = "color";
|
||||
private static final String TAG_MANA_CAP = "manaCap";
|
||||
@@ -91,7 +90,6 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
|
||||
public DyeColor color = DyeColor.WHITE;
|
||||
private int mana;
|
||||
private int knownMana = -1;
|
||||
|
||||
public int manaCap = -1;
|
||||
private int soundTicks = 0;
|
||||
@@ -386,31 +384,14 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
inputKey = cmp.getString(TAG_OUTPUT_KEY);
|
||||
}
|
||||
|
||||
if (cmp.contains(TAG_KNOWN_MANA)) {
|
||||
knownMana = cmp.getInt(TAG_KNOWN_MANA);
|
||||
}
|
||||
}
|
||||
|
||||
public void onWanded(PlayerEntity player, ItemStack wand) {
|
||||
if (player == null || player.isSneaking()) {
|
||||
outputting = !outputting;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
CompoundNBT nbttagcompound = new CompoundNBT();
|
||||
writePacketNBT(nbttagcompound);
|
||||
nbttagcompound.putInt(TAG_KNOWN_MANA, getCurrentMana());
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) player).connection.sendPacket(new SUpdateTileEntityPacket(pos, -999, nbttagcompound));
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
world.playSound(null, getPos(), ModSounds.ding, SoundCategory.PLAYERS, 0.11F, 1F);
|
||||
} else {
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.ding, SoundCategory.PLAYERS, 0.11F, 1F);
|
||||
}
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -418,7 +399,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
ItemStack pool = new ItemStack(getBlockState().getBlock());
|
||||
String name = pool.getDisplayName().getString();
|
||||
int color = 0x4444FF;
|
||||
HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name);
|
||||
HUDHandler.drawSimpleManaHUD(color, getCurrentMana(), manaCap, name);
|
||||
|
||||
int x = Minecraft.getInstance().getWindow().getScaledWidth() / 2 - 11;
|
||||
int y = Minecraft.getInstance().getWindow().getScaledHeight() / 2 + 30;
|
||||
|
||||
@@ -81,7 +81,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
private static final String TAG_UUID_MOST = "uuidMost";
|
||||
private static final String TAG_UUID_LEAST = "uuidLeast";
|
||||
private static final String TAG_MANA = "mana";
|
||||
private static final String TAG_KNOWN_MANA = "knownMana";
|
||||
private static final String TAG_REQUEST_UPDATE = "requestUpdate";
|
||||
private static final String TAG_ROTATION_X = "rotationX";
|
||||
private static final String TAG_ROTATION_Y = "rotationY";
|
||||
@@ -125,7 +124,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
UUID identity;
|
||||
|
||||
private int mana;
|
||||
private int knownMana = -1;
|
||||
public float rotationX, rotationY;
|
||||
|
||||
@Nullable public DyeColor paddingColor = null;
|
||||
@@ -353,9 +351,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY);
|
||||
mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER);
|
||||
|
||||
if (cmp.contains(TAG_KNOWN_MANA)) {
|
||||
knownMana = cmp.getInt(TAG_KNOWN_MANA);
|
||||
}
|
||||
if (cmp.contains(TAG_PADDING_COLOR)) {
|
||||
paddingColor = cmp.getInt(TAG_PADDING_COLOR) == -1 ? null : DyeColor.byId(cmp.getInt(TAG_PADDING_COLOR));
|
||||
}
|
||||
@@ -405,15 +400,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
}
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
if (!world.isRemote) {
|
||||
CompoundNBT nbttagcompound = new CompoundNBT();
|
||||
writePacketNBT(nbttagcompound);
|
||||
nbttagcompound.putInt(TAG_KNOWN_MANA, mana);
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) player).connection.sendPacket(new SUpdateTileEntityPacket(pos, -999, nbttagcompound));
|
||||
}
|
||||
}
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.ding, SoundCategory.PLAYERS, 0.1F, 1);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
} else {
|
||||
RayTraceResult pos = Item.rayTrace(world, player, RayTraceContext.FluidMode.ANY);
|
||||
if (pos instanceof BlockRayTraceResult && !world.isRemote) {
|
||||
@@ -572,7 +559,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public void renderHUD(Minecraft mc) {
|
||||
String name = new ItemStack(getBlockState().getBlock()).getDisplayName().getString();
|
||||
int color = getVariant().hudColor;
|
||||
HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name);
|
||||
HUDHandler.drawSimpleManaHUD(color, getCurrentMana(), getMaxMana(), name);
|
||||
|
||||
ItemStack lens = itemHandler.getStackInSlot(0);
|
||||
if (!lens.isEmpty()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -66,8 +67,8 @@ public class ManaGunClipRecipe extends SpecialRecipe {
|
||||
}
|
||||
|
||||
ItemStack lens = ItemManaGun.getLens(gun);
|
||||
ItemManaGun.setLens(gun, ItemStack.EMPTY);
|
||||
ItemStack gunCopy = gun.copy();
|
||||
ItemManaGun.setLens(gunCopy, ItemStack.EMPTY);
|
||||
ItemManaGun.setClip(gunCopy, true);
|
||||
ItemManaGun.setLensAtPos(gunCopy, lens, 0);
|
||||
return gunCopy;
|
||||
@@ -78,6 +79,12 @@ public class ManaGunClipRecipe extends SpecialRecipe {
|
||||
return width * height >= 2;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(CraftingInventory inv) {
|
||||
return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
|
||||
@@ -29,11 +29,13 @@ import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import top.theillusivec4.curios.api.CuriosAPI;
|
||||
import top.theillusivec4.curios.api.capability.CuriosCapability;
|
||||
import top.theillusivec4.curios.api.capability.ICurio;
|
||||
import top.theillusivec4.curios.api.event.LivingCurioDropRulesEvent;
|
||||
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
|
||||
|
||||
import vazkii.botania.common.capability.SimpleCapProvider;
|
||||
import vazkii.botania.common.core.handler.EquipmentHandler;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.item.ItemKeepIvy;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBauble;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
@@ -51,6 +53,17 @@ public class CurioIntegration extends EquipmentHandler {
|
||||
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("necklace"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void keepCurioDrops(LivingCurioDropRulesEvent event) {
|
||||
event.addOverride(stack -> {
|
||||
if (ItemKeepIvy.hasIvy(stack)) {
|
||||
stack.removeChildTag(ItemKeepIvy.TAG_KEEP);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, ICurio.DropRule.ALWAYS_KEEP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LazyOptional<IItemHandlerModifiable> getAllWornItems(LivingEntity living) {
|
||||
return CuriosAPI.getCuriosHandler(living).map(h -> {
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@@ -38,7 +37,12 @@ public class ItemKeepIvy extends Item {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static boolean hasIvy(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.hasTag() && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false);
|
||||
}
|
||||
|
||||
// Curios are handled in CurioIntegration#keepCurioDrops
|
||||
@SubscribeEvent
|
||||
public static void onPlayerDrops(LivingDropsEvent event) {
|
||||
if (!(event.getEntityLiving() instanceof PlayerEntity)) {
|
||||
return;
|
||||
@@ -89,8 +93,10 @@ public class ItemKeepIvy extends Item {
|
||||
ItemStack stack = ItemStack.read(cmp2);
|
||||
if (!stack.isEmpty()) {
|
||||
ItemStack copy = stack.copy();
|
||||
ItemNBTHelper.setBoolean(copy, TAG_KEEP, false);
|
||||
event.getPlayer().inventory.addItemStackToInventory(copy);
|
||||
stack.removeChildTag(TAG_KEEP);
|
||||
if (!event.getPlayer().inventory.addItemStackToInventory(copy)) {
|
||||
event.getPlayer().entityDropItem(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
|
||||
@Override
|
||||
public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
|
||||
super.onArmorTick(stack, world, player);
|
||||
if (hasArmorSet(player)) {
|
||||
if (!world.isRemote && hasArmorSet(player)) {
|
||||
int food = player.getFoodStats().getFoodLevel();
|
||||
if (food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) {
|
||||
player.heal(1F);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (player instanceof PlayerEntity && player.ticksExisted % 10 == 0) {
|
||||
if (!player.world.isRemote && player instanceof PlayerEntity && player.ticksExisted % 10 == 0) {
|
||||
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem {
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (player instanceof PlayerEntity && player.ticksExisted % 2 == 0) {
|
||||
if (!player.world.isRemote && player instanceof PlayerEntity && player.ticksExisted % 2 == 0) {
|
||||
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user