Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
updated mod
Browse files Browse the repository at this point in the history
  • Loading branch information
roryclaasen committed Jul 12, 2017
1 parent 6e4d0e7 commit 73d9978
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 77 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

mod_version=1.2.8
mod_version=1.3

# Minecraft
mc_version=1.7.10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public boolean canInteractWith(EntityPlayer player) {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.inventorySlots.size(); ++i) {
ItemStack itemstack = ((Slot) this.inventorySlots.get(i)).getStack();
ItemStack itemstack1 = (ItemStack) this.inventoryItemStacks.get(i);

if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) {
tileEntity.writeToLaser();
}
}
// for (int i = 0; i < this.inventorySlots.size(); ++i) {
// ItemStack itemstack = ((Slot) this.inventorySlots.get(i)).getStack();
// ItemStack itemstack1 = (ItemStack) this.inventoryItemStacks.get(i);
//
// if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) {
// tileEntity.writeToLaser();
// }
// }
}

private void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/roryclaasen/rorysmod/core/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@ public void createRecipes() {
// Rifle
Register.addShapedRecipie(new ItemStack(rifleBarrel), new Object[] { "sss", " ", "sss", 's', "ingotSteel" });
Register.addShapedRecipie(new ItemStack(rifleTrigger), new Object[] { " ss", " s ", " s", 's', "ingotSteel" });

Register.addShapedRecipie(new ItemStack(rifle1), new Object[] { "lbe", "ssc", " ts", 'l', "lens", 'b', new ItemStack(rifleBarrel), 'e', IC2Items.getItem("energyCrystal"), 's', "plateSteel", 'c', "circuitAdvanced", 't', new ItemStack(rifleTrigger) });

Register.addShaplessRecipie(new ItemStack(rifle2), new Object[] { rifle1, new ItemStack(upgradePlate), IC2Items.getItem("energyCrystal") });
Register.addShaplessRecipie(new ItemStack(rifle3), new Object[] { rifle2, new ItemStack(upgradePlate), IC2Items.getItem("energyCrystal") });
Register.addShaplessRecipie(new ItemStack(rifle4), new Object[] { rifle4, new ItemStack(upgradePlate), new ItemStack(upgradePlate), IC2Items.getItem("energyCrystal") });
Register.addShaplessRecipie(new ItemStack(rifle5), new Object[] { rifle5, new ItemStack(upgradePlate), new ItemStack(upgradePlate), IC2Items.getItem("energyCrystal") });

// Rifle upgrade
Register.addShapedRecipie(new ItemStack(upgradePlate, 2), new Object[] { "rir", "nsn", "rir", 'r', Items.redstone, 'i', "ingotIron", 'n', Items.gold_nugget, 's', "plateSteel" });
Register.addShapedRecipie(new ItemStack(rifleUpgrade), new Object[] { "cuc", 'u', new ItemStack(upgradePlate), 'c', "circuitBasic" });
Expand Down
90 changes: 55 additions & 35 deletions src/main/java/me/roryclaasen/rorysmod/entity/EntityLaser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package me.roryclaasen.rorysmod.entity;

import me.roryclaasen.rorysmod.core.Settings;
import me.roryclaasen.rorysmod.util.NBTLaser;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
Expand All @@ -22,8 +24,7 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import me.roryclaasen.rorysmod.core.Settings;
import me.roryclaasen.rorysmod.util.NBTLaser;
import net.minecraftforge.common.util.ForgeDirection;

public class EntityLaser extends EntityThrowable {

Expand Down Expand Up @@ -66,33 +67,13 @@ protected void onImpact(MovingObjectPosition movingObjectPosition) {
if (movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
if (Settings.setFireToBlocks) {
if (data.getItemCount(NBTLaser.Items.Igniter) > 0) {
int x = movingObjectPosition.blockX, y = movingObjectPosition.blockY, z = movingObjectPosition.blockZ;
boolean fire = true;
switch (movingObjectPosition.sideHit) {
case -1: {
fire = false;
}
case 0: {
--y;
fire = false;
}
case 1: {
++y;
}
case 2: {
--z;
}
case 3: {
++z;
}
case 4: {
--x;
}
case 5: {
++x;
}
}
if (fire) worldObj.setBlock(x, y, z, Blocks.fire);
// int range = 1 + (int) Math.floor(data.getItemCount(NBTLaser.Items.Igniter) / 2);

// int minX = movingObjectPosition.blockX - range, maxX = movingObjectPosition.blockX + range;
// int minY = movingObjectPosition.blockY - range, maxY = movingObjectPosition.blockY + range;
// int minZ = movingObjectPosition.blockZ - range, maxZ = movingObjectPosition.blockZ + range;

setBlockOnFire(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ, movingObjectPosition.sideHit);
}
}
} else if (movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
Expand All @@ -106,10 +87,47 @@ protected void onImpact(MovingObjectPosition movingObjectPosition) {
}
}

private void setBlockOnFire(int x, int y, int z, int side) {
boolean fire = true;
switch (side) {
case -1: {
fire = false;
}
case 0: {
--y;
fire = false;
}
case 1: {
++y;
}
case 2: {
--z;
}
case 3: {
++z;
}
case 4: {
--x;
}
case 5: {
++x;
}
}
if (fire) {
if (worldObj.isAirBlock(x, y, z) && worldObj.isSideSolid(x, y, z, ForgeDirection.DOWN)) {
worldObj.setBlock(x, y, z, Blocks.fire);
}
}

}

private void setFire(Entity entity) {
if (data != null) {
if (data.getItemCount(NBTLaser.Items.Igniter) > 0) {
entity.setFire((int) Math.ceil((double) data.getItemCount(NBTLaser.Items.Igniter) * 1.5));
float time = data.getItemCount(NBTLaser.Items.Igniter);
time += 0.5f * data.getItemCount(NBTLaser.Items.Overclock);
time -= 0.2f * data.getItemCount(NBTLaser.Items.Coolant);
entity.setFire((int) Math.ceil(time));
}
}
}
Expand All @@ -122,17 +140,19 @@ private void doDamage(Entity entity) {

private float getDamage() {
if (data.getItemCount(NBTLaser.Items.Phaser) == 0) return 0F;
float perP = 1.5F;
float perO = 1.2F;
float total = 1F + perP * ((float) data.getItemCount(NBTLaser.Items.Phaser) + (perO * ((float) data.getItemCount(NBTLaser.Items.Overclock) + 1F)));
float total = 1F * data.getItemCount(NBTLaser.Items.Phaser);
total += 0.75 * data.getItemCount(NBTLaser.Items.Overclock);
total -= 0.2 * data.getItemCount(NBTLaser.Items.Coolant);
return total;
}

private void explode() {
if (data != null) {
if (data.getItemCount(NBTLaser.Items.Explosion) > 0) {
float expl = 1F + (0.325F * (float) data.getItemCount(NBTLaser.Items.Explosion)) + (0.1F * (float) data.getItemCount(NBTLaser.Items.Overclock));
worldObj.createExplosion(this, posX, posY, posZ, expl, true);
float strength = 1F * data.getItemCount(NBTLaser.Items.Explosion);
strength += 0.5F * data.getItemCount(NBTLaser.Items.Overclock);

worldObj.newExplosion(this, posX, posY, posZ, strength, data.getItemCount(NBTLaser.Items.Igniter) > 0, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
/*
Copyright 2016-2017 Rory Claasen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* Copyright 2016-2017 Rory Claasen
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.roryclaasen.rorysmod.item;

import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import me.roryclaasen.rorysmod.util.NBTLaser;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class ItemBaseEnergyContainer extends ItemBase implements IEnergyContainerItem {

Expand Down Expand Up @@ -98,14 +96,22 @@ public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate)
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) return 0;
int energy = container.stackTagCompound.getInteger("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));

NBTLaser data = new NBTLaser(container);

float energyCost = 50F;
energyCost += 15F * data.getItemCount(NBTLaser.Items.Explosion);
energyCost += 7F * data.getItemCount(NBTLaser.Items.Igniter);
energyCost += 50F * data.getItemCount(NBTLaser.Items.Overclock);
energyCost += 5F * data.getItemCount(NBTLaser.Items.Phaser);

if (!simulate) {
energy -= energyExtracted;
if (energyCost > energy) return 0;
energy -= energyCost;
container.stackTagCompound.setInteger("Energy", energy);
updateItemDamage(container);
}
return energyExtracted;
return energy;
}

@Override
Expand All @@ -119,15 +125,15 @@ public int getMaxEnergyStored(ItemStack container) {
return capacity;
}

private void updateItemDamage(ItemStack itemtack) {
if (itemtack.stackTagCompound.hasKey("Energy")) {
int energy = itemtack.stackTagCompound.getInteger("Energy");
private void updateItemDamage(ItemStack itemstack) {
if (itemstack.stackTagCompound.hasKey("Energy")) {
int energy = itemstack.stackTagCompound.getInteger("Energy");
int percentage = (int) (((double) energy / (double) this.capacity) * (double) 100);
itemtack.setItemDamage(getMaxDamage() - percentage);
itemstack.setItemDamage(getMaxDamage() - percentage);
}
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({ "unchecked", "rawtypes" })
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
Expand Down
29 changes: 20 additions & 9 deletions src/main/java/me/roryclaasen/rorysmod/item/ItemRifle.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class ItemRifle extends ItemBaseEnergyContainer {

public ItemRifle(String unlocalizedName, int tier) {
super(unlocalizedName, 1000 * (tier), 10);
super(unlocalizedName, 1000 * (tier), 10, 50);
this.setMaxStackSize(1);
this.setMaxDamage(100);
this.setFull3D();
Expand All @@ -57,6 +57,7 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer
if (data.checkWeight(this.tier)) {
if (!data.overheating()) {
if (this.use(itemStack, false)) {
data = new NBTLaser(itemStack.stackTagCompound);
fireRifle(itemStack, world, player);
data.setCooldown(data.getMaxCooldown());
itemStack.stackTagCompound = data.getTag();
Expand All @@ -76,21 +77,31 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int par4, boolean par5) {
NBTLaser data = new NBTLaser(itemstack.stackTagCompound);
if (data.getCooldown() > 0) {
data.setCooldown(data.getCooldown() - 1);
int cooldown = data.getCooldown();
if (cooldown > 0) {
int newCooldown = cooldown - 1;
newCooldown -= (data.getItemCount(NBTLaser.Items.Coolant) / 2);
if (entity.isWet()) newCooldown -= 2;
data.setCooldown(newCooldown);
}
itemstack.stackTagCompound = data.getTag();
}

public void updateNBT(ItemStack itemStack) {
NBTLaser data = new NBTLaser(itemStack.stackTagCompound);
this.maxReceive = 10 * this.tier;
this.maxReceive = 50 * this.tier;
this.maxReceive += 10 * data.getItemCount(NBTLaser.Items.Capacitor);

this.capacity = (int) Math.ceil(this.baseCapacity + (1000 * (data.getItemCount(NBTLaser.Items.Capacitor)) + (((double) data.getItemCount(NBTLaser.Items.Overclock)) * 5)));

this.maxExtract = 10 + (75 * data.getItemCount(NBTLaser.Items.Overclock)) + (13 * data.getItemCount(NBTLaser.Items.Capacitor)) - data.getItemCount(NBTLaser.Items.Coolant) + (60 * data.getItemCount(NBTLaser.Items.Explosion)) + (60 * data.getItemCount(NBTLaser.Items.Phaser));
if (this.maxExtract < 10) this.maxExtract = 10;
this.capacity = this.baseCapacity;
this.capacity += 150 * data.getItemCount(NBTLaser.Items.Capacitor);

int cooldown = 100;
cooldown += 10 * data.getItemCount(NBTLaser.Items.Overclock);
cooldown += 10 * data.getItemCount(NBTLaser.Items.Phaser);
cooldown += 10 * data.getItemCount(NBTLaser.Items.Igniter);
cooldown -= 25 * data.getItemCount(NBTLaser.Items.Coolant);
data.setMaxCooldown(cooldown);

itemStack.stackTagCompound = data.getTag();
}

Expand All @@ -117,7 +128,7 @@ public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip,
int overclock = data.getItemCount(NBTLaser.Items.Overclock);
int explosion = data.getItemCount(NBTLaser.Items.Explosion);
int igniter = data.getItemCount(NBTLaser.Items.Igniter);

if (data.hasLens()) tooltip.add("Color: " + ColorUtils.getIntColorFromIntArray(data.getColor()));
if (capacitor > 0) tooltip.add(capacitor + " Capacitor(s)");
if (coolant > 0) tooltip.add(coolant + " Coolant(s)");
Expand Down

0 comments on commit 73d9978

Please sign in to comment.