Jump to content

Toma™

Members
  • Posts

    80
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Toma™

  1. Hi, since I plan on adding quite a lot of blocks into the game, I don't feel like manually writing .json files for them. However I've run into issue - I don't know how to do it. To be more specific I've been able to automatically create block model and item model files also with basic blockstate file, but I've wanted to do it even for blocks with multiple properties, like PropertyDirection and PropertyBool for example (for single property it's simple). I can't really figure out how to do it for multiple properties so I'm looking for someone who knows how to and is willing to give me a few hints about this.

  2. Alright, I'm working on one project which has some kind of "core" mod (functions etc). I was always able to update the dependency version using the build.gradle where I change the deobfcompile line. Never had single problem. But suddenly, after updating to new version I got 403 Forbidden access error. So I deleted everything, cloned the workspace from github and rebuild the workspace with dependency without problems (but with the older version). Then I have tried to repeat the process again, but it has ended with the same result as before. I have no idea what the problem could be. This is the only dependency which causes problems.

    We're using github releases system for this. I have access to the repository, I can view it from any browser (but it's private)

    I'm pretty bad with all this gradle stuff so if someone knows what's the problem and how to solve it, please help me, I will appreciate that

    LOG:

    Spoiler

    To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14/userguide/gradle_daemon.html.
    This mapping 'stable_39' was designed for MC 1.12! Use at your own peril.
    #################################################
             ForgeGradle 2.3-SNAPSHOT-7764e3e
      https://github.com/MinecraftForge/ForgeGradle
    #################################################
                     Powered by MCP
                http://modcoderpack.com
         by: Searge, ProfMobius, R4wk, ZeuX
         Fesh0r, IngisKahn, bspkrs, LexManos
    #################################################
    Invalid cookie header: "Set-Cookie: AWSALB=UrDsSJ2Dywoalo/oTgjxsEZHNS+UD/8ZcN9YXij+s/ZGwEsBclSxNKvu8izHh/OP0c6LSDTAbbbjt9/n+3wa7EalOCT1CezANYy5iWYNl/5MXcZtGGQwNrrEyhWl; Expires=Sun, 30 Jun 2019 20:37:34 GMT; Path=/". Invalid 'expires' attribute: Sun, 30 Jun 2019 20:37:34 GMT
    Invalid cookie header: "Set-Cookie: AWSALB=I3WiXINsfm6vyCeNAs4uhF4Jy095Gzt5nRgzIVulmV5lP2WyPvtCgh3zZc3FsW1bGNW0ta47xUQpz9DFe46MVbka53GTVqRy9XCHERgCWQAwFk+IB1Ajrd7Up8UK; Expires=Sun, 30 Jun 2019 20:37:34 GMT; Path=/". Invalid 'expires' attribute: Sun, 30 Jun 2019 20:37:34 GMT

    FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring root project 'SpeedsterHeroes-Reborn'.
    > Could not resolve all dependencies for configuration ':deobfCompile'.
       > Could not resolve com.github.revivalmoddingteam:RevivalCore:0.3.1.
         Required by:
             com.speedstersreborn:SpeedsterHeroes-Reborn:0.0.6
          > Could not resolve com.github.revivalmoddingteam:RevivalCore:0.3.1.
             > Could not get resource 'https://jitpack.io/com/github/revivalmoddingteam/RevivalCore/0.3.1/RevivalCore-0.3.1.pom'.
                > Could not GET 'https://jitpack.io/com/github/revivalmoddingteam/RevivalCore/0.3.1/RevivalCore-0.3.1.pom'. Received status code 403 from server: Forbidden

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

     

  3. Hello,

    I've recently found issue with my sounds. They're being played so I guess I did everything the right way.

    I know that minecraft sounds are directional/stereo (I don't know the correct term) because I cannot pinpoint entity location without issues, but when I play my sound, it always feels like it's coming from the client position so it makes it hard to realize where the sound is coming from. I noticed there are few other sound classes like Positioned sound, but minecraft uses that only for records, so I guess the issue is somewhere else. I just have no idea how to get this done. Does anybody know something about this?

  4. 3 hours ago, Matryoshika said:

    This is most likely caused by the Entity's Frustum culling.
    Don't have access to a workspace right now, but there should be a boolean along the lines of ignoreFrustumCheck that you can set to true in your entity's class that has been inherited from the base Entity class.

     

    Okay, I have tried that, but my entity is still disapearing under some angles for some reason. I added that boolean into constructor and that's all. I've been looking into it's usage and it appears only the Dragon entity from Minecraft is using that and I did exactly the same implementation. :/

  5. Hello, I created quite large entity which can be ridden by 32 players, however I found issue with it's rendering... When I'm looking around the entity it stops rendering under some angles. I have tried setting it's size to big number to cover whole entity so when you look at the entity you should be able to see it's bounding box. That didn't help. Is there some way to get around this? I could post some code, but I think this is built in somewhere in Minecraft by default.

  6. To get blockstate use Block#getDefaultState()

    Block is the block you want to place, you can get it from block list like Blocks class

    To get block by registry name, try going through ForgeRegistry

    • Like 2
  7. Okay, thanks for suggestion and information, I thought updateFrequency is how often is entity being updated... 

    Anyway, I have tried pretty much all values ranging from 1 to 80 and every time I had issues. When I used 1 from what I remember the entity was rubberbanding quite a lot. I will try to move the motion logic on server, to see if it helps, although I'm pretty sure I've seen someone comment here about how it is important to handle motion logic on both sides, and I don't really think there would be different calculations on server and client (but I'm not expert at all). I was even debugging all motion related variables to see if they're the same and they were. I will try to move it on server, if it improves at least a bit I will be happy. Thanks for a lot of information

  8. Hello, I've created custom vehicle entity which is controllable. However I have quite big issue - as soon as I attempt to drive, the entity teleports back few times and then starts moving (while sometimes teleporting a bit). Also when I dismount the entity, it starts teleporting every second until it loses it's velocity. I have been reading few threads about this, but nothing worked. I made whole entity move on both sides, even started sending input packets to have most precise calculations, but nothing works. I'm out of ideas. I have been playing quite a lot with the updateFrequency on registration, but couldn't find anything what would work perfectly, it always had some kind of teleportation issues.

    For registration I use the forge event and entry system, with tracking range of 256 blocks and update frequency of 20.

     

    If it's helpful there's the entity code:

    Spoiler
    
    	private static final Predicate<Entity> TARGET = Predicates.and(EntitySelectors.NOT_SPECTATING, EntitySelectors.IS_ALIVE, Entity::canBeCollidedWith);
    	private static final AxisAlignedBB BOX = new AxisAlignedBB(-0.5d, 0d, -0.5d, 1.5d, 1d, 1.5d);
    	private static final float MAX_TURNING_MODIFIER = 3F;
    	
    	private boolean isWaterVehicle;
    	
    	/** The max damage vehicle can take before it explodes **/
    	public float maxHealth = 100f;
    	
    	/** Current health state **/
    	public float health = 100f;
    	
    	/** Acceleration speed **/
    	public float acceleration = 0.08f;
    	
    	/** Speed at which will vehicle turn **/
    	public float turnSpeed = 0.45f;
    	
    	/** The max speed vehicle will be able to do **/
    	public float maxSpeed = 1.2f;
    	
    	public float currentSpeed = 0;
    	
    	/** How well will the vehicle drive on different surfaces **/
    	public float turnModifier;
    	
    	//TODO implement
    	public float fuel = 100f;
    	
    	/** If the vehicle is broken or not **/
    	private boolean isBroken = false;
    	
    	/** Ticks underWater **/
    	private short timeInInvalidState;
    	
    	/** Handles inputs from player who is driving the vehicle **/
    	private boolean inputForward, inputBack, inputRight, inputLeft, inputBoost;
    	
    	public EntityVehicle(World world)
    	{
    		super(world);
    		setSize(1f, 1f);
    		stepHeight = 1f;
    		preventEntitySpawning = true;
    		maxSpeed = 1.0f;
    	}
    	
    	public EntityVehicle(World world, int x, int y, int z)
    	{
    		this(world);
    		setPosition(x, y, z);
    	}
    	
    	@Override
    	public void onUpdate()
    	{
    		super.onUpdate();
    
    		if(!this.isBeingRidden() && (!noAccerationInput() || !noTurningInput()))
    		{
    			inputForward = false;
    			inputBack = false;
    			inputRight = false;
    			inputLeft = false;
    		}
    		
    		updateMotion();
    		handleEntityCollisions();
    		if(!world.isRemote) checkState();
    
    		move(MoverType.SELF, motionX, motionY, motionZ);
    	}
    	
    	public void handleEntityCollisions()
    	{
    		Vec3d vec1 = new Vec3d(posX, posY, posZ);
    		Vec3d vec2 = new Vec3d(vec1.x + motionX, vec1.y + motionY, vec1.z + motionZ);
    		Entity e = findEntityInPath(vec1, vec2);
    		
    		if(e != null)
    		{
    			e.motionX += motionX * currentSpeed;
    			e.motionY += currentSpeed / 2;
    			e.motionZ += motionZ * currentSpeed;
    			e.attackEntityFrom(PMCDamageSources.VEHICLE, currentSpeed * 10f);
    		}
    	}
    	
    	public void updateMotion()
    	{
    		Vec3d lookVec = getLookVec();
    		
    		if(!isBroken && hasFuel())
    		{
    			if(inputForward && !inputBack)
    			{
    				burnFuel();
    				currentSpeed = currentSpeed < maxSpeed ? currentSpeed + acceleration : maxSpeed;
    			}
    			
    			if(inputBack && !inputForward)
    			{
    				burnFuel();
    				currentSpeed = currentSpeed > 0 ? currentSpeed - acceleration : currentSpeed > (-maxSpeed * 0.3f) ? currentSpeed - 0.02f : -maxSpeed * 0.3f;
    			}
    		}
    		
    		if(inputRight && !inputLeft)
    		{
    			turnModifier = turnModifier < MAX_TURNING_MODIFIER ? turnModifier + turnSpeed : MAX_TURNING_MODIFIER;
    		}
    		
    		if(inputLeft && !inputRight)
    		{
    			turnModifier = turnModifier > -MAX_TURNING_MODIFIER ? turnModifier - turnSpeed : -MAX_TURNING_MODIFIER;
    		}
    		
    		if(noAccerationInput() || isBroken)
    		{
    			if(Math.abs(currentSpeed) < 0.009f) currentSpeed = 0f;
    			
    			if(currentSpeed != 0)
    			{
    				currentSpeed = currentSpeed > 0 ? currentSpeed - 0.008f : currentSpeed + 0.008f;
    			}
    		}
    		
    		if(noTurningInput())
    		{
    			if(Math.abs(turnModifier) < 0.1f) turnModifier = 0f;
    			
    			if(turnModifier != 0)
    			{
    				turnModifier = turnModifier > 0 ? turnModifier - 0.3f : turnModifier + 0.3f;
    			}
    		}
    		
    		motionX = lookVec.x * currentSpeed;
    		motionZ = lookVec.z * currentSpeed;
    		if(currentSpeed != 0)
    		{
    			rotationYaw += currentSpeed > 0 ? turnModifier : -turnModifier;
    		}
    		
    		if(!onGround) motionY -= 0.1d;
    	}
    	
    	@Nullable
    	protected Entity findEntityInPath(Vec3d start, Vec3d end)
    	{
    		Entity e = null;
    		List<Entity> entityList = world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(motionX, motionY, motionZ).grow(1d), TARGET);
    		double d0 = 0;
    		
    		for(int i = 0; i < entityList.size(); i++)
    		{
    			Entity entity = entityList.get(i);
    			
    			if(entity != this)
    			{
                    AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().grow(0.30000001192092896D);
                    RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(start, end);
                    
                    if (raytraceresult != null)
                    {
                        double d1 = start.squareDistanceTo(raytraceresult.hitVec);
                        
                        if (d1 < d0 || d0 == 0.0D)
                        {
                            e = entity;
                            d0 = d1;
                        }
                    }
    			}
    		}
    		
    		return e;
    	}
    	
    	@Override
    	public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
    	{
    		if(!world.isRemote)
    		{
    			if(this.canBeRidden(player))
    			{
    				player.startRiding(this);
    			}
    		}
    		
    		return true;
    	}
    	
    	private void explode()
    	{
    		if(!world.isRemote)
    		{
    			this.world.createExplosion(this, posX, posY, posZ, 3f, false);
    			this.setDead();
    		}
    	}
    	
    	// Should be running only on server side in case some client doesn't receive packet
    	// containing new health value of this vehicle
    	protected void checkState()
    	{
    		// if whole vehicle is under water -> can drive in shallow water
    		if(this.isInWater() && world.getBlockState(getPosition().up()).getMaterial().isLiquid())
    		{
    			timeInInvalidState++;
    			motionX *= 0.4d;
    			motionZ *= 0.4d;
    			motionY = -0.15d;
    		}
    		
    		if(timeInInvalidState > 30)
    		{
    			isBroken = true;
    		}
    		
    		if(isInLava() || health <= 0f) explode();
    	}
    	
    	@Override
    	public boolean attackEntityFrom(DamageSource source, float amount)
    	{
    		if(!getPassengers().contains(source.getTrueSource()))
    		{
    			this.health -= amount;
    		}
    		
    		return true;
    	}
    	
    	public void handleInputs(boolean forward, boolean back, boolean right, boolean left, EntityPlayer player)
    	{
    		if(isPlayerDriver(player))
    		{
    			this.inputForward = forward;
    			this.inputBack = back;
    			this.inputLeft = left;
    			this.inputRight = right;
    		}
    	}
    	
    	@Override
    	public boolean isInRangeToRenderDist(double distance) 
    	{
    		return true;
    	}
    	
    	public boolean isPlayerDriver(EntityPlayer player)
    	{
    		return player.isRiding() && player.getRidingEntity() instanceof EntityVehicle && player.getRidingEntity().getPassengers().get(0) == player;
    	}
    	
    	private boolean isVehicleMoving()
    	{
    		return currentSpeed != 0;
    	}
    	
    	private boolean isVehicleMovingForward()
    	{
    		return currentSpeed > 0;
    	}
    	
    	private boolean isVehicleMovingBackward()
    	{
    		return currentSpeed < 0;
    	}
    	
    	@Override
    	protected void entityInit() 
    	{
    	}
    	
    	@Override
    	protected void readEntityFromNBT(NBTTagCompound compound)
    	{
    		posX = compound.getDouble("posX");
    		posY = compound.getDouble("posY");
    		posZ = compound.getDouble("posZ");
    		motionX = compound.getDouble("motionX");
    		motionY = compound.getDouble("motionY");
    		motionZ = compound.getDouble("motionZ");
    		health = compound.getFloat("health");
    		fuel = compound.getFloat("fuel");
    		currentSpeed = compound.getFloat("speed");
    		acceleration = compound.getFloat("acceleration");
    		turnSpeed = compound.getFloat("turnSpeed");
    		isBroken = compound.getBoolean("isBroken");
    	}
    	
    	@Override
    	protected void writeEntityToNBT(NBTTagCompound compound) 
    	{
    		compound.setDouble("posX", this.posX);
    		compound.setDouble("posY", this.posY);
    		compound.setDouble("posZ", this.posZ);
    		compound.setDouble("motionX", this.motionX);
    		compound.setDouble("motionY", this.motionY);
    		compound.setDouble("motionZ", this.motionZ);
    		compound.setFloat("health", this.health);
    		compound.setFloat("fuel", this.fuel);
    		compound.setFloat("speed", this.currentSpeed);
    		compound.setFloat("acceleration", this.acceleration);
    		compound.setFloat("turnSpeed", this.turnSpeed);
    		compound.setBoolean("isBroken", this.isBroken);
    	}
    	
    	@Override
    	public boolean canBeCollidedWith()
    	{
    		return true;
    	}
    	
    	public boolean noAccerationInput()
    	{
    		return !inputForward && !inputBack;
    	}
    	
    	public boolean noTurningInput()
    	{
    		return !inputRight && !inputLeft;
    	}
    	
    	public void setAllRequiredValues(float maxHealth, float health, float maxSpeed, float acceleration, float turnSpeed)
    	{
    		this.maxHealth = maxHealth;
    		this.health = health;
    		this.maxSpeed = maxSpeed;
    		this.acceleration = acceleration;
    		this.turnSpeed = turnSpeed;
    	}
    	
    	public boolean hasFuel()
    	{
    		return fuel > 0; 
    	}
    	
    	/** Call with Fuel can **/
    	public void refill()
    	{
    		fuel = fuel + 30f < 100f ? fuel + 30f : 100f;
    	}
    	
    	/** Decrement each tick **/
    	public void burnFuel()
    	{
    		fuel = hasFuel() ? fuel - 0.05f : 0f;
    	}

     

     

    Input is being taken from ClientTickEvent and is synced throught packet to the entity - not sure if it's good idea, but I gave it a try, since nothing seemed to work

     

  9. 47 minutes ago, Draco18s said:

    So, uh, center = center and size = size? 

    Not much to compute there.

    So you need to move or resize the world border based on the players location? 

    Well. Move the center to the player's location and set the size to some value while they're inside the unrestricted region. ..

    I think you misunderstood my post a bit.

    What I meant is this:

    - I have map where I defined the map center (zone minimal offset) and map size (zone maximal offset). Then random zone center is calculated based on these values -> Zone center is between these 2 points.

    - The default zone size is the map size multiplied by 2

    - But since the map is being offset from the map center, the zone corners don't cover all maps corners (obviously). So I'm looking for a way to calculate the new zone size based on the map size*2 and the zone's offset from the map center. I've been trying some triangle math here, but that didn't work. I'm trying to always have 2 corners of the zone cover 2 corners of the map and the other 2 zone corners to stick away from the map. So far I managed to get it to work with 1 side of the zone, but now I'm completely lost.

     

    I will post GitHub link to my first post with updated code & my attempts.

  10. Hello everyone, I'm attempting to create shrinking zone system (like pubg and other BRs). I'm working on way to control it throught commands and in order to save it all I've made capability just for that. It all works fine.

    When creating the map you have to specify the map center and map size. When you run command to start the game, center of world border is calculated based on these values. But I need to have dynamic size of the world border to prevent it blocking some parts of the map. I have tried few things, but nothing was precise. So I am asking the Minecraft community if somebody is more experienced with all this maths stuff to help me with this. I want to be able to have always 2 sides of the map inside the border (I know I can't have all on square map with offset world border - so the other 2 sides of the border will be longer than the map size, but that doesn't matter).

    So what I have tried (the part of the code responsible for calculating the border size and center) :

    Spoiler
    
    	private void startGame(IGameData data, World world)
    	{
    		WorldBorder border = world.getWorldBorder();
    		BlockPos center = data.getMapCenter();
    		int size = data.getMapSize();
    		
    		BlockPos zoneCenter = new BlockPos(generateZoneCenterX(center, size), 256, generateZoneCenterZ(center, size));
    		
    		while(world.isAirBlock(zoneCenter))
    		{
    			zoneCenter = new BlockPos(zoneCenter.getX(), zoneCenter.getY() - 1, zoneCenter.getZ());
    			if(world.getBlockState(zoneCenter).getMaterial().isLiquid())
    			{
    				Pubgmc.logger.info("Generating new zone center...");
    				zoneCenter = new BlockPos(generateZoneCenterX(zoneCenter, size), 256, generateZoneCenterZ(zoneCenter, size));
    			}
    		}
    		
    		// ATTEMP 1
    		/*int rangeX = Math.abs(center.getX() - zoneCenter.getX());
    		int rangeZ = Math.abs(center.getZ() - zoneCenter.getZ());
    		double totalDistance = Math.sqrt(sqr(rangeX) + sqr(rangeZ));*/
    		
    		//ATEMP 2
    		int totalDistance = Math.abs(center.getX() - zoneCenter.getX()) + Math.abs(center.getZ() - zoneCenter.getZ());
    		
    		border.setCenter(zoneCenter.getX(), zoneCenter.getZ());
    		border.setTransition(size + totalDistance);
    	}

     

     

     

    GitHub

  11. I've been playing a bit with raytraceresults for my EntityBullet logic and I was messing with the vectors you get when you hit something. I've found that I can use RayTraceResult#hitVec to get exact coordinates of hit, but it works only for blocks. I wanted to use it for entities to be able to calculate damage based on the position of the hit, but it always get's the entity position rather than the hit position. Is there some way to calculate it on the entity/entity hitbox?

  12. 1 hour ago, Bomb787 said:

    Toolbox 2.0 is a pretty good program that we use for Flans Mod

     

    Yeah, I heard about it too, but isn't it really meant only for work with flans mod? I don't really know, I have worked with it only once and it looks like it's done only for the flans mod because of some different rendering stuff which wouldn't work with other mods unless I would create or copy flan's model rendering system.

  13. 10 hours ago, Cadiboo said:

    I do my best to keep all my models in JSON so resource packs can change them, so I use BlockBench. I think it might have an option to export to java models if you really can’t use JSON though

    Yeah, the BlockBench has the feature and it looks like it was added recently. Thanks for your help 

  14. 9 hours ago, Cadiboo said:

    I do my best to keep all my models in JSON so resource packs can change them, so I use BlockBench. I think it might have an option to export to java models if you really can’t use JSON though

    Well I like the .java models for creating stuff like weapons and some stuff like that, for me it feels like it's easier work with that. Thanks about the answer, I'll take a look at the BlockBench, last time I used it, there was no java option, but that might be because I was using the web app.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.