This commit is contained in:
Ellpeck 2016-07-22 20:23:51 +02:00
parent b0e96caaf1
commit fdd4c295a4
13 changed files with 308 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting; import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting; import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.CommonEvents; import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.gen.InitVillager; import de.ellpeck.actuallyadditions.mod.gen.InitVillager;
@ -106,6 +107,7 @@ public class ActuallyAdditions{
new CommonEvents(); new CommonEvents();
InitCrafting.init(); InitCrafting.init();
DungeonLoot.init(); DungeonLoot.init();
InitEntities.init();
proxy.init(event); proxy.init(event);

View file

@ -52,6 +52,7 @@ public class CreativeTab extends CreativeTabs{
this.add(InitItems.itemBooklet); this.add(InitItems.itemBooklet);
this.add(InitBlocks.blockSmileyCloud); this.add(InitBlocks.blockSmileyCloud);
this.add(InitBlocks.blockTinyTorch);
this.add(InitBlocks.blockFireworkBox); this.add(InitBlocks.blockFireworkBox);
this.add(InitBlocks.blockLaserRelay); this.add(InitBlocks.blockLaserRelay);
@ -138,6 +139,7 @@ public class CreativeTab extends CreativeTabs{
this.add(InitBlocks.blockBlackLotus); this.add(InitBlocks.blockBlackLotus);
this.add(InitBlocks.blockBookletStand); this.add(InitBlocks.blockBookletStand);
this.add(InitItems.itemWorm);
this.add(InitItems.itemPlayerProbe); this.add(InitItems.itemPlayerProbe);
this.add(InitItems.itemColorLens); this.add(InitItems.itemColorLens);
this.add(InitItems.itemExplosionLens); this.add(InitItems.itemExplosionLens);

View file

@ -0,0 +1,111 @@
/*
* This file ("EntityWorm.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class EntityWorm extends Entity{
public int timer;
public EntityWorm(World world){
super(world);
}
@Override
protected void entityInit(){
}
@Override
protected void readEntityFromNBT(NBTTagCompound compound){
this.timer = compound.getInteger("Timer");
}
@Override
protected void writeEntityToNBT(NBTTagCompound compound){
compound.setInteger("Timer", this.timer);
}
@Override
public void onUpdate(){
this.onEntityUpdate();
}
@Override
public void onEntityUpdate(){
this.timer++;
if(!this.worldObj.isRemote){
if(this.timer%50 == 0){
for(int x = -1; x <= 1; x++){
for(int z = -1; z <= 1; z++){
BlockPos pos = new BlockPos(this.posX+x, this.posY, this.posZ+z);
IBlockState state = this.worldObj.getBlockState(pos);
Block block = state.getBlock();
boolean isMiddlePose = x == 0 && z == 0;
if(canWormify(this.worldObj, pos, state)){
boolean isFarmland = block instanceof BlockFarmland;
if(!isFarmland || state.getValue(BlockFarmland.MOISTURE) < 7){
if(isMiddlePose || this.worldObj.rand.nextFloat() >= 0.45F){
IBlockState stateToModify = isFarmland ? state : Blocks.FARMLAND.getDefaultState();
this.worldObj.setBlockState(pos, stateToModify.withProperty(BlockFarmland.MOISTURE, 7), 2);
if(!isFarmland){
this.worldObj.setBlockToAir(pos.up());
}
}
}
if(isFarmland && this.worldObj.rand.nextFloat() >= 0.95F){
BlockPos plant = pos.up();
if(!this.worldObj.isAirBlock(plant)){
IBlockState plantState = this.worldObj.getBlockState(plant);
Block plantBlock = plantState.getBlock();
plantBlock.updateTick(this.worldObj, plant, plantState, Util.RANDOM);
this.worldObj.playEvent(2005, plant, 0);
}
}
}
else if(isMiddlePose){
this.setDead();
}
}
}
}
}
}
public static boolean canWormify(World world, BlockPos pos, IBlockState state){
Block block = state.getBlock();
boolean rightBlock = block instanceof BlockFarmland || block == Blocks.GRASS || block == Blocks.GRASS_PATH || (block == Blocks.DIRT && state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT);
if(rightBlock){
BlockPos posUp = pos.up();
IBlockState stateUp = world.getBlockState(posUp);
return stateUp.getBlock().isReplaceable(world, posUp);
}
else{
return false;
}
}
}

View file

@ -0,0 +1,32 @@
/*
* This file ("InitEntities.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public final class InitEntities{
public static void init(){
ModUtil.LOGGER.info("Initializing Entities...");
EntityRegistry.registerModEntity(EntityWorm.class, ModUtil.MOD_ID+".worm", 0, ActuallyAdditions.instance, 64, 1, false);
}
@SideOnly(Side.CLIENT)
public static void initClient(){
RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm.FACTORY);
}
}

View file

@ -0,0 +1,57 @@
/*
* This file ("RenderWorm.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderWorm extends Render<EntityWorm>{
private static final ItemStack STACK = new ItemStack(InitItems.itemWorm);
public static final IRenderFactory FACTORY = new IRenderFactory(){
@Override
public Render createRenderFor(RenderManager manager){
return new RenderWorm(manager);
}
};
protected RenderWorm(RenderManager renderManager){
super(renderManager);
}
@Override
protected ResourceLocation getEntityTexture(EntityWorm entity){
return TextureMap.LOCATION_BLOCKS_TEXTURE;
}
@Override
public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks){
GlStateManager.pushMatrix();
GlStateManager.translate(x, y+0.7F, z);
GlStateManager.rotate((float)(((entity.timer)%360)), 0, 1, 0);
GlStateManager.translate(0, 0, 0.4);
AssetUtil.renderItemInWorld(STACK);
GlStateManager.popMatrix();
}
}

View file

@ -209,10 +209,12 @@ public final class InitItems{
public static Item itemWaterBowl; public static Item itemWaterBowl;
public static Item itemFilter; public static Item itemFilter;
public static Item itemPlayerProbe; public static Item itemPlayerProbe;
public static Item itemWorm;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Items..."); ModUtil.LOGGER.info("Initializing Items...");
itemWorm = new ItemWorm("itemWorm");
itemPlayerProbe = new ItemPlayerProbe("itemPlayerProbe"); itemPlayerProbe = new ItemPlayerProbe("itemPlayerProbe");
itemFilter = new ItemFilter("itemFilter"); itemFilter = new ItemFilter("itemFilter");
itemWaterBowl = new ItemWaterBowl("itemWaterBowl"); itemWaterBowl = new ItemWaterBowl("itemWaterBowl");

View file

@ -0,0 +1,84 @@
/*
* This file ("ItemWorm.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.Util;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.List;
public class ItemWorm extends ItemBase{
public ItemWorm(String name){
super(name);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10){
IBlockState state = world.getBlockState(pos);
if(EntityWorm.canWormify(world, pos, state)){
List<EntityWorm> worms = world.getEntitiesWithinAABB(EntityWorm.class, new AxisAlignedBB(pos.getX()-1, pos.getY(), pos.getZ()-1, pos.getX()+2, pos.getY()+1, pos.getZ()+2));
if(worms == null || worms.isEmpty()){
if(!world.isRemote){
EntityWorm worm = new EntityWorm(world);
worm.setPosition(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5);
world.spawnEntityInWorld(worm);
stack.stackSize--;
}
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, side, par8, par9, par10);
}
@SubscribeEvent
public void onHoe(UseHoeEvent event){
World world = event.getWorld();
if(!world.isRemote){
BlockPos pos = event.getPos();
IBlockState state = world.getBlockState(pos);
if(state.getBlock() instanceof BlockGrass && world.rand.nextFloat() > 0.7F){
ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2)+1);
EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack);
world.spawnEntityInWorld(item);
}
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.UNCOMMON;
}
}

View file

@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.render.RenderDisplayStand;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderReconstructorLens; import de.ellpeck.actuallyadditions.mod.blocks.render.RenderReconstructorLens;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderSmileyCloud; import de.ellpeck.actuallyadditions.mod.blocks.render.RenderSmileyCloud;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.ClientEvents; import de.ellpeck.actuallyadditions.mod.event.ClientEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit;
@ -137,6 +138,8 @@ public class ClientProxy implements IProxy{
} }
}); });
} }
InitEntities.initClient();
} }
/** /**

View file

@ -194,6 +194,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
compound.setBoolean("Redstone", this.isRedstonePowered); compound.setBoolean("Redstone", this.isRedstonePowered);
compound.setInteger("TicksElapsed", this.ticksElapsed);
} }
if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){ if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){
compound.setBoolean("IsPulseMode", this.isPulseMode); compound.setBoolean("IsPulseMode", this.isPulseMode);
@ -208,6 +209,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
public void readSyncableNBT(NBTTagCompound compound, NBTType type){ public void readSyncableNBT(NBTTagCompound compound, NBTType type){
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
this.isRedstonePowered = compound.getBoolean("Redstone"); this.isRedstonePowered = compound.getBoolean("Redstone");
this.ticksElapsed = compound.getInteger("TicksElapsed");
} }
if(this.isRedstoneToggle()){ if(this.isRedstoneToggle()){
this.isPulseMode = compound.getBoolean("IsPulseMode"); this.isPulseMode = compound.getBoolean("IsPulseMode");

View file

@ -501,6 +501,7 @@ item.actuallyadditions.itemFilter.name=Item Filter
item.actuallyadditions.itemMiscBiomass.name=Biomass item.actuallyadditions.itemMiscBiomass.name=Biomass
item.actuallyadditions.itemMiscBiocoal.name=Bio Coal item.actuallyadditions.itemMiscBiocoal.name=Bio Coal
item.actuallyadditions.itemPlayerProbe.name=Player Probe item.actuallyadditions.itemPlayerProbe.name=Player Probe
item.actuallyadditions.itemWorm.name=Worm
#Tooltips #Tooltips
tooltip.actuallyadditions.onSuffix.desc=On tooltip.actuallyadditions.onSuffix.desc=On

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,6 @@
{
"animation":
{
"frametime": 3
}
}