mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-10-26 22:34:08 +00:00
Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9307e94129 | ||
|
|
3f62d4b8fe | ||
|
|
2257f1648c | ||
|
|
cefdfd7ca6 | ||
|
|
c802a448e4 | ||
|
|
daae5de075 | ||
|
|
b897e8485f | ||
|
|
abd62c1076 | ||
|
|
6b5a1bbc31 | ||
|
|
8e709b0190 | ||
|
|
d0b9a26957 | ||
|
|
a16181c480 | ||
|
|
37a43412d1 | ||
|
|
a7f8f1cbac | ||
|
|
104a6183d3 | ||
|
|
590485f8f3 | ||
|
|
9beb60183b | ||
|
|
1175f3a5c5 | ||
|
|
a165099e39 | ||
|
|
71c6c71281 | ||
|
|
56aaa823b2 | ||
|
|
2aa954918f | ||
|
|
cf57347284 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
root = true
|
||||
|
||||
[*.java]
|
||||
indent_style = tab
|
||||
@@ -2,10 +2,10 @@
|
||||
* This class was created by <Vazkii/ChickenBones>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
*
|
||||
* File Created @ [Feb 3, 2014, 9:05:38 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
@@ -67,14 +67,13 @@ public class LightningHandler {
|
||||
profiler.endStartSection("lightning");
|
||||
|
||||
float frame = event.partialTicks;
|
||||
Entity entity = Minecraft.getMinecraft().thePlayer;
|
||||
TextureManager render = Minecraft.getMinecraft().renderEngine;
|
||||
|
||||
interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
|
||||
interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
|
||||
interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;
|
||||
|
||||
Entity viewEntity = Minecraft.getMinecraft().renderViewEntity;
|
||||
interpPosX = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * frame;
|
||||
interpPosY = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * frame;
|
||||
interpPosZ = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * frame;
|
||||
|
||||
scratchView.set(viewEntity.posX, viewEntity.posY + viewEntity.getEyeHeight(), viewEntity.posZ);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -501,4 +500,4 @@ public class LightningHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,24 +381,38 @@ public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void setExtraReach(EntityLivingBase entity, float reach) {
|
||||
super.setExtraReach(entity, reach);
|
||||
IExtendedPlayerController controller = getReachController(entity);
|
||||
if(controller != null)
|
||||
controller.setReachDistanceExtension(Math.max(0, controller.getReachDistanceExtension() + reach));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientExtraReach(EntityLivingBase entity, float reach) {
|
||||
IExtendedPlayerController controller = getReachController(entity);
|
||||
if(controller != null)
|
||||
controller.setReachDistanceExtension(Math.max(0, reach));
|
||||
}
|
||||
|
||||
private IExtendedPlayerController getReachController(EntityLivingBase entity) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
// Player object might have changed, need to check the UUID.
|
||||
if(entity.worldObj.isRemote && entity.getUniqueID().equals(player.getUniqueID())) {
|
||||
if(!(mc.playerController instanceof IExtendedPlayerController)) {
|
||||
GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE);
|
||||
NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER);
|
||||
BotaniaPlayerController controller = new BotaniaPlayerController(mc, net);
|
||||
boolean isFlying = player.capabilities.isFlying;
|
||||
boolean allowFlying = player.capabilities.allowFlying;
|
||||
controller.setGameType(type);
|
||||
player.capabilities.isFlying = isFlying;
|
||||
player.capabilities.allowFlying = allowFlying;
|
||||
mc.playerController = controller;
|
||||
}
|
||||
if(!entity.worldObj.isRemote || !entity.getUniqueID().equals(player.getUniqueID()))
|
||||
return null;
|
||||
|
||||
((IExtendedPlayerController) mc.playerController).setReachDistanceExtension(Math.max(0, ((IExtendedPlayerController) mc.playerController).getReachDistanceExtension() + reach));
|
||||
if(!(mc.playerController instanceof IExtendedPlayerController)) {
|
||||
GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE);
|
||||
NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER);
|
||||
BotaniaPlayerController controller = new BotaniaPlayerController(mc, net);
|
||||
boolean isFlying = player.capabilities.isFlying;
|
||||
boolean allowFlying = player.capabilities.allowFlying;
|
||||
controller.setGameType(type);
|
||||
player.capabilities.isFlying = isFlying;
|
||||
player.capabilities.allowFlying = allowFlying;
|
||||
mc.playerController = controller;
|
||||
}
|
||||
|
||||
return (IExtendedPlayerController) mc.playerController;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler {
|
||||
|
||||
for (ItemStack emptyContainer : BrewHelper.getBrewContainers()) {
|
||||
final ItemStack filledContainer = recipe.getOutput(emptyContainer);
|
||||
if (result.isItemEqual(filledContainer) && Objects.equals(result.stackTagCompound, filledContainer.stackTagCompound)) {
|
||||
if (filledContainer != null && result.isItemEqual(filledContainer) && Objects.equals(result.stackTagCompound, filledContainer.stackTagCompound)) {
|
||||
arecipes.add(new CachedBreweryRecipe(recipe, emptyContainer));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -40,6 +40,13 @@ public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler {
|
||||
output = new PositionedStack(recipe.getOutput(), 111, 21);
|
||||
}
|
||||
|
||||
// Kept for Alfheim, which calls super(recipe, false) from its NEI handler.
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) {
|
||||
this(recipe);
|
||||
}
|
||||
|
||||
public void setIngredients(List<Object> inputs) {
|
||||
float degreePerInput = 360F / inputs.size();
|
||||
float currentDegree = -90F;
|
||||
@@ -74,10 +81,10 @@ public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "botania.petalApothecary";
|
||||
return getRecipeID();
|
||||
}
|
||||
|
||||
// Used by the Alfheim addon, identical to getOverlayIdentifier()
|
||||
// Kept for Alfheim, which overrides this instead of getOverlayIdentifier().
|
||||
@Deprecated
|
||||
public String getRecipeID() {
|
||||
return "botania.petalApothecary";
|
||||
|
||||
@@ -33,7 +33,8 @@ public class RenderTileCocoon extends TileEntitySpecialRenderer {
|
||||
|
||||
float rot = 0F;
|
||||
float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F;
|
||||
if(cocoon.timePassed % modval < 10) {
|
||||
// At timePassed 0 with partialTicks 0 (inventory/NEI render), log(0) makes rot NaN and the model disappears.
|
||||
if(cocoon.timePassed > 0 && cocoon.timePassed % modval < 10) {
|
||||
float mod = (cocoon.timePassed + partialTicks) % modval;
|
||||
float v = mod / 5 * (float) Math.PI * 2;
|
||||
rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + partialTicks);
|
||||
|
||||
@@ -87,8 +87,8 @@ public class SkyblockSkyRenderer extends IRenderHandler {
|
||||
float f6;
|
||||
|
||||
float insideVoid = 0;
|
||||
if(mc.thePlayer.posY <= -2)
|
||||
insideVoid = (float) Math.min(1F, -(mc.thePlayer.posY + 2) / 30F);
|
||||
if(viewEntity.posY <= -2)
|
||||
insideVoid = (float) Math.min(1F, -(viewEntity.posY + 2) / 30F);
|
||||
|
||||
f1 = Math.max(0F, f1 - insideVoid);
|
||||
f2 = Math.max(0F, f2 - insideVoid);
|
||||
|
||||
@@ -101,6 +101,7 @@ public class SubTileEntropinnyum extends SubTileGenerating {
|
||||
if (world.isRemote || mana != 0 || !(Math.abs(supertile.xCoord - posX) <= RANGE && Math.abs(supertile.yCoord - posY) <= RANGE && Math.abs(supertile.zCoord - posZ) <= RANGE)) {
|
||||
return false;
|
||||
}
|
||||
if (explosionSource == null) return false;
|
||||
|
||||
explosionSource.setDead();
|
||||
mana += getMaxMana();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.item.ItemStackNBT;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -183,17 +184,17 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(getBlockMetadata() < PYLON_LOCATIONS.length)
|
||||
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
|
||||
if (getBlockMetadata() < PYLON_LOCATIONS.length)
|
||||
for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
|
||||
if(tile instanceof TilePylon)
|
||||
((TilePylon) tile).activated = false;
|
||||
if (tile instanceof TilePylon tilePylon)
|
||||
tilePylon.activated = false;
|
||||
}
|
||||
|
||||
if(!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) {
|
||||
if (!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) {
|
||||
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2);
|
||||
for(int i = 0; i < 50; i++) {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
float red = (float) Math.random();
|
||||
float green = (float) Math.random();
|
||||
float blue = (float) Math.random();
|
||||
@@ -202,104 +203,99 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:enchanterBlock", 0.5F, 10F);
|
||||
}
|
||||
|
||||
switch(stage) {
|
||||
case 1 : { // Get books
|
||||
if(stageTicks % 20 == 0) {
|
||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3));
|
||||
int count = items.size();
|
||||
boolean addedEnch = false;
|
||||
switch (stage) {
|
||||
case 1 -> { // Get books
|
||||
if (stageTicks % 20 == 0) {
|
||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 1, zCoord + 3));
|
||||
int count = items.size();
|
||||
boolean addedEnch = false;
|
||||
|
||||
if(count > 0 && !worldObj.isRemote) {
|
||||
for(EntityItem entity : items) {
|
||||
ItemStack item = entity.getEntityItem();
|
||||
if(item.getItem() == Items.enchanted_book) {
|
||||
NBTTagList enchants = Items.enchanted_book.func_92110_g(item);
|
||||
if(enchants != null && enchants.tagCount() > 0) {
|
||||
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
|
||||
short enchantId = enchant.getShort("id");
|
||||
short enchantLvl = enchant.getShort("lvl");
|
||||
if(!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) {
|
||||
this.enchants.add(new EnchantmentData(enchantId, enchantLvl));
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F);
|
||||
addedEnch = true;
|
||||
break;
|
||||
if (count > 0 && !worldObj.isRemote) {
|
||||
for (EntityItem entity : items) {
|
||||
ItemStack item = entity.getEntityItem();
|
||||
if (item.getItem() == Items.enchanted_book) {
|
||||
NBTTagList enchants = Items.enchanted_book.func_92110_g(item);
|
||||
if (enchants != null && enchants.tagCount() > 0) {
|
||||
NBTTagCompound enchant = enchants.getCompoundTagAt(0);
|
||||
short enchantId = enchant.getShort("id");
|
||||
short enchantLvl = enchant.getShort("lvl");
|
||||
if (!hasEnchantAlready(enchantId) && isEnchantmentValid(enchantId)) {
|
||||
this.enchants.add(new EnchantmentData(enchantId, enchantLvl));
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:ding", 1F, 1F);
|
||||
addedEnch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!addedEnch) {
|
||||
if(enchants.isEmpty())
|
||||
stage = 0;
|
||||
else advanceStage();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2 : { // Get Mana
|
||||
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
|
||||
TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
|
||||
if(pylonTile != null) {
|
||||
pylonTile.activated = true;
|
||||
pylonTile.centerX = xCoord;
|
||||
pylonTile.centerY = yCoord;
|
||||
pylonTile.centerZ = zCoord;
|
||||
}
|
||||
}
|
||||
|
||||
if(manaRequired == -1) {
|
||||
manaRequired = 0;
|
||||
for(EnchantmentData data : enchants) {
|
||||
Enchantment ench = Enchantment.enchantmentsList[data.enchant];
|
||||
manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F));
|
||||
}
|
||||
} else if(mana >= manaRequired) {
|
||||
manaRequired = 0;
|
||||
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()])
|
||||
((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false;
|
||||
|
||||
advanceStage();
|
||||
} else {
|
||||
ISparkEntity spark = getAttachedSpark();
|
||||
if(spark != null) {
|
||||
List<ISparkEntity> sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
|
||||
for(ISparkEntity otherSpark : sparkEntities) {
|
||||
if(spark == otherSpark)
|
||||
continue;
|
||||
|
||||
if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool)
|
||||
otherSpark.registerTransfer(spark);
|
||||
if (!addedEnch) {
|
||||
if (enchants.isEmpty())
|
||||
stage = 0;
|
||||
else advanceStage();
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2 -> { // Get Mana
|
||||
for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
|
||||
TilePylon pylonTile = (TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
|
||||
if (pylonTile != null) {
|
||||
pylonTile.activated = true;
|
||||
pylonTile.centerX = xCoord;
|
||||
pylonTile.centerY = yCoord;
|
||||
pylonTile.centerZ = zCoord;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3 : { // Enchant
|
||||
if(stageTicks >= 100) {
|
||||
for(EnchantmentData data : enchants)
|
||||
if(EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0)
|
||||
itemToEnchant.addEnchantment(Enchantment.enchantmentsList[data.enchant], data.level);
|
||||
if (manaRequired == -1) {
|
||||
manaRequired = 0;
|
||||
for (EnchantmentData data : enchants) {
|
||||
Enchantment ench = Enchantment.enchantmentsList[data.enchant];
|
||||
manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F));
|
||||
}
|
||||
} else if (mana >= manaRequired) {
|
||||
manaRequired = 0;
|
||||
for (int[] pylon : PYLON_LOCATIONS[getBlockMetadata()])
|
||||
((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false;
|
||||
|
||||
enchants.clear();
|
||||
manaRequired = -1;
|
||||
mana = 0;
|
||||
advanceStage();
|
||||
} else {
|
||||
ISparkEntity spark = getAttachedSpark();
|
||||
if (spark != null) {
|
||||
List<ISparkEntity> sparkEntities = SparkHelper.getSparksAround(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
|
||||
for (ISparkEntity otherSpark : sparkEntities) {
|
||||
if (spark == otherSpark)
|
||||
continue;
|
||||
|
||||
craftingFanciness();
|
||||
advanceStage();
|
||||
if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool)
|
||||
otherSpark.registerTransfer(spark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4 : { // Reset
|
||||
if(stageTicks >= 20)
|
||||
advanceStage();
|
||||
case 3 -> { // Enchant
|
||||
if (stageTicks >= 100) {
|
||||
for (EnchantmentData data : enchants)
|
||||
if (EnchantmentHelper.getEnchantmentLevel(data.enchant, itemToEnchant) == 0) {
|
||||
ItemStackNBT.enchant(itemToEnchant, data.enchant, data.level);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
enchants.clear();
|
||||
manaRequired = -1;
|
||||
mana = 0;
|
||||
|
||||
craftingFanciness();
|
||||
advanceStage();
|
||||
}
|
||||
}
|
||||
case 4 -> { // Reset
|
||||
if (stageTicks >= 20)
|
||||
advanceStage();
|
||||
}
|
||||
}
|
||||
|
||||
if(stage != 0)
|
||||
if (stage != 0)
|
||||
stageTicks++;
|
||||
}
|
||||
|
||||
@@ -388,12 +384,12 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
|
||||
enchants.clear();
|
||||
String enchStr = cmp.getString(TAG_ENCHANTS);
|
||||
if(!enchStr.isEmpty()) {
|
||||
if (!enchStr.isEmpty()) {
|
||||
String[] enchTokens = enchStr.split(",");
|
||||
for(String token : enchTokens) {
|
||||
for (String token : enchTokens) {
|
||||
String[] entryTokens = token.split(":");
|
||||
int id = Integer.parseInt(entryTokens[0]);
|
||||
int lvl = Integer.parseInt(entryTokens[1]);
|
||||
short id = Short.parseShort(entryTokens[0]);
|
||||
short lvl = Short.parseShort(entryTokens[1]);
|
||||
enchants.add(new EnchantmentData(id, lvl));
|
||||
}
|
||||
}
|
||||
@@ -479,9 +475,9 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
|
||||
private static class EnchantmentData {
|
||||
|
||||
public int enchant, level;
|
||||
public short enchant, level;
|
||||
|
||||
public EnchantmentData(int enchant, int level) {
|
||||
public EnchantmentData(short enchant, short level) {
|
||||
this.enchant = enchant;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
long least = compound.getLong(TAG_UUID_LEAST);
|
||||
UUID identity = getIdentifierUnsafe();
|
||||
if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits())
|
||||
identity = new UUID(most, least);
|
||||
this.identity = new UUID(most, least);
|
||||
} else getIdentifier();
|
||||
|
||||
mana = compound.getInteger(TAG_MANA);
|
||||
|
||||
@@ -256,6 +256,13 @@ public class CommonProxy {
|
||||
((EntityPlayerMP) entity).theItemInWorldManager.setBlockReachDistance(Math.max(5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets (instead of adds to) the extra reach of the client player. No-op on the server.
|
||||
*/
|
||||
public void setClientExtraReach(EntityLivingBase entity, float reach) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public boolean openWikiPage(World world, Block block, MovingObjectPosition pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,16 @@ import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockModSlab extends ItemSlab {
|
||||
private final String unlocalizedName;
|
||||
|
||||
public ItemBlockModSlab(Block blockSlab) {
|
||||
super(blockSlab, ((BlockModSlab)blockSlab).getSingleBlock(), ((BlockModSlab)blockSlab).getFullBlock(), false);
|
||||
unlocalizedName = blockSlab.getUnlocalizedName().replace("tile.", "tile.botania:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return field_150939_a.getUnlocalizedName().replaceAll("tile.", "tile.botania:");
|
||||
return unlocalizedName;
|
||||
}
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> infoList, boolean advanced) {
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
|
||||
public class ItemReachRing extends ItemBauble {
|
||||
|
||||
@@ -27,6 +30,29 @@ public class ItemReachRing extends ItemBauble {
|
||||
Botania.proxy.setExtraReach(player, 3.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLoad(ItemStack stack, EntityLivingBase player) {
|
||||
if(player.worldObj.isRemote) {
|
||||
// Baubles resends all baubles to the client on login and on every dimension change and calls this for each
|
||||
// of them, but the client keeps its reach extension across dimension changes. Set it instead of adding to it.
|
||||
Botania.proxy.setClientExtraReach(player, 3.5F * countWornRings(player));
|
||||
} else super.onPlayerLoad(stack, player);
|
||||
}
|
||||
|
||||
private static int countWornRings(EntityLivingBase player) {
|
||||
if(!(player instanceof EntityPlayer))
|
||||
return 0;
|
||||
|
||||
int count = 0;
|
||||
IInventory baubles = BaublesApi.getBaubles((EntityPlayer) player);
|
||||
for(int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
ItemStack bauble = baubles.getStackInSlot(i);
|
||||
if(bauble != null && bauble.getItem() instanceof ItemReachRing)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
Botania.proxy.setExtraReach(player, -3.5F);
|
||||
|
||||
Reference in new issue
Block a user