mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Machines primus
This commit is contained in:
parent
56898a95db
commit
38d0bb17f9
5 changed files with 48 additions and 26 deletions
|
@ -251,32 +251,34 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
|||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof TileEntityBase){
|
||||
TileEntityBase base = (TileEntityBase)tile;
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK);
|
||||
if(!base.stopFromDropping){
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK);
|
||||
|
||||
//Remove unnecessarily saved default values to avoid unstackability
|
||||
List<String> keysToRemove = new ArrayList<String>();
|
||||
for(String key : data.getKeySet()){
|
||||
NBTBase tag = data.getTag(key);
|
||||
//Remove only ints because they are the most common ones
|
||||
//Add else if below here to remove more types
|
||||
if(tag instanceof NBTTagInt){
|
||||
if(((NBTTagInt)tag).getInt() == 0){
|
||||
keysToRemove.add(key);
|
||||
//Remove unnecessarily saved default values to avoid unstackability
|
||||
List<String> keysToRemove = new ArrayList<String>();
|
||||
for(String key : data.getKeySet()){
|
||||
NBTBase tag = data.getTag(key);
|
||||
//Remove only ints because they are the most common ones
|
||||
//Add else if below here to remove more types
|
||||
if(tag instanceof NBTTagInt){
|
||||
if(((NBTTagInt)tag).getInt() == 0){
|
||||
keysToRemove.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(String key : keysToRemove){
|
||||
data.removeTag(key);
|
||||
}
|
||||
for(String key : keysToRemove){
|
||||
data.removeTag(key);
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state));
|
||||
if(!data.hasNoTags()){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
stack.getTagCompound().setTag("Data", data);
|
||||
}
|
||||
ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state));
|
||||
if(!data.hasNoTags()){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
stack.getTagCompound().setTag("Data", data);
|
||||
}
|
||||
|
||||
drops.add(stack);
|
||||
drops.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return drops;
|
||||
|
|
|
@ -137,7 +137,7 @@ public final class InitBooklet{
|
|||
}
|
||||
crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTALS).setNoText());
|
||||
crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText());
|
||||
chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 0).setNoText());
|
||||
chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 145));
|
||||
chaptersIntroduction[6] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial();
|
||||
chaptersIntroduction[5] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).setWildcard().addTextReplacement("<rf>", TileEntityCoalGenerator.PRODUCE));
|
||||
ArrayList<BookletPage> empowererPages = new ArrayList<BookletPage>();
|
||||
|
|
|
@ -107,19 +107,23 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
|||
if(world.rand.nextBoolean()){
|
||||
TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb);
|
||||
if(compost instanceof TileEntityCompost){
|
||||
((TileEntityCompost)compost).setInventorySlotContents(0, new ItemStack(InitItems.itemFertilizer, 10));
|
||||
TileEntityCompost tile = (TileEntityCompost)compost;
|
||||
tile.stopFromDropping = true;
|
||||
tile.setInventorySlotContents(0, new ItemStack(InitItems.itemFertilizer, 10));
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity ferment = this.getTileAtPos(world, 11, 1, 0, sbb);
|
||||
if(ferment instanceof TileEntityFermentingBarrel){
|
||||
TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel)ferment;
|
||||
tile.stopFromDropping = true;
|
||||
tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500)+200));
|
||||
}
|
||||
|
||||
TileEntity coffee = this.getTileAtPos(world, 4, 2, 6, sbb);
|
||||
if(coffee instanceof TileEntityCoffeeMachine){
|
||||
TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine)coffee;
|
||||
tile.stopFromDropping = true;
|
||||
tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000)+500));
|
||||
tile.coffeeCacheAmount = world.rand.nextInt(150);
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
|
||||
|
@ -128,6 +132,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
|||
TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb);
|
||||
if(press instanceof TileEntityCanolaPress){
|
||||
TileEntityCanolaPress tile = (TileEntityCanolaPress)press;
|
||||
tile.stopFromDropping = true;
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3));
|
||||
tile.setInventorySlotContents(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal()));
|
||||
}
|
||||
|
@ -135,6 +140,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
|||
TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
|
||||
if(crusher instanceof TileEntityGrinder){
|
||||
TileEntityGrinder tile = (TileEntityGrinder)crusher;
|
||||
tile.stopFromDropping = true;
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
|
||||
if(world.rand.nextFloat() >= 0.25F){
|
||||
tile.setInventorySlotContents(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
|
||||
|
@ -143,7 +149,14 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
|||
|
||||
TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb);
|
||||
if(coal instanceof TileEntityCoalGenerator){
|
||||
((TileEntityCoalGenerator)coal).setInventorySlotContents(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1));
|
||||
TileEntityCoalGenerator tile = (TileEntityCoalGenerator)coal;
|
||||
tile.stopFromDropping = true;
|
||||
tile.setInventorySlotContents(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1));
|
||||
}
|
||||
|
||||
TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb);
|
||||
if(reconstructor instanceof TileEntityAtomicReconstructor){
|
||||
((TileEntityAtomicReconstructor)reconstructor).stopFromDropping = true;
|
||||
}
|
||||
|
||||
VillageComponentJamHouse.generateCrate(world, sbb, this.getXWithOffset(6, 4), this.getYWithOffset(4), this.getZWithOffset(6, 4), DungeonLoot.ENGINEER_HOUSE);
|
||||
|
@ -152,6 +165,8 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
|||
TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6, sbb);
|
||||
TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3, sbb);
|
||||
if(firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy){
|
||||
((TileEntityLaserRelayEnergy)firstRelay).stopFromDropping = true;
|
||||
((TileEntityLaserRelayEnergy)secondRelay).stopFromDropping = true;
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,12 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
|||
|
||||
public abstract class TileEntityBase extends TileEntity implements ITickable{
|
||||
|
||||
protected int ticksElapsed;
|
||||
|
||||
public final String name;
|
||||
public boolean isRedstonePowered;
|
||||
public boolean isPulseMode;
|
||||
protected int ticksElapsed;
|
||||
public boolean stopFromDropping;
|
||||
|
||||
protected TileEntity[] tilesAround = new TileEntity[6];
|
||||
protected boolean hasSavedDataOnChangeOrWorldStart;
|
||||
|
@ -185,6 +187,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
if(type == NBTType.SAVE_TILE){
|
||||
compound.setBoolean("Redstone", this.isRedstonePowered);
|
||||
compound.setInteger("TicksElapsed", this.ticksElapsed);
|
||||
compound.setBoolean("StopDrop", this.stopFromDropping);
|
||||
}
|
||||
if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){
|
||||
compound.setBoolean("IsPulseMode", this.isPulseMode);
|
||||
|
@ -199,6 +202,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
if(type == NBTType.SAVE_TILE){
|
||||
this.isRedstonePowered = compound.getBoolean("Redstone");
|
||||
this.ticksElapsed = compound.getInteger("TicksElapsed");
|
||||
this.stopFromDropping = compound.getBoolean("StopDrop");
|
||||
}
|
||||
if(this.isRedstoneToggle()){
|
||||
this.isPulseMode = compound.getBoolean("IsPulseMode");
|
||||
|
|
|
@ -1105,4 +1105,5 @@ booklet.actuallyadditions.chapter.website.text.1=On the topic of self-advertisem
|
|||
booklet.actuallyadditions.chapter.website.button.1=View the Website
|
||||
|
||||
booklet.actuallyadditions.chapter.engineerHouse.name=A visit to the Engineers
|
||||
booklet.actuallyadditions.chapter.engineerHouse.text.1=If you want to know how to start in your world, you can always check out what the <imp>Engineers<r> have been up to. <n>They are two friendly <imp>villagers<r> that sell you various goods: One is the <item>Crystallizer<r>, who will exchange <imp>Emeralds and Crystals<r> with you, and the <item>Engineer<r> will trade <imp>various machines<r> with you! On the next page, you can see the <imp>house<r> they live in - which is also worth checking out!
|
||||
booklet.actuallyadditions.chapter.engineerHouse.text.1=If you want to know how to start, you can check out what the <imp>Engineers<r> are up to. <n>They are two friendly <imp>villagers<r> that sell you various goods: One is the <item>Crystallizer<r>, who will exchange <imp>Emeralds and Crystals<r> with you, and the <item>Engineer<r> will trade <imp>various machines<r> with you! <n>On the next page, you can see the <imp>house<r> they live in - which is also worth checking out! But be careful, the <imp>machines inside the house<r> are a little more <imp>fragile<r>, meaning they will shatter once you try to break them.
|
||||
booklet.actuallyadditions.chapter.engineerHouse.text.2=<i> Machines Primus
|
Loading…
Reference in a new issue