Some cleanup
Changed AltarMaker chat anti-spam. Fixed formatting for AltarMaker messages
This commit is contained in:
parent
8f8f0e6910
commit
ff055a33da
|
@ -6,7 +6,10 @@ import WayofTime.bloodmagic.api.Constants;
|
|||
import WayofTime.bloodmagic.api.altar.AltarComponent;
|
||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -38,45 +41,44 @@ public class ItemAltarMaker extends Item implements IAltarManipulator {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
tooltip.add(StatCollector.translateToLocal("tooltip.BloodMagic.currentTier") + " " + ((stack.getTagCompound() != null ? stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) : 0) + 1));
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER + 1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (!player.capabilities.isCreativeMode || world.isRemote) return itemStack;
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!player.capabilities.isCreativeMode || world.isRemote)
|
||||
return stack;
|
||||
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (itemStack.getTagCompound() == null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
itemStack.setTagCompound(tag);
|
||||
itemStack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
|
||||
}
|
||||
if (player.isSneaking()) {
|
||||
if (itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1) {
|
||||
itemStack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
|
||||
setTierToBuild(EnumAltarTier.values()[itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]);
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(StatCollector.translateToLocal("misc.altarMaker.setTier"), itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
|
||||
return itemStack;
|
||||
if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1) {
|
||||
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
|
||||
setTierToBuild(EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]);
|
||||
ChatUtil.sendNoSpamClient(TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
|
||||
return stack;
|
||||
}
|
||||
else {
|
||||
itemStack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1);
|
||||
setTierToBuild(EnumAltarTier.values()[itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]);
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(StatCollector.translateToLocal("misc.altarMaker.setTier"), itemStack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
|
||||
return itemStack;
|
||||
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1);
|
||||
setTierToBuild(EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]);
|
||||
ChatUtil.sendNoSpamClient(TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (mop == null || mop.typeOfHit == MovingObjectPosition.MovingObjectType.MISS || mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) return itemStack;
|
||||
if (mop == null || mop.typeOfHit == MovingObjectPosition.MovingObjectType.MISS || mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) return stack;
|
||||
|
||||
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && world.getBlockState(mop.getBlockPos()).getBlock() instanceof BlockAltar) {
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(StatCollector.translateToLocal("misc.altarMaker.building"), tierToBuild));
|
||||
ChatUtil.sendNoSpamClient(TextHelper.localizeEffect("chat.BloodMagic.altarMaker.building", tierToBuild));
|
||||
buildAltar(world, mop.getBlockPos());
|
||||
|
||||
world.markBlockForUpdate(mop.getBlockPos());
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void setTierToBuild(EnumAltarTier tierToBuild) {
|
||||
|
@ -87,9 +89,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator {
|
|||
|
||||
if (world.isRemote) return;
|
||||
|
||||
if (tierToBuild == EnumAltarTier.ONE) {
|
||||
if (tierToBuild == EnumAltarTier.ONE)
|
||||
return;
|
||||
}
|
||||
|
||||
for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) {
|
||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||
|
@ -108,7 +109,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator {
|
|||
|
||||
public String destroyAltar(EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
if (world.isRemote) return "";
|
||||
if (world.isRemote)
|
||||
return "";
|
||||
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
BlockPos pos = mop.getBlockPos();
|
||||
|
@ -125,6 +127,6 @@ public class ItemAltarMaker extends Item implements IAltarManipulator {
|
|||
}
|
||||
|
||||
world.markBlockForUpdate(pos);
|
||||
return "" + altarTier.toInt();
|
||||
return String.valueOf(altarTier.toInt());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,31 +162,24 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
|||
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1));
|
||||
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1), block, block.getBlock());
|
||||
}
|
||||
if (getWorld().getTotalWorldTime() % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
|
||||
everySecond();
|
||||
if (getWorld().getTotalWorldTime() % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) {
|
||||
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
||||
int fluidInputted;
|
||||
int fluidOutputted;
|
||||
fluidInputted = Math.min(syphonMax, -this.fluid.amount + capacity);
|
||||
fluidInputted = Math.min(this.fluidInput.amount, fluidInputted);
|
||||
this.fluid.amount += fluidInputted;
|
||||
this.fluidInput.amount -= fluidInputted;
|
||||
fluidOutputted = Math.min(syphonMax, this.bufferCapacity - this.fluidOutput.amount);
|
||||
fluidOutputted = Math.min(this.fluid.amount, fluidOutputted);
|
||||
this.fluidOutput.amount += fluidOutputted;
|
||||
this.fluid.amount -= fluidOutputted;
|
||||
}
|
||||
|
||||
if (getWorld().getTotalWorldTime() % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
|
||||
everyFiveSeconds();
|
||||
startCycle();
|
||||
|
||||
updat();
|
||||
}
|
||||
|
||||
private void everySecond() {
|
||||
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
||||
int fluidInputted;
|
||||
int fluidOutputted;
|
||||
fluidInputted = Math.min(syphonMax, -this.fluid.amount + capacity);
|
||||
fluidInputted = Math.min(this.fluidInput.amount, fluidInputted);
|
||||
this.fluid.amount += fluidInputted;
|
||||
this.fluidInput.amount -= fluidInputted;
|
||||
fluidOutputted = Math.min(syphonMax, this.bufferCapacity - this.fluidOutput.amount);
|
||||
fluidOutputted = Math.min(this.fluid.amount, fluidOutputted);
|
||||
this.fluidOutput.amount += fluidOutputted;
|
||||
this.fluid.amount -= fluidOutputted;
|
||||
}
|
||||
|
||||
private void everyFiveSeconds() {
|
||||
startCycle();
|
||||
updateAltar();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -224,7 +217,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
|||
isActive = false;
|
||||
}
|
||||
|
||||
private void updat() {
|
||||
private void updateAltar() {
|
||||
if (!isActive) {
|
||||
if (cooldownAfterCrafting > 0)
|
||||
cooldownAfterCrafting--;
|
||||
|
@ -311,8 +304,6 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
|||
}
|
||||
|
||||
private void checkTier() {
|
||||
// TODO - Write checking for tier stuff
|
||||
|
||||
EnumAltarTier tier = BloodAltar.getAltarTier(getWorld(), getPos());
|
||||
this.altarTier = tier;
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package WayofTime.bloodmagic.util.handler;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -66,7 +69,7 @@ public class EventHandler {
|
|||
public void harvestEvent(PlayerEvent.HarvestCheck event) {
|
||||
if (event.block != null && event.block instanceof BlockAltar && event.entityPlayer != null && event.entityPlayer instanceof EntityPlayerMP && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemAltarMaker) {
|
||||
ItemAltarMaker altarMaker = (ItemAltarMaker) event.entityPlayer.getCurrentEquippedItem().getItem();
|
||||
event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation(StatCollector.translateToLocal("misc.altarMaker.destroy"), altarMaker.destroyAltar(event.entityPlayer)));
|
||||
ChatUtil.sendNoSpamClient(TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.entityPlayer)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ tile.BloodMagic.bloodLight.name=Blood Light
|
|||
tooltip.BloodMagic.orb.desc=Stores raw Life Essence
|
||||
tooltip.BloodMagic.orb.owner=Added by: %s
|
||||
tooltip.BloodMagic.currentOwner=Owner: %s
|
||||
tooltip.BloodMagic.currentTier=Current tier:
|
||||
tooltip.BloodMagic.currentTier=Current tier: %d
|
||||
|
||||
tooltip.BloodMagic.sigil.air.desc=&oI feel lighter already...
|
||||
tooltip.BloodMagic.sigil.bloodLight.desc=&oI see a light!
|
||||
|
@ -125,10 +125,10 @@ tooltip.BloodMagic.activationCrystal.weak=Activates low-level rituals
|
|||
tooltip.BloodMagic.activationCrystal.awakened=Activates more powerful rituals
|
||||
tooltip.BloodMagic.activationCrystal.creative=Creative Only - Activates any ritual
|
||||
|
||||
# Miscs
|
||||
misc.altarMaker.setTier=Set Tier to: %d
|
||||
misc.altarMaker.building=Building a: Tier %d Altar
|
||||
misc.altarMaker.destroy=Destroyed a: Tier %d Altar
|
||||
# Chat
|
||||
chat.BloodMagic.altarMaker.setTier=Set Tier to: %d
|
||||
chat.BloodMagic.altarMaker.building=Building a Tier %d Altar
|
||||
chat.BloodMagic.altarMaker.destroy=Destroyed a Tier %d Altar
|
||||
|
||||
# JustEnoughItems
|
||||
jei.BloodMagic.recipe.altar=Blood Altar
|
||||
|
|
Loading…
Reference in a new issue