Added Reconstruction Module as Rarmor integration

This commit is contained in:
Ellpeck 2016-05-06 16:11:26 +02:00
parent 1c0fb786b2
commit f21fa7e317
11 changed files with 175 additions and 34 deletions

View file

@ -43,6 +43,7 @@ dependencies {
//compile "codechicken:NotEnoughItems:1.8-1.0.5.104:dev" //compile "codechicken:NotEnoughItems:1.8-1.0.5.104:dev"
deobfCompile "mezz.jei:jei_1.9:3.3.3.197" deobfCompile "mezz.jei:jei_1.9:3.3.3.197"
compile file "lib/Rarmor.jar"
} }
processResources { processResources {

View file

@ -128,9 +128,8 @@ public class ActuallyAdditions{
@EventHandler @EventHandler
public void missingMapping(FMLMissingMappingsEvent event){ public void missingMapping(FMLMissingMappingsEvent event){
for(FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()){ for(FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()){
//Ignore removal of foreign paxels
if(mapping.name != null && mapping.name.toLowerCase(Locale.ROOT).startsWith(ModUtil.MOD_ID+":")){ if(mapping.name != null && mapping.name.toLowerCase(Locale.ROOT).startsWith(ModUtil.MOD_ID+":")){
if(mapping.name.contains("paxel") || mapping.name.contains("itemSpecial") || mapping.name.contains("blockBookStand")){ if(mapping.name.contains("paxel") || mapping.name.contains("itemSpecial") || mapping.name.contains("blockBookStand") || mapping.name.contains("Rarmor")){
mapping.ignore(); mapping.ignore();
ModUtil.LOGGER.info("Missing Mapping "+mapping.name+" is getting ignored. This is intentional."); ModUtil.LOGGER.info("Missing Mapping "+mapping.name+" is getting ignored. This is intentional.");
} }

View file

@ -191,6 +191,7 @@ public class CreativeTab extends CreativeTabs{
this.add(InitItems.itemPaxelCrystalBlack); this.add(InitItems.itemPaxelCrystalBlack);
this.add(InitItems.itemPaxelCrystalGreen); this.add(InitItems.itemPaxelCrystalGreen);
this.add(InitItems.itemPaxelCrystalWhite); this.add(InitItems.itemPaxelCrystalWhite);
this.add(InitItems.itemRarmorModuleReconstructor);
InitForeignPaxels.addToCreativeTab(); InitForeignPaxels.addToCreativeTab();
this.add(InitBlocks.blockCrystal); this.add(InitBlocks.blockCrystal);
@ -296,10 +297,14 @@ public class CreativeTab extends CreativeTabs{
} }
public void add(Item item){ public void add(Item item){
if(item != null){
item.getSubItems(item, instance, this.list); item.getSubItems(item, instance, this.list);
} }
}
public void add(Block block){ public void add(Block block){
if(block != null){
block.getSubBlocks(new ItemStack(block).getItem(), instance, this.list); block.getSubBlocks(new ItemStack(block).getItem(), instance, this.list);
} }
}
} }

View file

@ -29,6 +29,7 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fml.common.Loader;
public class InitItems{ public class InitItems{
@ -205,6 +206,8 @@ public class InitItems{
public static Item itemBootsCrystalWhite; public static Item itemBootsCrystalWhite;
public static Item itemPaxelCrystalWhite; public static Item itemPaxelCrystalWhite;
public static Item itemRarmorModuleReconstructor;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Items..."); ModUtil.LOGGER.info("Initializing Items...");
@ -366,5 +369,9 @@ public class InitItems{
itemPantsCrystalWhite = new ItemArmorAA("itemPantsCrystalWhite", InitArmorMaterials.armorMaterialCrystalWhite, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); itemPantsCrystalWhite = new ItemArmorAA("itemPantsCrystalWhite", InitArmorMaterials.armorMaterialCrystalWhite, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY);
itemBootsCrystalWhite = new ItemArmorAA("itemBootsCrystalWhite", InitArmorMaterials.armorMaterialCrystalWhite, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); itemBootsCrystalWhite = new ItemArmorAA("itemBootsCrystalWhite", InitArmorMaterials.armorMaterialCrystalWhite, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY);
itemPaxelCrystalWhite = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "itemPaxelCrystalWhite", Util.CRYSTAL_WHITE_RARITY, 14606302); itemPaxelCrystalWhite = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "itemPaxelCrystalWhite", Util.CRYSTAL_WHITE_RARITY, 14606302);
if(Loader.isModLoaded("rarmor")){
itemRarmorModuleReconstructor = new ItemRarmorModuleReconstructor("itemRarmorModuleReconstructor");
}
} }
} }

View file

@ -0,0 +1,124 @@
package de.ellpeck.actuallyadditions.mod.items;
import cofh.api.energy.IEnergyContainerItem;
import de.canitzp.rarmor.api.InventoryBase;
import de.canitzp.rarmor.api.modules.IRarmorModule;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.items.lens.Lenses;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import java.util.ArrayList;
import java.util.List;
@Optional.Interface(modid = "rarmor", iface = "de.canitzp.rarmor.api.modules.IRarmorModule")
public class ItemRarmorModuleReconstructor extends ItemBase implements IRarmorModule{
public ItemRarmorModuleReconstructor(String name){
super(name);
this.setMaxStackSize(1);
}
@Override
public String getUniqueName(){
return this.getRegistryName().toString();
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
@Override
public ModuleType getModuleType(){
return ModuleType.ACTIVE;
}
@Override
public List<String> getGuiHelp(){
List text = new ArrayList<String>();
text.add("Read more about this in the");
text.add("Actually Additions Manual!");
return text;
}
@Override
public void onModuleTickInArmor(World world, EntityPlayer player, ItemStack armorChestplate, ItemStack module, InventoryBase inventory){
if(!world.isRemote && player.isSneaking() && player.onGround){
if(world.getTotalWorldTime()%50 == 0){
RayTraceResult result = WorldUtil.getNearestPositionWithAir(world, player, Lenses.LENS_NONE.getDistance());
if(result != null){
BlockPos pos = result.getBlockPos();
if(pos != null){
IAtomicReconstructor fake = this.getFakeReconstructor(world, player, armorChestplate);
int energyUse = TileEntityAtomicReconstructor.ENERGY_USE*2;
if(fake.getEnergy() >= energyUse){
Lenses.LENS_NONE.invoke(world.getBlockState(pos), pos, fake);
EnumFacing hit = result.sideHit;
TileEntityAtomicReconstructor.shootLaser(world, player.posX-player.width/2, player.posY+player.getYOffset()+player.getEyeHeight()/2, player.posZ-player.width/2, pos.getX()+hit.getFrontOffsetX(), pos.getY()+hit.getFrontOffsetY(), pos.getZ()+hit.getFrontOffsetZ(), Lenses.LENS_NONE);
fake.extractEnergy(energyUse);
}
}
}
}
}
}
private IAtomicReconstructor getFakeReconstructor(final World world, final EntityPlayer player, final ItemStack armorChestplate){
return new IAtomicReconstructor(){
@Override
public int getX(){
return MathHelper.floor_double(player.posX);
}
@Override
public int getY(){
return MathHelper.floor_double(player.posY);
}
@Override
public int getZ(){
return MathHelper.floor_double(player.posZ);
}
@Override
public World getWorldObject(){
return world;
}
@Override
public void extractEnergy(int amount){
Item item = armorChestplate.getItem();
if(item instanceof IEnergyContainerItem){
((IEnergyContainerItem)item).extractEnergy(armorChestplate, amount, false);
}
}
@Override
public int getEnergy(){
Item item = armorChestplate.getItem();
if(item instanceof IEnergyContainerItem){
return ((IEnergyContainerItem)item).getEnergyStored(armorChestplate);
}
else{
return 0;
}
}
};
}
}

View file

@ -12,11 +12,9 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class ItemBase extends Item{ public class ItemBase extends Item{

View file

@ -23,12 +23,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class PacketParticle implements IMessage{ public class PacketParticle implements IMessage{
private int startX; private double startX;
private int startY; private double startY;
private int startZ; private double startZ;
private int endX; private double endX;
private int endY; private double endY;
private int endZ; private double endZ;
private float[] color; private float[] color;
private int particleAmount; private int particleAmount;
private float particleSize; private float particleSize;
@ -38,7 +38,7 @@ public class PacketParticle implements IMessage{
} }
public PacketParticle(int startX, int startY, int startZ, int endX, int endY, int endZ, float[] color, int particleAmount, float particleSize){ public PacketParticle(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int particleAmount, float particleSize){
this.startX = startX; this.startX = startX;
this.startY = startY; this.startY = startY;
this.startZ = startZ; this.startZ = startZ;
@ -51,13 +51,13 @@ public class PacketParticle implements IMessage{
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderParticlesFromAToB(int startX, int startY, int startZ, int endX, int endY, int endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){ public static void renderParticlesFromAToB(double startX, double startY, double startZ, double endX, double endY, double endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){
World world = Minecraft.getMinecraft().theWorld; World world = Minecraft.getMinecraft().theWorld;
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){ if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){
int difX = startX-endX; double difX = startX-endX;
int difY = startY-endY; double difY = startY-endY;
int difZ = startZ-endZ; double difZ = startZ-endZ;
double distance = new Vec3d(startX, startY, startZ).distanceTo(new Vec3d(endX, endY, endZ)); double distance = new Vec3d(startX, startY, startZ).distanceTo(new Vec3d(endX, endY, endZ));
for(int times = 0; times < particleAmount/2; times++){ for(int times = 0; times < particleAmount/2; times++){
@ -71,12 +71,12 @@ public class PacketParticle implements IMessage{
@Override @Override
public void fromBytes(ByteBuf buf){ public void fromBytes(ByteBuf buf){
this.startX = buf.readInt(); this.startX = buf.readDouble();
this.startY = buf.readInt(); this.startY = buf.readDouble();
this.startZ = buf.readInt(); this.startZ = buf.readDouble();
this.endX = buf.readInt(); this.endX = buf.readDouble();
this.endY = buf.readInt(); this.endY = buf.readDouble();
this.endZ = buf.readInt(); this.endZ = buf.readDouble();
this.particleAmount = buf.readInt(); this.particleAmount = buf.readInt();
this.particleSize = buf.readFloat(); this.particleSize = buf.readFloat();
@ -88,12 +88,12 @@ public class PacketParticle implements IMessage{
@Override @Override
public void toBytes(ByteBuf buf){ public void toBytes(ByteBuf buf){
buf.writeInt(this.startX); buf.writeDouble(this.startX);
buf.writeInt(this.startY); buf.writeDouble(this.startY);
buf.writeInt(this.startZ); buf.writeDouble(this.startZ);
buf.writeInt(this.endX); buf.writeDouble(this.endX);
buf.writeInt(this.endY); buf.writeDouble(this.endY);
buf.writeInt(this.endZ); buf.writeDouble(this.endZ);
buf.writeInt(this.particleAmount); buf.writeInt(this.particleAmount);
buf.writeFloat(this.particleSize); buf.writeFloat(this.particleSize);

View file

@ -103,11 +103,11 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
BlockPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, i); BlockPos hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, this.pos, i);
if(currentLens.invoke(this.worldObj.getBlockState(hitBlock), hitBlock, this)){ if(currentLens.invoke(this.worldObj.getBlockState(hitBlock), hitBlock, this)){
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); shootLaser(this.worldObj, this.getX(), this.getY(), this.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
break; break;
} }
else if(i >= distance-1){ else if(i >= distance-1){
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); shootLaser(this.worldObj, this.getX(), this.getY(), this.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
} }
} }
} }
@ -122,11 +122,11 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
return this.counter >= 500 ? Lenses.LENS_DISRUPTION : Lenses.LENS_NONE; return this.counter >= 500 ? Lenses.LENS_DISRUPTION : Lenses.LENS_NONE;
} }
private void shootLaser(int endX, int endY, int endZ, Lens currentLens){ public static void shootLaser(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, Lens currentLens){
if(!ConfigValues.lessSound){ if(!ConfigValues.lessSound){
this.worldObj.playSound(null, this.getX(), this.getY(), this.getZ(), SoundHandler.reconstructor, SoundCategory.BLOCKS, 0.35F, 1.0F); world.playSound(null, startX, startY, startZ, SoundHandler.reconstructor, SoundCategory.BLOCKS, 0.35F, 1.0F);
} }
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(this.getX(), this.getY(), this.getZ(), endX, endY, endZ, currentLens.getColor(), ConfigValues.lessParticles ? 2 : 8, 2F), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getX(), this.getY(), this.getZ(), 64)); PacketHandler.theNetwork.sendToAllAround(new PacketParticle(startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), ConfigValues.lessParticles ? 2 : 8, 2F), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 64));
} }
@Override @Override

View file

@ -332,6 +332,7 @@ item.actuallyadditions.itemChestQuartz.name=Black Quartz Chestplate
item.actuallyadditions.itemPantsQuartz.name=Black Quartz Pants item.actuallyadditions.itemPantsQuartz.name=Black Quartz Pants
item.actuallyadditions.itemBootsQuartz.name=Black Quartz Boots item.actuallyadditions.itemBootsQuartz.name=Black Quartz Boots
item.actuallyadditions.itemBooklet.name=Actually Additions Manual item.actuallyadditions.itemBooklet.name=Actually Additions Manual
item.actuallyadditions.itemRarmorModuleReconstructor.name=Reconstruction Module
item.actuallyadditions.itemLaserWrench.name=Laser Wrench item.actuallyadditions.itemLaserWrench.name=Laser Wrench
item.actuallyadditions.itemChestToCrateUpgrade.name=Chest To Storage Crate Upgrade item.actuallyadditions.itemChestToCrateUpgrade.name=Chest To Storage Crate Upgrade
item.actuallyadditions.itemMiscDrillCore.name=Drill Core item.actuallyadditions.itemMiscDrillCore.name=Drill Core

View file

@ -0,0 +1,6 @@
{
"parent": "actuallyadditions:item/standardItem",
"textures": {
"layer0": "actuallyadditions:items/itemRarmorModuleReconstructor"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B