use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.
the class DarkSteelUpgradeRecipeCategory method registerSubtypes.
public static void registerSubtypes(ISubtypeRegistry subtypeRegistry) {
DarkSteelUpgradeSubtypeInterpreter dsusi = new DarkSteelUpgradeSubtypeInterpreter();
Set<Item> items = new HashSet<Item>();
for (ItemStack stack : ItemHelper.getValidItems()) {
if (stack.getItem() instanceof IDarkSteelItem)
items.add(stack.getItem());
}
for (Item item : items) {
if (item != null) {
subtypeRegistry.registerSubtypeInterpreter(item, dsusi);
}
}
}
use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.
the class EnergyUpgradePowerAdapter method attachCapabilities.
@SubscribeEvent
public static void attachCapabilities(@Nonnull AttachCapabilitiesEvent<ItemStack> evt) {
if (evt.getCapabilities().containsKey(KEY)) {
return;
}
final ItemStack stack = evt.getObject();
if (stack != null && stack.getItem() instanceof IDarkSteelItem) {
EnergyUpgadeCap cap = new EnergyUpgadeCap(stack);
evt.addCapability(KEY, cap);
}
}
use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.
the class UpgradeRenderDispatcher method doRenderLayer.
@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {
@Override
public void apply(@Nonnull EntityEquipmentSlot slot) {
ItemStack item = player.getItemStackFromSlot(slot);
if (item.getItem() instanceof IDarkSteelItem) {
for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
if (upgrade instanceof IHasPlayerRenderer && upgrade.hasUpgrade(item)) {
((IHasPlayerRenderer) upgrade).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
}
}
if (item.getItem() instanceof IHasPlayerRenderer) {
((IHasPlayerRenderer) item.getItem()).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
}
});
IInventory baubles = BaublesUtil.instance().getBaubles(player);
if (baubles != null) {
for (int i = 0; i < baubles.getSizeInventory(); i++) {
ItemStack piece = baubles.getStackInSlot(i);
if (piece.getItem() instanceof IHasPlayerRenderer) {
((IHasPlayerRenderer) piece.getItem()).getRender().doRenderLayer(renderPlayer, null, piece, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
}
}
}
use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.
the class DarkSteelController method onFall.
@SubscribeEvent
public static void onFall(LivingFallEvent event) {
float distance = event.getDistance();
if (distance > 3) {
ItemStack boots = event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.FEET);
if (boots.getItem() instanceof IDarkSteelItem) {
int energyStored = EnergyUpgradeManager.getEnergyStored(boots);
if (energyStored > 0) {
float toMitigate = distance - 3;
int energyCost = (int) Math.min(energyStored, Math.ceil(toMitigate * Config.darkSteelFallDistanceCost));
float mitigated = energyCost / (float) Config.darkSteelFallDistanceCost;
if (!event.getEntity().world.isRemote) {
EnergyUpgradeManager.extractEnergy(boots, (IDarkSteelItem) boots.getItem(), energyCost, false);
}
if (mitigated < toMitigate) {
// Log.debug("Mitigating fall damage partially: original=", distance, " mitigated=", mitigated, " remaining=", distance - mitigated, " power used=",
// energyCost);
event.setDistance(distance - mitigated);
} else {
// Log.debug("Canceling fall damage: original=", distance, " power used=", energyCost);
event.setCanceled(true);
}
}
}
}
}
use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.
the class DarkSteelController method onPlayerTick.
@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
EntityPlayer player = event.player;
if (event.phase == Phase.START && !player.isSpectator()) {
// boots
updateStepHeightAndFallDistance(player);
// leggings
SpeedController.updateSpeed(player);
NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {
@Override
public void apply(@Nonnull EntityEquipmentSlot slot) {
ItemStack item = player.getItemStackFromSlot(slot);
if (item.getItem() instanceof IDarkSteelItem) {
for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
if (upgrade.hasUpgrade(item)) {
upgrade.onPlayerTick(item, (IDarkSteelItem) item.getItem(), player);
}
}
}
}
});
}
}
Aggregations