Skip to content

Commit

Permalink
1.0.4.1 Update:
Browse files Browse the repository at this point in the history
-Added custom particles for mirrors;
-Optimized loot manager and loot pools;
-Changed configuration manager.
  • Loading branch information
Codename Revy committed Jan 14, 2020
1 parent daded17 commit b55f97f
Show file tree
Hide file tree
Showing 26 changed files with 257 additions and 248 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'

version = '1.0.4.0'
version = '1.0.4.1'
group = 'com.codenamerevy.magicmirror'
archivesBaseName = 'magicmirror'

Expand Down Expand Up @@ -76,7 +76,7 @@ minecraft {

dependencies {
// Forge version
minecraft 'net.minecraftforge:forge:1.15.1-30.0.36'
minecraft 'net.minecraftforge:forge:1.15.1-30.0.39'
}

// Manifest for reading by the runtime..
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/com/codenamerevy/magicmirror/MagicMirror.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.codenamerevy.magicmirror;

import com.codenamerevy.magicmirror.config.MagicMirrorsConfig;
import com.codenamerevy.magicmirror.init.ParticleInit;
import com.codenamerevy.magicmirror.tabs.MirrorsItemGroup;
import com.codenamerevy.magicmirror.util.Ref;
import com.codenamerevy.magicmirror.util.handler.EventHandler;
import com.codenamerevy.magicmirror.util.handler.LootHandler;
import com.codenamerevy.magicmirror.util.handler.RegistryHandler;
import com.codenamerevy.magicmirror.util.handler.SoundHandler;
import com.codenamerevy.magicmirror.util.handler.*;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down Expand Up @@ -36,16 +36,6 @@ public MagicMirror()
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, MagicMirrorsConfig.CLIENT_CONFIG);

}

@SubscribeEvent
public void clientSetup(final FMLClientSetupEvent event)
{
if(MagicMirrorsConfig.CategoryDeveloper.enableLogger.get()) {
Ref.LOGGER.info("Doing Client Setup!");
Ref.LOGGER.info("START MAGICMIRRORS MOD LOADING. IF YOU ARE NOT A DEVELOPER, PLEASE DISABLE INTERNAL LOGGING IN magicmirrors-debug.toml!");
}
}

@SubscribeEvent
public void commonSetup (final FMLCommonSetupEvent event)
{
Expand All @@ -57,5 +47,16 @@ public void commonSetup (final FMLCommonSetupEvent event)
MinecraftForge.EVENT_BUS.register(EventHandler.class);
MinecraftForge.EVENT_BUS.register(LootHandler.class);
}

@SubscribeEvent
public void clientSetup(final FMLClientSetupEvent event)
{
if(MagicMirrorsConfig.CategoryDeveloper.enableLogger.get()) {
Ref.LOGGER.info("Doing Client Setup!");
Ref.LOGGER.info("STARTING MAGICMIRRORS MOD LOADING. IF YOU ARE NOT A DEVELOPER, PLEASE DISABLE INTERNAL LOGGING IN CONFIG");
}
MinecraftForge.EVENT_BUS.register(ParticleHandler.class);
MinecraftForge.EVENT_BUS.register(ParticleFactoryHandler.class);
}
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @author CodenameRevy
*/

package com.codenamerevy.magicmirror.content.items;

import com.codenamerevy.magicmirror.init.SoundInit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/**
* @author CodenameRevy
*/

package com.codenamerevy.magicmirror.content.items;

import com.codenamerevy.magicmirror.init.ParticleInit;
import com.codenamerevy.magicmirror.init.SoundInit;
import com.codenamerevy.magicmirror.util.TeleportHelper;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -32,11 +37,9 @@ public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player
@Override
public void onUsingTick (ItemStack stack, LivingEntity entity,int count)
{

Random rand = entity.world.rand;
for (int i = 0; i < 45; i++)
{
entity.world.addParticle(ParticleTypes.DRAGON_BREATH, entity.serverPosX + (rand.nextBoolean() ? -1 : 1) * Math.pow(rand.nextFloat(), 2) * 2, entity.chunkCoordY + rand.nextFloat() * 3 - 2, entity.serverPosZ + (rand.nextBoolean() ? -1 : 1) * Math.pow(rand.nextFloat(), 2) * 2, 0, 0.105D, 0);
for(int a = 0; a < 25; a++) {
entity.world.addParticle(ParticleInit.MIRROR_PARTICLE, entity.lastTickPosX + (rand.nextBoolean() ? -1 : 1) * Math.pow(rand.nextFloat(), 2) * 2, entity.lastTickPosY + rand.nextFloat() * 3 - 2, entity.lastTickPosZ + (rand.nextBoolean() ? -1 : 1) * Math.pow(rand.nextFloat(), 2) * 2, -1, -0.105D, -1);
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/codenamerevy/magicmirror/init/ParticleInit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.codenamerevy.magicmirror.init;

import com.codenamerevy.magicmirror.util.Ref;
import net.minecraft.particles.BasicParticleType;
import net.minecraftforge.registries.ObjectHolder;

@ObjectHolder(Ref.MODID)
public class ParticleInit
{
public static final BasicParticleType MIRROR_PARTICLE = createBasicParticleType(false, "mirror_particle");

private static BasicParticleType createBasicParticleType(boolean alwaysShow, String name) {
BasicParticleType particleType = new BasicParticleType(alwaysShow);
particleType.setRegistryName(Ref.MODID, name);
return particleType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.codenamerevy.magicmirror.particle;

import net.minecraft.client.particle.*;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.Random;

public class MirrorParticle extends SpriteTexturedParticle
{
private static final Random RAND = new Random();
protected final IAnimatedSprite animatedSprite;

private MirrorParticle(IAnimatedSprite animatedSprite, World world, double x, double y, double z, double speedX, double speedY, double speedZ) {
super(world, x, y, z, 0.5D - RAND.nextDouble(), speedY, 0.5D - RAND.nextDouble());
this.animatedSprite = animatedSprite;
this.motionY *= 0.20000000029082000D;
if(speedX == 0.0D && speedZ == 0.0D) {
this.motionX *= 0.10000000029082000D;
this.motionZ *= 0.10000000029082000D;
}
this.particleScale *= 0.5F;
this.maxAge = (int)(7.5D / (Math.random() * 0.4D + 0.2D));
this.canCollide = false;
this.selectSpriteWithAge(animatedSprite);
}

public void tick()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if(this.age++ >= this.maxAge){
this.setExpired();
}else{
this.selectSpriteWithAge(this.animatedSprite);
this.motionY += 0.04D;
this.move(this.motionX, this.motionY, this.motionZ);
if(this.posY == this.prevPosY){
this.motionX *= 1.1D;
this.motionZ *= 1.1D;
}
this.motionX *= 0.9599999785423279D;
this.motionY *= 0.9599999785423279D;
this.motionZ *= 0.9599999785423279D;
if (this.onGround) {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
}
}

@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}

@Override
public int getBrightnessForRender(float partialTick) {
float f = ((float) this.age + partialTick) / (float) this.maxAge;
f = MathHelper.clamp(f, 0f, 1f);
int i = super.getBrightnessForRender(partialTick);
int j = i & 255;
int k = i >> 16 & 255;
j = j + (int) (f * 15f * 16f);
if (j > 240) {
j = 240;
}
return j | k << 16;
}

@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private IAnimatedSprite animatedSprite;

public Factory(IAnimatedSprite animatedSprite) {
this.animatedSprite = animatedSprite;
}

@Override
public Particle makeParticle(BasicParticleType type, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new MirrorParticle(this.animatedSprite, world, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @author CodenameRevy
*/

package com.codenamerevy.magicmirror.util;

import com.codenamerevy.magicmirror.init.SoundInit;
Expand All @@ -14,7 +18,7 @@ public class TeleportHelper
{
private static PlayerEntity player;

public static final void travelHome(PlayerEntity player)
public static void travelHome(PlayerEntity player)
{
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;

Expand All @@ -24,7 +28,7 @@ public static final void travelHome(PlayerEntity player)
serverPlayer.teleport(player.getServer().getWorld(transDimension), serverPlayer.serverPosX, serverPlayer.serverPosY, serverPlayer.serverPosZ, serverPlayer.rotationYaw, serverPlayer.rotationPitch);
}

public static final void setPositionAndUpdate(LivingEntity entity, World world, BlockPos bedPos)
public static void setPositionAndUpdate(LivingEntity entity, World world, BlockPos bedPos)
{
player = (ServerPlayerEntity) entity;

Expand Down
Loading

0 comments on commit b55f97f

Please sign in to comment.