mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 05:02:30 +00:00
More Map Maker things. Clsoes #150.
This commit is contained in:
1 parent
1a0dc81e92
commit
a70132df5c
4 files changed
+158
-29
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
/**
|
||||
* A TileEntity that implements this interface has an IO key lock. This
|
||||
* interface defines an input and output key.<br><br>
|
||||
*
|
||||
* A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input
|
||||
* key of the TE is equal to the Output key of the Spreader.<br><br>
|
||||
*
|
||||
* A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the
|
||||
* Output key of the IManaPool is equal to the Input key of the Spreader.
|
||||
*/
|
||||
public interface IKeyLocked {
|
||||
|
||||
public String getInputKey();
|
||||
|
||||
public String getOutputKey();
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -32,6 +33,7 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.wand.IWandHUD;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.item.block.ItemBlockPool;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
@@ -40,6 +42,8 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BlockPool extends BlockModContainer implements IWandHUD, IWandable, ILexiconable {
|
||||
|
||||
boolean lastFragile = false;
|
||||
|
||||
protected BlockPool() {
|
||||
super(Material.rock);
|
||||
setHardness(2.0F);
|
||||
@@ -64,10 +68,26 @@ public class BlockPool extends BlockModContainer implements IWandHUD, IWandable,
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1) {
|
||||
return par1;
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
|
||||
TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4);
|
||||
lastFragile = pool.fragile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> drops = new ArrayList();
|
||||
|
||||
if(!lastFragile)
|
||||
drops.add(new ItemStack(this, 1, metadata));
|
||||
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.IKeyLocked;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.ManaNetworkEvent;
|
||||
@@ -41,7 +42,7 @@ import vazkii.botania.common.block.tile.TileMod;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
public class TilePool extends TileMod implements IManaPool {
|
||||
public class TilePool extends TileMod implements IManaPool, IKeyLocked {
|
||||
|
||||
public static final int MAX_MANA = 1000000;
|
||||
|
||||
@@ -50,6 +51,11 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
private static final String TAG_OUTPUTTING = "outputting";
|
||||
private static final String TAG_COLOR = "color";
|
||||
private static final String TAG_MANA_CAP = "manaCap";
|
||||
private static final String TAG_CAN_ACCEPT = "canAccept";
|
||||
private static final String TAG_CAN_SPARE = "canSpare";
|
||||
private static final String TAG_FRAGILE = "fragile";
|
||||
private static final String TAG_INPUT_KEY = "inputKey";
|
||||
private static final String TAG_OUTPUT_KEY = "outputKey";
|
||||
|
||||
boolean outputting = false;
|
||||
public boolean alchemy = false;
|
||||
@@ -59,8 +65,15 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
int mana;
|
||||
int knownMana = -1;
|
||||
int craftCooldown = 20;
|
||||
|
||||
public int manaCap = MAX_MANA;
|
||||
boolean canAccept = true;
|
||||
boolean canSpare = true;
|
||||
public boolean fragile = false;
|
||||
|
||||
String inputKey = "";
|
||||
String outputKey = "";
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
Block blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
|
||||
@@ -177,22 +190,26 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
boolean didSomething = false;
|
||||
|
||||
if(outputting) {
|
||||
if(getCurrentMana() > 0)
|
||||
didSomething = true;
|
||||
if(canSpare) {
|
||||
if(getCurrentMana() > 0)
|
||||
didSomething = true;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
int manaVal = Math.min(1000, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack)));
|
||||
mana.addMana(stack, manaVal);
|
||||
recieveMana(-manaVal);
|
||||
if(!worldObj.isRemote) {
|
||||
int manaVal = Math.min(1000, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack)));
|
||||
mana.addMana(stack, manaVal);
|
||||
recieveMana(-manaVal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mana.getMana(stack) > 0)
|
||||
didSomething = true;
|
||||
if(canAccept) {
|
||||
if(mana.getMana(stack) > 0)
|
||||
didSomething = true;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
int manaVal = Math.min(1000, Math.min(MAX_MANA - getCurrentMana(), mana.getMana(stack)));
|
||||
mana.addMana(stack, -manaVal);
|
||||
recieveMana(manaVal);
|
||||
if(!worldObj.isRemote) {
|
||||
int manaVal = Math.min(1000, Math.min(MAX_MANA - getCurrentMana(), mana.getMana(stack)));
|
||||
mana.addMana(stack, -manaVal);
|
||||
recieveMana(manaVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +230,14 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
cmp.setBoolean(TAG_OUTPUTTING, outputting);
|
||||
cmp.setInteger(TAG_COLOR, color);
|
||||
|
||||
cmp.setInteger(TAG_MANA_CAP, manaCap);
|
||||
cmp.setBoolean(TAG_CAN_ACCEPT, canAccept);
|
||||
cmp.setBoolean(TAG_CAN_SPARE, canSpare);
|
||||
cmp.setBoolean(TAG_FRAGILE, fragile);
|
||||
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,9 +245,20 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
mana = cmp.getInteger(TAG_MANA);
|
||||
outputting = cmp.getBoolean(TAG_OUTPUTTING);
|
||||
color = cmp.getInteger(TAG_COLOR);
|
||||
|
||||
if(cmp.hasKey(TAG_MANA_CAP))
|
||||
manaCap = cmp.getInteger(TAG_MANA_CAP);
|
||||
|
||||
if(cmp.hasKey(TAG_CAN_ACCEPT))
|
||||
canAccept = cmp.getBoolean(TAG_CAN_ACCEPT);
|
||||
if(cmp.hasKey(TAG_CAN_SPARE))
|
||||
canSpare = cmp.getBoolean(TAG_CAN_SPARE);
|
||||
fragile = cmp.getBoolean(TAG_FRAGILE);
|
||||
|
||||
if(cmp.hasKey(TAG_INPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_INPUT_KEY);
|
||||
if(cmp.hasKey(TAG_OUTPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_OUTPUT_KEY);
|
||||
|
||||
if(cmp.hasKey(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInteger(TAG_KNOWN_MANA);
|
||||
}
|
||||
@@ -276,4 +311,14 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
public int getCurrentMana() {
|
||||
return worldObj != null && getBlockMetadata() == 1 ? MAX_MANA : mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInputKey() {
|
||||
return inputKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputKey() {
|
||||
return outputKey;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
import vazkii.botania.api.mana.IKeyLocked;
|
||||
import vazkii.botania.api.mana.ILens;
|
||||
import vazkii.botania.api.mana.ILensEffect;
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
@@ -52,7 +53,7 @@ import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, ITileBound {
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, ITileBound, IKeyLocked {
|
||||
|
||||
private static final int MAX_MANA = 1000;
|
||||
private static final String TAG_MANA = "mana";
|
||||
@@ -60,12 +61,16 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
private static final String TAG_REQUEST_UPDATE = "requestUpdate";
|
||||
private static final String TAG_ROTATION_X = "rotationX";
|
||||
private static final String TAG_ROTATION_Y = "rotationY";
|
||||
|
||||
|
||||
private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX";
|
||||
private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY";
|
||||
private static final String TAG_FORCE_CLIENT_BINDING_Z = "forceClientBindingZ";
|
||||
|
||||
// Map Maker Tags
|
||||
|
||||
private static final String TAG_INPUT_KEY = "inputKey";
|
||||
private static final String TAG_OUTPUT_KEY = "outputKey";
|
||||
|
||||
private static final String TAG_MAPMAKER_OVERRIDE = "mapmakerOverrideEnabled";
|
||||
private static final String TAG_FORCED_COLOR = "mmForcedColor";
|
||||
private static final String TAG_FORCED_MANA_PAYLOAD = "mmForcedManaPayload";
|
||||
@@ -73,15 +78,20 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
private static final String TAG_FORCED_MANA_LOSS_PER_TICK = "mmForcedManaLossPerTick";
|
||||
private static final String TAG_FORCED_GRAVITY = "mmForcedGravity";
|
||||
private static final String TAG_FORCED_VELOCITY_MULTIPLIER = "mmForcedVelocityMultiplier";
|
||||
|
||||
boolean mapmakerOverride = false;
|
||||
int mmForcedColor = 0x20FF20;
|
||||
int mmForcedManaPayload = 160;
|
||||
int mmForcedTicksBeforeManaLoss = 60;
|
||||
float mmForcedManaLossPerTick = 4F;
|
||||
float mmForcedGravity = 0F;
|
||||
float mmForcedVelocityMultiplier = 1F;
|
||||
|
||||
private boolean mapmakerOverride = false;
|
||||
private int mmForcedColor = 0x20FF20;
|
||||
private int mmForcedManaPayload = 160;
|
||||
private int mmForcedTicksBeforeManaLoss = 60;
|
||||
private float mmForcedManaLossPerTick = 4F;
|
||||
private float mmForcedGravity = 0F;
|
||||
private float mmForcedVelocityMultiplier = 1F;
|
||||
|
||||
String inputKey = "";
|
||||
String outputKey = "";
|
||||
|
||||
// End Map Maker Tags
|
||||
|
||||
public static boolean staticRedstone = false;
|
||||
public static boolean staticDreamwood = false;
|
||||
|
||||
@@ -136,6 +146,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
if(tileAt instanceof IManaPool) {
|
||||
IManaPool pool = (IManaPool) tileAt;
|
||||
if(pool != receiver) {
|
||||
if(pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey()))
|
||||
continue;
|
||||
|
||||
int manaInPool = pool.getCurrentMana();
|
||||
if(manaInPool > 0 && !isFull()) {
|
||||
int manaMissing = MAX_MANA - mana;
|
||||
@@ -159,10 +172,12 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
if(isRedstone())
|
||||
shouldShoot = redstone && !redstoneLastTick;
|
||||
|
||||
if(receiver != null && receiver instanceof IKeyLocked)
|
||||
shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey());
|
||||
|
||||
if(shouldShoot)
|
||||
tryShootBurst();
|
||||
|
||||
|
||||
if(receiverLastTick != receiver && !worldObj.isRemote) {
|
||||
requestsClientUpdate = true;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
@@ -179,10 +194,14 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
cmp.setFloat(TAG_ROTATION_X, rotationX);
|
||||
cmp.setFloat(TAG_ROTATION_Y, rotationY);
|
||||
cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate);
|
||||
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_X, receiver == null ? 0 : ((TileEntity) receiver).xCoord);
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Y, receiver == null ? -1 : ((TileEntity) receiver).yCoord);
|
||||
cmp.setInteger(TAG_FORCE_CLIENT_BINDING_Z, receiver == null ? 0 : ((TileEntity) receiver).zCoord);
|
||||
|
||||
|
||||
cmp.setBoolean(TAG_MAPMAKER_OVERRIDE, mapmakerOverride);
|
||||
cmp.setInteger(TAG_FORCED_COLOR, mmForcedColor);
|
||||
cmp.setInteger(TAG_FORCED_MANA_PAYLOAD, mmForcedManaPayload);
|
||||
@@ -201,6 +220,11 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
rotationX = cmp.getFloat(TAG_ROTATION_X);
|
||||
rotationY = cmp.getFloat(TAG_ROTATION_Y);
|
||||
requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE);
|
||||
|
||||
if(cmp.hasKey(TAG_INPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_INPUT_KEY);
|
||||
if(cmp.hasKey(TAG_OUTPUT_KEY))
|
||||
inputKey = cmp.getString(TAG_OUTPUT_KEY);
|
||||
|
||||
mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE);
|
||||
mmForcedColor = cmp.getInteger(TAG_FORCED_COLOR);
|
||||
@@ -489,4 +513,14 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public int getMaxMana() {
|
||||
return MAX_MANA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInputKey() {
|
||||
return inputKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputKey() {
|
||||
return outputKey;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user