mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Fix sparks not being colored by network
This commit is contained in:
1 parent
9f1a2b8a7d
commit
1229141b2f
4 files changed
+17
-16
No files matched your search
@@ -12,6 +12,7 @@ package vazkii.botania.api.corporea;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
@@ -81,6 +82,6 @@ public interface ICorporeaSpark {
|
||||
* Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others
|
||||
* of the same network, and on changing network should trigger a re-cache of the previous network.
|
||||
*/
|
||||
public int getNetwork();
|
||||
public EnumDyeColor getNetwork();
|
||||
|
||||
}
|
||||
@@ -32,12 +32,11 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
|
||||
|
||||
@Override
|
||||
public void colorSpinningIcon(EntityCorporeaSpark entity, float a) {
|
||||
int network = Math.min(15, entity.getNetwork());
|
||||
int hex = EnumDyeColor.byMetadata(network).getMapColor().colorValue;
|
||||
int hex = entity.getNetwork().getMapColor().colorValue;
|
||||
int r = (hex & 0xFF0000) >> 16;
|
||||
int g = (hex & 0xFF00) >> 8;
|
||||
int b = (hex & 0xFF);
|
||||
GlStateManager.color(r, g, b, a);
|
||||
GlStateManager.color(r / 255F, g / 255F, b / 255F, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,19 +80,19 @@ public class RenderSparkBase<T extends Entity> extends RenderEntity {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getBaseIcon(T entity) {
|
||||
protected TextureAtlasSprite getBaseIcon(T entity) {
|
||||
return MiscellaneousIcons.INSTANCE.sparkWorldIcon;
|
||||
}
|
||||
|
||||
public void colorSpinningIcon(T entity, float a) {
|
||||
protected void colorSpinningIcon(T entity, float a) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSpinningIcon(T entity) {
|
||||
protected TextureAtlasSprite getSpinningIcon(T entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renderCallback(T entity, float pticks) {
|
||||
protected void renderCallback(T entity, float pticks) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -230,13 +231,13 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
|
||||
return dataWatcher.getWatchableObjectInt(28) == 1;
|
||||
}
|
||||
|
||||
public void setNetwork(int network) {
|
||||
dataWatcher.updateObject(29, network);
|
||||
public void setNetwork(EnumDyeColor network) {
|
||||
dataWatcher.updateObject(29, network.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNetwork() {
|
||||
return dataWatcher.getWatchableObjectInt(29);
|
||||
public EnumDyeColor getNetwork() {
|
||||
return EnumDyeColor.byMetadata(dataWatcher.getWatchableObjectInt(29));
|
||||
}
|
||||
|
||||
public int getItemDisplayTicks() {
|
||||
@@ -273,8 +274,8 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
|
||||
}
|
||||
} else if(stack.getItem() == ModItems.dye) {
|
||||
int color = stack.getItemDamage();
|
||||
if(color != getNetwork()) {
|
||||
setNetwork(color);
|
||||
if(color != getNetwork().getMetadata()) {
|
||||
setNetwork(EnumDyeColor.byMetadata(color));
|
||||
|
||||
if(master != null)
|
||||
restartNetwork();
|
||||
@@ -303,14 +304,14 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound cmp) {
|
||||
setMaster(cmp.getBoolean(TAG_MASTER));
|
||||
setNetwork(cmp.getInteger(TAG_NETWORK));
|
||||
setNetwork(EnumDyeColor.byMetadata(cmp.getInteger(TAG_NETWORK)));
|
||||
dataWatcher.updateObject(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound cmp) {
|
||||
cmp.setBoolean(TAG_MASTER, isMaster());
|
||||
cmp.setInteger(TAG_NETWORK, getNetwork());
|
||||
cmp.setInteger(TAG_NETWORK, getNetwork().getMetadata());
|
||||
cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(EntitySpark.INVISIBILITY_DATA_WATCHER_KEY));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user