use of uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class SyncMaterialData method process.
@Override
public void process(EntityPlayer player, Side side) {
final ISynthesisMaterial material = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
Iterator<Entry<String, Integer>> it = materials.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Integer> pair = (Map.Entry<String, Integer>) it.next();
material.setMaterial(MaterialRegistry.get(pair.getKey().toString()), pair.getValue());
}
}
use of uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class CapabilityEvents method onEntityConstructing.
@SubscribeEvent
public void onEntityConstructing(AttachCapabilitiesEvent<Entity> event) {
if (event.getObject() instanceof EntityPlayer) {
event.addCapability(new ResourceLocation(Reference.MODID, "IOrganizationXIII"), new ICapabilitySerializable<NBTTagCompound>() {
OrganizationXIIICapability.IOrganizationXIII inst = ModCapabilities.ORGANIZATION_XIII.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == ModCapabilities.ORGANIZATION_XIII;
}
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
return capability == ModCapabilities.ORGANIZATION_XIII ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.ORGANIZATION_XIII.getStorage().writeNBT(ModCapabilities.ORGANIZATION_XIII, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.ORGANIZATION_XIII.getStorage().readNBT(ModCapabilities.ORGANIZATION_XIII, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IMunny"), new ICapabilitySerializable<NBTPrimitive>() {
MunnyCapability.IMunny inst = ModCapabilities.MUNNY.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.MUNNY;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.MUNNY ? (T) inst : null;
}
@Override
public NBTPrimitive serializeNBT() {
return (NBTPrimitive) ModCapabilities.MUNNY.getStorage().writeNBT(ModCapabilities.MUNNY, inst, null);
}
@Override
public void deserializeNBT(NBTPrimitive nbt) {
ModCapabilities.MUNNY.getStorage().readNBT(ModCapabilities.MUNNY, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ICheatMode"), new ICapabilitySerializable<NBTPrimitive>() {
CheatModeCapability.ICheatMode inst = ModCapabilities.CHEAT_MODE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.CHEAT_MODE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.CHEAT_MODE ? (T) inst : null;
}
@Override
public NBTPrimitive serializeNBT() {
return (NBTPrimitive) ModCapabilities.CHEAT_MODE.getStorage().writeNBT(ModCapabilities.CHEAT_MODE, inst, null);
}
@Override
public void deserializeNBT(NBTPrimitive nbt) {
ModCapabilities.CHEAT_MODE.getStorage().readNBT(ModCapabilities.CHEAT_MODE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IPlayerStats"), new ICapabilitySerializable<NBTTagCompound>() {
PlayerStatsCapability.IPlayerStats inst = ModCapabilities.PLAYER_STATS.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.PLAYER_STATS;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.PLAYER_STATS ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.PLAYER_STATS.getStorage().writeNBT(ModCapabilities.PLAYER_STATS, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.PLAYER_STATS.getStorage().readNBT(ModCapabilities.PLAYER_STATS, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISummonKeyblade"), new ICapabilitySerializable<NBTTagCompound>() {
SummonKeybladeCapability.ISummonKeyblade inst = ModCapabilities.SUMMON_KEYBLADE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SUMMON_KEYBLADE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SUMMON_KEYBLADE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SUMMON_KEYBLADE.getStorage().writeNBT(ModCapabilities.SUMMON_KEYBLADE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SUMMON_KEYBLADE.getStorage().readNBT(ModCapabilities.SUMMON_KEYBLADE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IMagicState"), new ICapabilitySerializable<NBTTagCompound>() {
MagicStateCapability.IMagicState inst = ModCapabilities.MAGIC_STATE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.MAGIC_STATE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.MAGIC_STATE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.MAGIC_STATE.getStorage().writeNBT(ModCapabilities.MAGIC_STATE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.MAGIC_STATE.getStorage().readNBT(ModCapabilities.MAGIC_STATE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IDriveState"), new ICapabilitySerializable<NBTTagCompound>() {
DriveStateCapability.IDriveState inst = ModCapabilities.DRIVE_STATE.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.DRIVE_STATE;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.DRIVE_STATE ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.DRIVE_STATE.getStorage().writeNBT(ModCapabilities.DRIVE_STATE, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.DRIVE_STATE.getStorage().readNBT(ModCapabilities.DRIVE_STATE, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "IFirstTimeJoin"), new ICapabilitySerializable<NBTTagCompound>() {
FirstTimeJoinCapability.IFirstTimeJoin inst = ModCapabilities.FIRST_TIME_JOIN.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.FIRST_TIME_JOIN;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.FIRST_TIME_JOIN ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.FIRST_TIME_JOIN.getStorage().writeNBT(ModCapabilities.FIRST_TIME_JOIN, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.FIRST_TIME_JOIN.getStorage().readNBT(ModCapabilities.FIRST_TIME_JOIN, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISynthesisRecipe"), new ICapabilitySerializable<NBTTagCompound>() {
SynthesisRecipeCapability.ISynthesisRecipe inst = ModCapabilities.SYNTHESIS_RECIPES.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_RECIPES;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_RECIPES ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SYNTHESIS_RECIPES.getStorage().writeNBT(ModCapabilities.SYNTHESIS_RECIPES, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SYNTHESIS_RECIPES.getStorage().readNBT(ModCapabilities.SYNTHESIS_RECIPES, inst, null, nbt);
}
});
event.addCapability(new ResourceLocation(Reference.MODID, "ISynthesisMaterial"), new ICapabilitySerializable<NBTTagCompound>() {
SynthesisMaterialCapability.ISynthesisMaterial inst = ModCapabilities.SYNTHESIS_MATERIALS.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_MATERIALS;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == ModCapabilities.SYNTHESIS_MATERIALS ? (T) inst : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) ModCapabilities.SYNTHESIS_MATERIALS.getStorage().writeNBT(ModCapabilities.SYNTHESIS_MATERIALS, inst, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
ModCapabilities.SYNTHESIS_MATERIALS.getStorage().readNBT(ModCapabilities.SYNTHESIS_MATERIALS, inst, null, nbt);
}
});
}
}
use of uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class GuiMaterialList method drawSlot.
@Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) {
ISynthesisMaterial MATS = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
List<String> materials = new ArrayList<String>();
materials.addAll(MATS.getKnownMaterialsMap().keySet());
this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(materials.get(var1).toString() + ".name") + " x" + MATS.getKnownMaterialsMap().get(materials.get(var1)), listWidth - 10), this.left + 3, var3 + 2, 0xFFFFFF);
Material m = MaterialRegistry.get(materials.get(var1).toString());
if (m.getTexture() != null) {
GL11.glPushMatrix();
{
ResourceLocation texture = m.getTexture();
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GL11.glTranslatef(this.left + 3, var3 + 12, 0);
GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
parent.drawTexturedModalRect(0, 0, 0, 0, 256, 256);
}
GL11.glPopMatrix();
} else {
ItemStack item = m.getItem();
this.ir.renderItemAndEffectIntoGUI(item, this.left + 3, var3 + 12);
}
}
Aggregations